You are tasked with building a sophisticated Minimum Viable Product (MVP) for a personal finance web application called "Debt Compass" (Borç Pusulası). This application is designed to help individuals with high debt-to-income ratios, specifically those with significant student loan burdens, create realistic and personalized repayment strategies. The MVP should NOT be a simple landing page or a single-page application (SPA). It must be a multi-page application built with Next.js using the App Router (the `app/` directory structure). The application needs a robust backend with a database and full CRUD (Create, Read, Update, Delete) functionality for key entities.
**Technology Stack:**
* **Framework:** Next.js (App Router)
* **Database:** PostgreSQL
* **ORM:** Drizzle ORM (for schema definition and querying)
* **UI:** Tailwind CSS (for styling)
* **Authentication:** NextAuth.js (for user authentication)
**Core Features & Database Schema (Drizzle ORM):**
1. **User Authentication:** Secure user registration and login using NextAuth.js.
* `users` table: `id` (uuid, pk), `name` (text), `email` (text, unique), `emailVerified` (timestamp, optional), `image` (text, optional), `createdAt` (timestamp)
2. **Debt Management:** Users can input and manage their various debts, focusing on student loans.
* `debts` table: `id` (uuid, pk), `userId` (uuid, fk to users), `name` (text), `type` (enum: 'student', 'car', 'mortgage', 'credit_card', 'personal'), `totalAmount` (numeric), `currentBalance` (numeric), `interestRate` (numeric, e.g., 6.5 for 6.5%), `dueDate` (date, optional), `createdAt` (timestamp), `updatedAt` (timestamp)
3. **Income & Expense Tracking:** Users can log their income sources and recurring expenses.
* `incomes` table: `id` (uuid, pk), `userId` (uuid, fk to users), `source` (text), `amount` (numeric), `frequency` (enum: 'monthly', 'bi-weekly', 'weekly', 'irregular'), `date` (date), `createdAt` (timestamp)
* `expenses` table: `id` (uuid, pk), `userId` (uuid, fk to users), `description` (text), `amount` (numeric), `frequency` (enum: 'monthly', 'bi-weekly', 'weekly', 'irregular'), `date` (date), `createdAt` (timestamp)
4. **Repayment Strategy Simulation:** The core of the MVP. Users can simulate different repayment scenarios.
* `repaymentPlans` table: `id` (uuid, pk), `userId` (uuid, fk to users), `name` (text, e.g., 'Aggressive Payoff', 'SAVE Plan Focus'), `planType` (enum: 'standard', 'save', 'custom', 'snowball', 'avalanche'), `startDate` (date), `createdAt` (timestamp)
* `planSimulations` table: `id` (uuid, pk), `repaymentPlanId` (uuid, fk to repaymentPlans), `debtId` (uuid, fk to debts), `month` (integer, 1-12), `year` (integer), `startingBalance` (numeric), `principalPaid` (numeric), `interestPaid` (numeric), `endingBalance` (numeric), `totalPaidThisMonth` (numeric), `createdAt` (timestamp)
**Application Structure (Next.js App Router):**
* `/app/dashboard`: Main dashboard page after login, showing a summary of debts, income, expenses, and current plan status.
* `/app/debts`: Page to view, add, edit, and delete debts.
* `/app/income-expenses`: Page to manage income and expense entries.
* `/app/strategies`: Page to create new repayment plans, run simulations, and view results.
* `/app/strategies/[planId]`: Detailed view of a specific repayment plan and its simulation results.
* `/app/settings`: User profile and application settings.
* `/app/api/...`: API routes for all CRUD operations.
**API Routes (Example Structure using Drizzle & PostgreSQL):**
* `POST /api/auth/signup`, `POST /api/auth/signin`, etc. (handled by NextAuth.js)
* `GET /api/debts`: Fetch all debts for the logged-in user.
* `POST /api/debts`: Add a new debt.
* `PUT /api/debts/[debtId]`: Update a specific debt.
* `DELETE /api/debts/[debtId]`: Delete a specific debt.
* Similar CRUD API routes for `incomes`, `expenses`, `repaymentPlans`, and `planSimulations`.
**Key Functionality to Implement:**
1. **User Dashboard:** Display a clear overview of the user's financial situation, including total debt, monthly payments, income, expenses, and savings progress.
2. **Debt Input & Management:** Allow users to accurately input all details of their student loans and other debts.
3. **Income/Expense Logging:** Simple interface for users to log their income and recurring expenses.
4. **Repayment Plan Creation:** Allow users to select different repayment strategies (e.g., SAVE plan calculations, Snowball, Avalanche) and input parameters.
5. **Simulation Engine:** Implement the logic to simulate monthly progress for each selected debt based on the chosen repayment plan, calculating principal and interest paid, and remaining balance.
6. **Analysis & Visualization:** Display simulation results clearly, perhaps with charts showing debt reduction over time, total interest paid, and projected payoff dates. Provide comparisons between different plan types.
7. **Financial Health Score:** Develop a basic algorithm to calculate a score based on debt-to-income ratio, savings rate, and debt payoff progress.
**Prompt Instructions:**
* Set up the Next.js project with the App Router.
* Configure Drizzle ORM with PostgreSQL (use a local development database like Dockerized PostgreSQL or any accessible instance).
* Implement all necessary database schema using Drizzle.
* Create API routes (using `route.ts` files in `app/api/`) for all CRUD operations for `users`, `debts`, `incomes`, `expenses`, `repaymentPlans`, and `planSimulations` tables.
* Integrate NextAuth.js for user authentication.
* Build the UI components using React and Tailwind CSS for the specified pages (`/dashboard`, `/debts`, `/income-expenses`, `/strategies`, `/strategies/[planId]`, `/settings`).
* Implement the core simulation logic for at least the SAVE plan and a basic Snowball/Avalanche strategy. The simulation should accurately calculate monthly principal and interest payments