Build a comprehensive Next.js 14 application using the App Router (`app/` directory) that acts as a robust retirement fund tracker. The application should allow users to securely link their financial accounts (simulated for MVP) from various providers like ADP and Fidelity, view all their retirement funds (401k, IRA, etc.) in a unified dashboard, and receive proactive notifications for significant account changes such as transfers or conversions. Implement full CRUD functionality for user accounts and linked accounts. Utilize Drizzle ORM with PostgreSQL for the database schema. Ensure secure authentication using NextAuth.js. Design a multi-page structure with distinct routes for dashboard, account linking, transaction history, and settings. Create API routes for all data operations, ensuring secure handling of sensitive information (use placeholders for actual sensitive data in MVP). The user interface should be clean, intuitive, and responsive, built with React Server Components and Client Components where appropriate. Key features for the MVP include:
1. **User Authentication:** Secure sign-up, login, and logout using NextAuth.js with email/password and potentially OAuth (e.g., Google).
2. **Account Linking (Simulated):** A secure interface where users can input details for their financial institutions (e.g., ADP, Fidelity). For the MVP, simulate successful linking and data retrieval without actual API integrations. Store linked account types, provider names, and basic metadata.
3. **Unified Dashboard:** A main page displaying a summary of all linked retirement accounts, current balances, and recent activity. Use React Server Components for fetching and displaying this aggregated data.
4. **Transaction History:** A dedicated page to view detailed transaction history for each linked account. Implement filtering and sorting options.
5. **Proactive Notifications (Simulated):** A backend mechanism (can be a scheduled job or triggered via API calls) to simulate detection of 'unusual' activities like fund conversions or transfers. Users should receive in-app notifications and simulated email alerts.
6. **Database Schema (Drizzle ORM with PostgreSQL):**
* `users` table: id, name, email, password_hash, createdAt, updatedAt
* `linked_accounts` table: id, user_id, provider_name (e.g., 'ADP', 'Fidelity'), account_type (e.g., '401k', 'IRA'), account_number_masked, balance, currency, createdAt, updatedAt
* `transactions` table: id, linked_account_id, transaction_date, description, amount, type ('deposit', 'withdrawal', 'transfer', 'conversion'), createdAt, updatedAt
* `notifications` table: id, user_id, message, type (e.g., 'account_change', 'fund_alert'), read, createdAt, updatedAt
7. **API Routes (App Router):** Implement API routes under `app/api/` for:
* `auth/*`: Handled by NextAuth.js.
* `/api/accounts`: CRUD operations for linked accounts.
* `/api/accounts/:id/transactions`: Fetch transactions for a specific account.
* `/api/notifications`: Fetch user notifications.
* `/api/simulate-notification`: An endpoint to manually trigger a simulated notification for testing.
8. **UI Components:** Develop reusable UI components for forms, tables, charts (using a library like Chart.js or Recharts), and notification alerts. Ensure the UI is professional and trustworthy.