Create a full-stack web application using Next.js App Router, Drizzle ORM with PostgreSQL, and Tailwind CSS. The application will be a SaaS tool named 'Roth IRA Filing Assistant' to help users correctly file their Backdoor Roth IRA contributions, especially addressing the overlooked 1099-R forms and past filing errors. The MVP must include robust backend logic for user management, financial data handling, and IRS compliance guidance. Avoid creating a simple landing page or SPA; focus on a multi-page application structure with proper data persistence and API routes.
**Project Structure:**
- `app/` directory for routing (multi-page)
- `components/` for reusable UI components (React)
- `lib/` for utility functions and helpers
- `prisma/` or `drizzle/` for database schema and migrations
- `api/` routes for backend logic
**Core Features to Implement:
1. **User Authentication:** Secure user registration, login, and session management (e.g., using NextAuth.js or Clerk).
2. **1099-R Data Input Form:**
* A multi-step form within the `app/` directory to capture user's 1099-R details: Box 1 (Gross distribution), Box 2 (Taxable amount), Box 5 (Employee contributions/Designated Roth contributions). Use clear labels and input validation.
* Implement CRUD operations for storing this data associated with the logged-in user.
3. **Tax Filing Guidance Module:**
* Based on the entered 1099-R data (especially when Taxable Amount is $0.01 or very low, indicating after-tax contributions), provide step-by-step guidance on how to correctly enter this information in common tax software like FreeTaxUSA. This section should explain *where* to input the information and *what options* to select.
* Create API routes to process this data and return tailored guidance.
4. **Prior Year Filing Error Correction:**
* A dedicated section for users who missed filing for previous years.
* Provide detailed explanations on the IRS amendment process (Form 1040-X).
* Generate basic templates or guidance for drafting an amendment, referencing the user's inputted 1099-R data.
* API endpoints to retrieve user's historical 1099-R data for amendment reference.
5. **IRA Basis Tracking (Basic MVP):
* A simple module to track total after-tax contributions made to Roth IRAs over the years, which helps establish the 'basis' for future tax calculations.
* API endpoints for creating, reading, updating, and deleting basis records.
6. **IRS Compliance & Potential Penalty Estimation (Simplified):**
* A feature to estimate potential penalties or interest if a user has significantly unfiled or misfiled information, based on common IRS guidelines. This should be presented as an estimate, not definitive advice.
**Technical Stack & Requirements:**
* **Framework:** Next.js (App Router)
* **Database:** PostgreSQL with Drizzle ORM.
* **Schema:** Define tables for `users`, `forms_1099r` (with fields for user ID, tax year, box values), `ira_basis_contributions` (with fields for user ID, year, amount, type - e.g., 'after-tax'), and potentially `filing_amendments` (for tracking correction attempts).
* **Migrations:** Use Drizzle's migration system to manage schema changes.
* **Styling:** Tailwind CSS for rapid UI development.
* **API Routes:** Implement RESTful API endpoints under `app/api/` for all CRUD operations and complex business logic (e.g., tax guidance generation).
* **Error Handling:** Implement robust error handling on both frontend and backend.
* **Security:** Ensure all data handling is secure, especially financial and personal information. Implement input sanitization and validation.