Build a comprehensive Minimum Viable Product (MVP) for a personal finance application called 'Subscription Tracker'. The application's core purpose is to help users manage their subscriptions, prevent unwanted charges, and navigate disputes with service providers, especially after cancellation. The technology stack should be Next.js App Router (using the 'app/' directory), Drizzle ORM with PostgreSQL as the database, and Tailwind CSS for styling.
The application must feature a multi-page structure and implement full CRUD (Create, Read, Update, Delete) operations for all core data entities.
**Database Schema (Drizzle ORM):**
1. **`users` table:**
* `id` (UUID, primary key)
* `email` (VARCHAR, unique, not null)
* `password` (VARCHAR, not null)
* `createdAt` (TIMESTAMP, default NOW())
* `updatedAt` (TIMESTAMP, default NOW())
2. **`subscriptions` table:**
* `id` (UUID, primary key)
* `userId` (UUID, foreign key to `users.id`, not null)
* `serviceName` (VARCHAR, not null)
* `providerName` (VARCHAR)
* `startDate` (DATE, not null)
* `billingCycle` (ENUM: 'monthly', 'annually', 'one-time', 'other')
* `amount` (DECIMAL(10, 2), not null)
* `currency` (VARCHAR(3), default 'USD')
* `cancellationPolicy` (TEXT)
* `notes` (TEXT)
* `isActive` (BOOLEAN, default true)
* `cancellationDate` (DATE)
* `createdAt` (TIMESTAMP, default NOW())
* `updatedAt` (TIMESTAMP, default NOW())
3. **`cancellation_requests` table:**
* `id` (UUID, primary key)
* `subscriptionId` (UUID, foreign key to `subscriptions.id`, not null)
* `requestDate` (DATE, not null)
* `status` (ENUM: 'pending', 'sent', 'confirmed', 'failed', 'disputed')
* `proofOfCancellation` (TEXT, e.g., URL to uploaded file)
* `notes` (TEXT)
* `createdAt` (TIMESTAMP, default NOW())
* `updatedAt` (TIMESTAMP, default NOW())
4. **`dispute_records` table:**
* `id` (UUID, primary key)
* `subscriptionId` (UUID, foreign key to `subscriptions.id`, not null)
* `collectionAgencyName` (VARCHAR)
* `debtAmount` (DECIMAL(10, 2))
* `dateNotified` (DATE)
* `disputeDate` (DATE)
* `evidence` (TEXT, e.g., URL to uploaded files like emails, certified mail receipts)
* `status` (ENUM: 'open', 'resolved', 'closed')
* `notes` (TEXT)
* `createdAt` (TIMESTAMP, default NOW())
* `updatedAt` (TIMESTAMP, default NOW())
**Frontend (Next.js App Router):**
* **Authentication:** User registration, login, and logout. Implement JWT-based authentication.
* **Dashboard (`/dashboard`):** An overview of active subscriptions, upcoming bills, and recent activity.
* **Subscriptions Page (`/dashboard/subscriptions`):**
* List all subscriptions with filtering and sorting options.
* Add New Subscription form.
* View Subscription Details (modal or separate page).
* Edit/Delete Subscription functionality.
* **Subscription Detail Page (`/dashboard/subscriptions/[id]`):**
* Detailed view of a single subscription.
* Section to manage cancellation requests.
* Ability to add new cancellation requests, view their status, and upload proof.
* **Disputes Page (`/dashboard/disputes`):**
* List all active and resolved dispute records.
* Add New Dispute Record form.
* Upload evidence for disputes.
* View dispute details and history.
* **Settings Page (`/dashboard/settings`):** User profile management.
* **Public Pages:** Landing page (`/`), About (`/about`), Contact (`/contact`).
**Backend (API Routes):**
* Implement API routes within the `app/api/` directory for all CRUD operations.
* **Authentication Routes:** `/api/auth/register`, `/api/auth/login`, `/api/auth/logout`.
* **Subscription Routes:** `/api/subscriptions` (GET, POST), `/api/subscriptions/[id]` (GET, PUT, DELETE).
* **Cancellation Request Routes:** `/api/subscriptions/[id]/cancellations` (GET, POST), `/api/cancellations/[cancellationId]` (PUT).
* **Dispute Routes:** `/api/disputes` (GET, POST), `/api/disputes/[disputeId]` (GET, PUT).
* Ensure all API routes are protected and require user authentication, except for public pages and auth routes.
* Implement proper error handling and validation for all API requests.
**Key Functionalities & Business Logic:**
1. **Subscription Management:** Allow users to add, view, edit, and delete their subscription details.
2. **Cancellation Tracking:** Users can initiate and track the status of their cancellation requests. They must be able to upload proof (e.g., screenshots of confirmation emails, certified mail receipts).
3. **Dispute Handling:** Users can log details of disputes, including the collection agency, debt amount, and dates. They can upload evidence to support their case.
4. **Data Validation:** Implement robust validation on both frontend and backend to ensure data integrity.
5. **Security:** Secure API routes, protect user data, and use secure password hashing.
**Implementation Notes:**
* Use Drizzle ORM for database interactions, providing type safety.
* Integrate Tailwind CSS for responsive and modern UI design.
* Implement client-side and server-side data fetching strategies as appropriate using Next.js App Router features.
* Handle file uploads for evidence and proof of cancellation (consider using a cloud storage service like AWS S3 or a Vercel Blob storage integration for production, but for MVP, a local storage simulation might suffice).
* The prompt should guide the AI to generate not just the structure but also the core logic for these features, including database migrations (if applicable for Drizzle setup) and API endpoint implementations.