You are an expert backend developer tasked with creating a full-stack Minimum Viable Product (MVP) for a personal finance application called 'Bill Watcher' (Fatura Gözcü). This application aims to help users monitor their bills, receive alerts for unexpected charges, and prevent overspending, particularly focusing on high-cost international calls.
The MVP should be built using Next.js 14 with the App Router (using the `app/` directory), TypeScript, and a PostgreSQL database managed with Drizzle ORM.
**Core Features to Implement:**
1. **User Authentication:** Secure user signup and login using NextAuth.js.
2. **Bill Management (CRUD):** Users should be able to add, view, update, and delete their bills. Each bill should have fields like `id`, `userId`, `provider` (e.g., 'Telecom', 'Internet'), `amount`, `dueDate`, `billingPeriodStart`, `billingPeriodEnd`, `type` (e.g., 'Monthly', 'One-Time'), `createdAt`, and `updatedAt`.
3. **Transaction/Usage Tracking (CRUD):** Users should be able to log individual transactions or usage details associated with a bill. Fields should include `id`, `billId`, `description`, `amount`, `transactionDate`, `isInternational` (boolean), `country` (if international), `callDurationMinutes` (if applicable), `createdAt`, and `updatedAt`.
4. **Alerting System:**
* **High Charge Alert:** Trigger an alert if a newly added bill or a significant transaction exceeds a user-defined threshold or a dynamically calculated average.
* **International Call Alert:** Trigger an alert if a transaction is flagged as international, especially if it exceeds a certain duration or cost threshold.
* **Due Date Reminder:** Send reminders for upcoming bill due dates.
5. **Dashboard:** A landing page (`/dashboard`) that provides an overview of upcoming bills, recent spending, and active alerts.
6. **Database Schema (Drizzle ORM):** Define the database schema using Drizzle ORM for PostgreSQL.
* `users` table (managed by NextAuth.js, but needs schema definition).
* `bills` table.
* `transactions` table.
7. **API Routes:** Implement robust API routes (within `app/api/` or using Route Handlers in `app/` directory) for all CRUD operations and for triggering/fetching alerts.
8. **Multi-Page Structure:** Implement at least the following pages:
* `/` (Public Landing Page)
* `/auth/signin` (Sign in page)
* `/auth/signup` (Sign up page)
* `/dashboard` (User's main dashboard)
* `/bills` (List all bills)
* `/bills/new` (Add a new bill)
* `/bills/[id]` (View/Edit a specific bill)
* `/transactions/new` (Add a new transaction, likely linked to a bill)
* `/alerts` (View active alerts)
**Technical Stack & Requirements:**
* **Framework:** Next.js 14 (App Router)
* **Language:** TypeScript
* **Database:** PostgreSQL
* **ORM:** Drizzle ORM
* **Authentication:** NextAuth.js
* **Styling:** Tailwind CSS (for rapid UI development)
* **State Management:** React Context API or Zustand for client-side state.
**Prompt Guidelines:**
* Organize the project structure logically within the `app/` directory.
* Implement full CRUD functionality for `bills` and `transactions`.
* Ensure API routes are well-defined and handle request methods correctly (GET, POST, PUT, DELETE).
* Implement the alerting logic. For MVP, this can be triggered on data creation/update, simulating background jobs. Real-time background job processing is out of scope for the MVP code generation but the logic should be present.
* The database schema should be clearly defined using Drizzle's syntax.
* Include basic UI components for each page using Tailwind CSS.
* Do not create a single-page application. Ensure proper page navigation using Next.js `Link` component.
* The generated code should be production-ready for an MVP, including error handling and basic form validation.
* Focus on the backend logic, database interactions, and API endpoints. UI can be functional but doesn't need to be pixel-perfect.
* Ensure all necessary dependencies are listed for installation.