You are an AI assistant tasked with building a comprehensive MVP for a healthcare billing negotiation platform called 'Health Bill Buddy'. The platform should empower users to understand and negotiate their medical bills, especially those without insurance. The MVP needs to be a multi-page application built with Next.js App Router (using the 'app/' directory). It must include a robust backend with a database (using Drizzle ORM with PostgreSQL) to manage user data, medical service information, negotiation history, and financial assistance applications. Implement full CRUD operations for all major entities.
**Core Features & Functionality:**
1. **User Authentication & Management:**
* Secure user registration and login (email/password, potentially OAuth later).
* User profile management to store basic information and billing history.
2. **Medical Bill Analysis & Estimation:**
* **Service Input:** Users can input medical services received (e.g., ER visit, CT scan, medication) and the original bill amount.
* **AI-Powered Cost Estimator:** Integrate a component (initially placeholder, but designed for future AI integration) that estimates the *fair market value* or typical self-pay rates for common procedures based on anonymized data or public resources. This will help users gauge if the offered bill is reasonable.
* **Discount Calculator:** A tool to calculate the final amount based on offered percentage discounts.
3. **Negotiation Assistant:**
* **Pre-defined Negotiation Templates:** Offer templates for common negotiation scenarios (e.g., asking for a higher discount, inquiring about financial assistance).
* **Communication Log:** Users can log their calls and interactions with the hospital's billing department, including dates, times, representatives spoken to, and outcomes. This data should be stored and linked to the user's account.
* **AI Negotiation Bot (MVP placeholder):** Design the UI and data structure to eventually support an AI bot that can suggest negotiation strategies based on user input and historical data. For MVP, it can provide suggested phrases or talking points.
4. **Financial Assistance Application Tracker:**
* **Information Hub:** Provide links and guidance on how to apply for hospital financial assistance programs.
* **Status Tracker:** Allow users to manually update the status of their financial assistance applications (e.g., 'Submitted', 'Pending Review', 'Approved', 'Denied').
5. **Database Schema (Drizzle ORM for PostgreSQL):**
* `users` table: `id`, `email`, `password_hash`, `created_at`, `updated_at`.
* `medical_bills` table: `id`, `user_id` (fk to users), `hospital_name`, `bill_amount`, `service_date`, `bill_date`, `original_bill_pdf_url` (optional), `created_at`, `updated_at`.
* `bill_items` table: `id`, `bill_id` (fk to medical_bills), `description`, `hcpcs_code` (optional), `billed_amount`, `insurance_paid` (optional), `patient_paid` (optional).
* `negotiations` table: `id`, `bill_id` (fk to medical_bills), `negotiation_date`, `type` (e.g., 'discount_request', 'financial_assistance'), `hospital_representative`, `communication_log`, `offered_discount_percentage`, `final_amount_agreed`, `status`, `created_at`, `updated_at`.
* `financial_assistance_apps` table: `id`, `user_id` (fk to users), `hospital_name`, `application_date`, `status` ('Submitted', 'Pending', 'Approved', 'Denied'), `notes`, `created_at`, `updated_at`.
**Technical Stack & Implementation Details:**
* **Framework:** Next.js App Router (`app/` directory).
* **Language:** TypeScript.
* **Styling:** Tailwind CSS for rapid UI development.
* **Database:** PostgreSQL.
* **ORM:** Drizzle ORM.
* **State Management:** React Context API or Zustand for client-side state.
* **API Routes:** Utilize Next.js API routes (`app/api/`) for backend logic and database interactions. Implement robust error handling and input validation for all API endpoints.
* **Full CRUD:** Ensure that for users, medical bills, negotiation entries, and financial assistance applications, complete Create, Read, Update, and Delete operations are functional via the API routes.
* **Deployment:** Structure the project with deployment readiness in mind (e.g., environment variables, sensible defaults).
* **Future Considerations (Beyond MVP):** AI-powered negotiation, direct integration with hospital billing systems (highly complex, likely out of scope for MVP), insurance EOB parsing.
**Project Structure:**
```
app/
api/
(auth)/ # Auth routes
bills/
[billId]/
route.ts # CRUD for individual bill items
route.ts # CRUD for bills
negotiations/
[negotiationId]/
route.ts
route.ts
financial-assistance/
[appId]/
route.ts
route.ts
(routes)/ # Core app pages
dashboard/
page.tsx
bills/
new/
page.tsx
[billId]/
page.tsx
negotiate/
page.tsx
financial-assistance/
page.tsx
profile/
page.tsx
layout.tsx
page.tsx # Landing page
components/
# Reusable UI components
drizzle/
# Drizzle schema and migrations
lib/
# Utility functions, constants, db client
public/
# Static assets
styles/
# Global styles
```
Generate the full Next.js App Router project structure, including the database schema, API routes for all CRUD operations, and the necessary frontend components for the MVP features described above. Focus on creating a functional, multi-page application, not a single-page interface or a simple landing page.