Create a full-stack Next.js application with an App Router structure that helps users manage their earned breaks after completing tasks. The application should enforce CRUD operations for tasks and breaks, feature a multi-page structure, and use Drizzle ORM with a PostgreSQL database. Implement robust API routes for all data management.
**Project Structure:**
- Use the `app/` directory for routing.
- Create distinct pages for:
- Dashboard (Overview of tasks, earned break points, upcoming breaks)
- Task Management (CRUD for tasks)
- Break Management (CRUD for planned breaks, start/stop functionality)
- Statistics (Weekly/Monthly insights)
- Settings (User preferences, platform integrations)
**Backend (API Routes & Database):**
- **Database:** PostgreSQL with Drizzle ORM.
- **Schema:**
- `users` table: `id`, `email`, `password` (hashed), `createdAt`, `updatedAt`.
- `tasks` table: `id`, `userId`, `description`, `completed` (boolean), `pointsEarned` (integer), `createdAt`, `updatedAt`.
- `breaks` table: `id`, `userId`, `description`, `plannedStartTime`, `plannedEndTime`, `actualStartTime` (nullable), `actualEndTime` (nullable), `status` ('scheduled', 'in_progress', 'completed', 'cancelled'), `createdAt`, `updatedAt`.
- **API Routes:** Implement `app/api/` routes for:
- User authentication (signup, login, logout).
- Task CRUD: `POST /api/tasks`, `GET /api/tasks`, `GET /api/tasks/:id`, `PUT /api/tasks/:id`, `DELETE /api/tasks/:id`.
- Break CRUD: `POST /api/breaks`, `GET /api/breaks`, `GET /api/breaks/:id`, `PUT /api/breaks/:id`, `DELETE /api/breaks/:id`.
- Break control: `POST /api/breaks/:id/start`, `POST /api/breaks/:id/stop`.
- Statistics: `GET /api/stats/weekly`, `GET /api/stats/monthly`.
- **Logic:** Ensure all API routes correctly interact with the database, performing full CRUD operations. Implement user authentication and authorization for all routes.
**Frontend (Next.js App Router):**
- **Pages:** Develop the UI for each page listed above.
- **Components:** Create reusable React components for task items, break timers, statistics charts, forms, etc.
- **State Management:** Use React's Context API or a lightweight state management library if needed.
- **User Experience:** Focus on a clean, intuitive UI. Implement real-time updates where necessary (e.g., break timer countdown).
- **Break Timer:** Implement a functional timer for breaks that counts down from the `plannedEndTime` and allows users to start and stop it via API calls.
- **Points System:** Ensure tasks, when marked as completed, correctly award points. These points should be visible on the dashboard and factored into break planning logic (if applicable in MVP scope).
**Key Functionality to Implement:**
1. **Task Creation and Tracking:** Users can add tasks with descriptions and assign potential points upon completion. They can mark tasks as complete.
2. **Break Scheduling:** Users can schedule breaks, defining planned start and end times. The system should calculate the duration.
3. **Break Execution:** Users can start a scheduled break. A countdown timer should be displayed. When the time is up, or the user manually stops the break, it should be marked as completed.
4. **Point System:** Earned points from completed tasks should be aggregated and displayed.
5. **Basic Statistics:** Show weekly and monthly summaries of completed tasks and utilized break time.
6. **User Authentication:** Secure signup, login, and logout functionality.