You are an expert full-stack developer. Your task is to build a fully functional Minimum Viable Product (MVP) application called 'TaxInsight Pro' using Next.js 14 with the App Router, TypeScript, and Tailwind CSS for styling. The application should allow users to compare W2 (employee) and 1099 (independent contractor) employment statuses financially, manage expenses, and generate basic reports.
**Core Requirements:**
1. **Next.js 14 App Router Structure:** Organize all files within the `app/` directory following Next.js conventions.
2. **TypeScript:** Use TypeScript for all components, API routes, and database models.
3. **Tailwind CSS:** Implement a modern and responsive UI using Tailwind CSS.
4. **Multi-page Application:** The application must have distinct routes and pages, not a single-page application.
5. **Database & ORM:**
* Use a PostgreSQL database (or SQLite for local development convenience).
* Implement Drizzle ORM for database interactions.
* **Database Schema:**
* `users` table: `id (UUID, primary key)`, `email (VARCHAR, unique)`, `password_hash (VARCHAR)`, `created_at (TIMESTAMP)`, `updated_at (TIMESTAMP)`.
* `comparisons` table: `id (UUID, primary key)`, `userId (UUID, foreign key to users.id)`, `status_type (ENUM('W2', '1099'))`, `hourly_rate (DECIMAL)`, `hours_per_week (DECIMAL)`, `estimated_gross_income (DECIMAL)`, `estimated_deductions (DECIMAL)`, `estimated_taxes (DECIMAL)`, `estimated_net_income (DECIMAL)`, `created_at (TIMESTAMP)`.
* `expenses` table: `id (UUID, primary key)`, `userId (UUID, foreign key to users.id)`, `category (VARCHAR)`, `amount (DECIMAL)`, `description (TEXT)`, `expense_date (DATE)`, `created_at (TIMESTAMP)`.
* **Drizzle Configuration:** Set up Drizzle ORM with migrations and schema definitions.
6. **Authentication:**
* Basic user registration (`/register`) and login (`/login`) functionality.
* Implement session management (e.g., using NextAuth.js or custom JWT-based authentication via cookies) to protect authenticated routes.
7. **API Routes (CRUD Operations):**
* `/api/auth/register` (POST): Register new user.
* `/api/auth/login` (POST): Authenticate user and create session.
* `/api/comparisons` (GET, POST):
* GET: Retrieve all comparison entries for the authenticated user.
* POST: Create a new W2/1099 comparison entry.
* `/api/comparisons/[id]` (GET, PUT, DELETE):
* GET: Retrieve a specific comparison entry.
* PUT: Update an existing comparison entry.
* DELETE: Delete a comparison entry.
* `/api/expenses` (GET, POST):
* GET: Retrieve all expense entries for the authenticated user.
* POST: Create a new expense entry.
* `/api/expenses/[id]` (GET, PUT, DELETE):
* GET: Retrieve a specific expense entry.
* PUT: Update an existing expense entry.
* DELETE: Delete an expense entry.
**Frontend Pages & Components:**
1. **Landing Page (`/`):** Publicly accessible, introduces the app, call-to-action for login/register.
2. **Login Page (`/login`):** User login form.
3. **Register Page (`/register`):** User registration form.
4. **Dashboard Page (`/dashboard`):** Protected route. Displays a summary of user's comparisons and recent expenses. A simple welcome message and navigation links.
5. **W2/1099 Comparison Tool Page (`/dashboard/compare`):** Protected route.
* A form to input details for both W2 and 1099 scenarios: hourly rate, estimated weekly hours.
* A calculation logic that estimates gross income, standard/itemized deductions (simplified placeholder logic for MVP, e.g., fixed percentage or user input), and estimated taxes (simplified, e.g., a fixed percentage for income tax + self-employment tax for 1099).
* Displays a side-by-side comparison of estimated net income for both scenarios.
* Ability to save the comparison to the database.
6. **Expense Management Page (`/dashboard/expenses`):** Protected route.
* A form to add new expenses (category, amount, description, date).
* A table displaying all user's expenses with options to edit and delete (CRUD UI).
7. **Reports Page (`/dashboard/reports`):** Protected route.
* Displays a list of saved comparisons.
* Allows users to view detailed individual comparison reports.
* (Optional for MVP): A simple summary of total expenses by category.
**Styling:**
* Use Tailwind CSS classes for all styling. Ensure responsive design.
**Development Environment Setup:**
* Provide instructions for setting up the Next.js project.
* Instructions for Drizzle ORM setup (migration commands, schema definition).
* Example `.env` file for database connection string and auth secrets.
**Output:**
Provide the complete file structure and code for the described MVP, including:
* `package.json` with necessary dependencies.
* Next.js project setup files.
* Database schema (`schema.ts`).
* Drizzle configuration.
* Authentication helpers/middleware.
* All required API routes.
* All required frontend pages and components.
* Basic utility functions for tax estimation (can be simplified for MVP).
Focus on functionality and a clean, maintainable code structure. Ensure all routes are protected where necessary and CRUD operations are fully functional for `comparisons` and `expenses`.