You are an expert Next.js developer. Create a full-stack MVP application named 'Emergency Fund Guide' using Next.js 14 App Router, Drizzle ORM with PostgreSQL, and Tailwind CSS. The application aims to help users discover, compare, and manage safe and accessible options for emergency funds.
**Database Schema (Drizzle ORM for PostgreSQL):**
1. `users` table:
* `id` (uuid, primary key, default `gen_random_uuid()`)
* `email` (text, unique, not null)
* `passwordHash` (text, not null)
* `createdAt` (timestamp, default `now()`)
2. `fund_options` table:
* `id` (uuid, primary key, default `gen_random_uuid()`)
* `name` (text, not null)
* `type` (text, not null, e.g., 'HYSA', 'CD', 'Treasury', 'Money Market')
* `description` (text)
* `minDeposit` (numeric)
* `currentApy` (numeric, not null)
* `accessibilityDetails` (text, e.g., 'Same day withdrawal', '7-day penalty for early withdrawal')
* `providerName` (text)
* `providerUrl` (text)
* `lastUpdated` (timestamp, default `now()`)
3. `user_funds` table:
* `id` (uuid, primary key, default `gen_random_uuid()`)
* `userId` (uuid, foreign key referencing `users.id`, not null)
* `fundOptionId` (uuid, foreign key referencing `fund_options.id`, null if custom fund)
* `customFundName` (text, null, for funds not in `fund_options`)
* `currentBalance` (numeric, not null)
* `openDate` (date)
* `lastUpdated` (timestamp, default `now()`)
* `isActive` (boolean, default `true`)
**Application Structure (Next.js App Router):**
1. **Project Setup:** Initialize a Next.js 14 project with Tailwind CSS. Configure Drizzle ORM for PostgreSQL.
2. **Authentication:** Implement a basic email/password authentication system. Use `bcrypt` for password hashing. Store session in a cookie (e.g., using `iron-session` or a similar simple approach for MVP).
* `app/auth/register/page.tsx`: User registration form.
* `app/auth/login/page.tsx`: User login form.
* `app/api/auth/register/route.ts`: API endpoint for user registration.
* `app/api/auth/login/route.ts`: API endpoint for user login.
* `lib/auth.ts`: Utility for session management and authentication helpers.
3. **Pages:**
* `app/page.tsx`: Public home page with a brief introduction and calls to action (Login/Register).
* `app/(protected)/dashboard/page.tsx`: User dashboard displaying an overview of their tracked funds.
* `app/(protected)/compare/page.tsx`: Fund comparison tool.
* `app/(protected)/funds/[id]/page.tsx`: Detail page for a specific fund option.
* `app/(protected)/profile/page.tsx`: User profile/settings page.
4. **API Routes (`app/api/`):**
* `app/api/fund-options/route.ts`: (GET, POST)
* GET: Retrieve a list of all `fund_options`.
* POST: Add a new `fund_option` (placeholder for admin functionality for MVP).
* `app/api/fund-options/[id]/route.ts`: (GET, PUT, DELETE)
* GET: Retrieve a specific `fund_option` by ID.
* PUT: Update a specific `fund_option` by ID.
* DELETE: Delete a specific `fund_option` by ID.
* `app/api/user-funds/route.ts`: (GET, POST)
* GET: Retrieve all `user_funds` for the authenticated user.
* POST: Add a new `user_fund` for the authenticated user.
* `app/api/user-funds/[id]/route.ts`: (GET, PUT, DELETE)
* GET: Retrieve a specific `user_fund` by ID for the authenticated user.
* PUT: Update a specific `user_fund` by ID for the authenticated user.
* DELETE: Delete a specific `user_fund` by ID for the authenticated user.
**MVP Functionality:**
* **User Authentication:** Allow users to register and log in.
* **Fund Options Listing & Comparison:**
* On `/compare`, display all `fund_options` from the database.
* Implement basic filtering (e.g., by type) and sorting (e.g., by `currentApy`).
* Each `fund_option` should link to its detail page.
* **User Fund Tracking (CRUD):**
* On `/dashboard`, display a list of `user_funds` associated with the logged-in user.
* Provide a form/modal to "Add New Fund" where users can select an existing `fund_option` or manually enter details for a `customFundName`.
* Allow users to edit (`currentBalance`, `isActive`) or delete their tracked funds.
* **Database Seeding:** Include a `seed.ts` script to populate `fund_options` table with some sample data.
* **Environment Variables:** Ensure proper `.env` setup for `DATABASE_URL`, `AUTH_SECRET` (for session).
**Technical Details:**
* Use server components for pages where appropriate, and client components for interactive elements.
* Implement robust error handling for API routes and forms.
* Focus on a clean, responsive UI with Tailwind CSS.
* Do NOT generate only a landing page or a single-page application.