Create a full-stack web application using Next.js App Router, TypeScript, Drizzle ORM with PostgreSQL, and Tailwind CSS. The application will be a 'Birth Bill Tracker' designed to help users manage and understand their medical bills related to childbirth, especially when dealing with insurance.
**Project Structure:**
Use the `app/` directory for routing. Create separate folders for authentication, dashboard, bill management, insurance details, resources, and user profile.
**Key Features & Functionality:**
1. **User Authentication:** Secure signup/login using NextAuth.js with email/password and Google OAuth. Implement password reset functionality.
2. **User Profile Management:** Allow users to manage their personal information, primary insurance provider details (name, policy number, contact info), and emergency contact.
3. **Insurance Details Module:**
* Users can input detailed information about their insurance plan: deductible amount, out-of-pocket maximum, co-insurance percentage, specific coverage details for maternity/newborn care, and in-network provider list.
* CRUD operations for insurance plan entries.
4. **Bill Management Module:**
* Users can add new medical bills. Each bill entry should include:
* Provider name (hospital, doctor, anesthesiologist, etc.)
* Date of service
* Service description (e.g., 'Vaginal Delivery', 'Hospital Stay - 2 nights', 'Newborn Care')
* Billed amount
* Insurance claim status (submitted, processed, denied, pending)
* Amount covered by insurance
* Patient responsibility amount (after insurance)
* Date of bill received
* Option to upload bill PDF/image.
* Full CRUD operations for bill entries.
5. **Cost Analysis & Estimation:**
* Based on user's insurance details and entered bills, calculate:
* Total billed amount for childbirth.
* Total amount paid by insurance.
* Total out-of-pocket cost incurred by the user so far.
* Remaining deductible and out-of-pocket maximum.
* Estimated final cost based on policy limits.
* Provide a visual dashboard summarizing these costs.
6. **Negotiation & Resources Section:**
* A read-only section with curated resources: articles, guides, and templates on negotiating medical bills, understanding Explanation of Benefits (EOBs), and common healthcare billing practices in the US.
* (MVP Scope) Basic guidance text. Future iterations can include AI-powered negotiation suggestions.
7. **Dashboard:** A central landing page after login displaying a summary of the user's financial situation regarding their childbirth costs: total billed, total paid by insurance, user's out-of-pocket expenses, and progress towards out-of-pocket maximum.
8. **Database Schema (Drizzle ORM):**
* `users` table: id, name, email, password (hashed), oAuth_provider, oAuth_id, created_at, updated_at
* `insurance_plans` table: id, user_id, provider_name, policy_number, deductible, out_of_pocket_max, co_insurance_percentage, created_at, updated_at
* `medical_bills` table: id, user_id, provider_name, service_description, billed_amount, insurance_paid_amount, patient_responsibility, claim_status, date_of_service, date_billed, created_at, updated_at
* (Optional) `bill_documents` table for storing file metadata if files are stored externally (e.g., S3).
**API Routes:**
* Implement API routes (within `app/api/`) for all CRUD operations (e.g., `/api/bills`, `/api/insurance`, `/api/users`). Ensure proper request handling, validation, and database interactions.
* Example: `POST /api/bills` to create a new bill, `GET /api/bills` to retrieve all bills for the logged-in user, `PUT /api/bills/[id]` to update a bill, `DELETE /api/bills/[id]` to delete a bill.
**UI/UX:**
* Use Tailwind CSS for styling, ensuring a clean, responsive, and user-friendly interface.
* Implement client-side and server-side form validation.
* Use React Server Components (RSC) and Client Components appropriately for performance.
**Deployment:** Prepare for deployment on platforms like Vercel.
**Security:** Implement security best practices, including input sanitization, protection against CSRF and XSS attacks, and secure handling of sensitive financial and personal data.