You are an expert full-stack developer. Your task is to develop a comprehensive MVP (Minimum Viable Product) for a productivity application called 'Focus Start'. The application aims to help users define and execute their first concrete task of the day, guiding them away from distractions and into a productive mindset.
The application must be built using **Next.js 14 with the App Router** for both frontend and backend (API routes). For the database, use **Drizzle ORM** with a **PostgreSQL** schema (you can use SQLite for local development if easier, but the schema should be PostgreSQL compatible). Implement full **CRUD (Create, Read, Update, Delete)** operations for all core functionalities. Styling should be done with **Tailwind CSS**.
Here are the detailed requirements:
**1. Project Setup:**
- Initialize a new Next.js project with App Router.
- Configure Drizzle ORM to connect to a PostgreSQL database.
- Set up Tailwind CSS.
**2. Authentication System:**
- Implement a basic user authentication system (e.g., using `next-auth` or a custom email/password system).
- Pages: `/login`, `/register`, `/logout`.
- Protect authenticated routes (e.g., `/dashboard`, `/tasks`, `/settings`, `/history`).
**3. Database Schema (Drizzle ORM):**
- **`users` table:**
- `id`: Primary key, UUID.
- `email`: String, unique, required.
- `password_hash`: String, required.
- `created_at`: Timestamp, default now.
- `updated_at`: Timestamp, default now, on update now.
- **`focus_tasks` table:**
- `id`: Primary key, UUID.
- `user_id`: Foreign key referencing `users.id`, required.
- `title`: String, required (e.g., "Write report intro").
- `description`: Text, optional.
- `scheduled_date`: Date, required (for which day this task is planned).
- `status`: Enum ('pending', 'active', 'completed', 'skipped'), default 'pending'.
- `actual_start_time`: Timestamp, optional (when user started the timer).
- `actual_end_time`: Timestamp, optional (when user stopped the timer).
- `duration_minutes`: Integer, optional (calculated from start/end or manually entered).
- `created_at`: Timestamp, default now.
- `updated_at`: Timestamp, default now, on update now.
- **`distraction_settings` table:**
- `id`: Primary key, UUID.
- `user_id`: Foreign key referencing `users.id`, required.
- `type`: Enum ('website', 'application'), required.
- `value`: String, required (e.g., "twitter.com", "Slack").
- `active`: Boolean, default true.
- `created_at`: Timestamp, default now.
- `updated_at`: Timestamp, default now, on update now.
- **`daily_reflections` table:**
- `id`: Primary key, UUID.
- `user_id`: Foreign key referencing `users.id`, required.
- `date`: Date, unique per user, required.
- `notes`: Text, optional.
- `productivity_score`: Integer (1-5), optional.
- `created_at`: Timestamp, default now.
- `updated_at`: Timestamp, default now, on update now.
**4. Pages and Functionality (Multi-page structure):**
- **`/dashboard` (Authenticated Page):**
- Display the user's "Focus Task" for the current day.
- A large, prominent timer component (start, pause, reset functionality).
- Buttons to mark the task as 'completed' or 'skipped'.
- A simple prompt to create a task if none exists for the day.
- Display a quick overview of recent focus streaks or progress.
- **`/tasks` (Authenticated Page):**
- List all focus tasks (upcoming and past).
- **CRUD for Focus Tasks:**
- **Create:** Form to add a new focus task with title, description, and scheduled date.
- **Read:** Display tasks in a paginated or filtered list.
- **Update:** Edit task details, change status, update actual start/end times.
- **Delete:** Remove a task.
- **`/settings` (Authenticated Page):**
- User profile settings (email, password change).
- **Distraction Settings Management:**
- **CRUD for `distraction_settings`:**
- **Create:** Form to add a new website URL or application name to the distraction list.
- **Read:** List all defined distractions.
- **Update:** Toggle `active` status for a distraction, edit its value.
- **Delete:** Remove a distraction from the list.
- Note: Actual OS-level or browser-level blocking is outside the scope of this web MVP prompt. The UI will manage a *list of things to block*, and the timer will visually indicate a "focus mode" where these are theoretically blocked.
- **`/history` (Authenticated Page):**
- Display a calendar or list view of past days.
- For each day, show the completed/skipped focus task and the associated `daily_reflection`.
- Allow viewing/editing of `daily_reflection` for past days.
- Basic analytics: total focus time, number of tasks completed, streaks.
**5. API Routes (`app/api`):**
- **`/api/auth`:**
- `POST /api/auth/register`: User registration.
- `POST /api/auth/login`: User login.
- `GET /api/auth/me`: Get current user info.
- **`/api/tasks`:**
- `GET /api/tasks`: Get all tasks for the authenticated user, possibly with `date` filter.
- `POST /api/tasks`: Create a new focus task.
- `PUT /api/tasks/[id]`: Update a specific task (status, details, times).
- `DELETE /api/tasks/[id]`: Delete a specific task.
- **`/api/settings/distractions`:**
- `GET /api/settings/distractions`: Get all distraction settings for the user.
- `POST /api/settings/distractions`: Add a new distraction.
- `PUT /api/settings/distractions/[id]`: Update a distraction (e.g., toggle active).
- `DELETE /api/settings/distractions/[id]`: Delete a distraction.
- **`/api/reflections`:**
- `GET /api/reflections`: Get daily reflections for the user, possibly with `date` filter.
- `POST /api/reflections`: Create/update a daily reflection for a specific