You are an expert full-stack developer tasked with building a Minimum Viable Product (MVP) for a web application called 'Mind Diverter'. This application is designed for busy professionals who need a mental break by working on unrelated, creative projects. The MVP should be a robust, multi-page application built with Next.js 14 using the App Router (`app/` directory). It must include a PostgreSQL database managed by Drizzle ORM, with API routes for full CRUD operations on projects and tasks.
**Core Requirements:**
1. **Next.js 14 App Router:** Structure the application using the `app/` directory. Implement a multi-page layout with clear navigation.
2. **Database:** Use PostgreSQL as the database. Integrate Drizzle ORM for schema definition and database interactions.
3. **Drizzle Schema:** Define the following Drizzle schemas:
* `users`: `id` (serial, primary key), `email` (varchar, unique), `name` (varchar).
* `projects`: `id` (serial, primary key), `userId` (integer, foreign key to users.id), `title` (varchar), `description` (text), `templateType` (varchar), `createdAt` (timestamp), `updatedAt` (timestamp).
* `tasks`: `id` (serial, primary key), `projectId` (integer, foreign key to projects.id), `title` (varchar), `description` (text), `status` (varchar, e.g., 'TODO', 'IN_PROGRESS', 'DONE'), `priority` (varchar, e.g., 'LOW', 'MEDIUM', 'HIGH'), `dueDate` (timestamp), `createdAt` (timestamp), `updatedAt` (timestamp).
4. **API Routes (Route Handlers):** Create API routes within the `app/api/` directory for full CRUD operations for `projects` and `tasks`.
* `/api/projects`: GET (list all projects for the authenticated user), POST (create a new project).
* `/api/projects/[id]`: GET (get a specific project), PUT (update a project), DELETE (delete a project).
* `/api/tasks`: GET (list all tasks for a specific project), POST (create a new task for a project).
* `/api/tasks/[id]`: GET (get a specific task), PUT (update a task), DELETE (delete a task).
5. **Frontend Components:** Develop React components using Server Components and Client Components appropriately.
* **Authentication:** Implement a basic authentication flow (e.g., using Clerk or a simple email/password system with NextAuth.js, although for MVP, assume user context is available). For MVP, focus on user association with projects/tasks. Assume a logged-in user context for now.
* **Dashboard/Projects Page (`/app/dashboard/projects`):** Display a list of the user's projects. Allow creation of new projects (linking to a project creation form/modal).
* **Project Detail Page (`/app/projects/[projectId]`):** Display project details and a list of tasks associated with that project. Allow adding, editing, and deleting tasks.
* **Task Management:** Implement UI for creating, viewing, updating (status, priority, due date), and deleting tasks within a project.
* **Project Templates:** Include a selection of predefined project templates (e.g., 'Game Idea', 'Art Project', 'Writing Prompt') that pre-populate project descriptions or suggest initial tasks.
* **Focus Mode/Timer:** Integrate a simple timer component (e.g., Pomodoro) that can be activated while working on a task.
* **Gallery Page (`/app/dashboard/gallery`):** A page to showcase completed projects (initially just a list, can be enhanced later).
6. **Error Handling:** Implement basic error handling for API calls and form submissions.
7. **Styling:** Use a modern UI library like Tailwind CSS with Shadcn/ui for components.
**Structure:**
* `app/` directory for all routes.
* `components/` for reusable UI components.
* `lib/` for database connection, Drizzle schema, and utility functions.
* `api/` for Route Handlers.
**Deliverables:**
Provide the complete Next.js project structure with all the above-mentioned features implemented. Ensure that the database schema, API routes, and frontend components work cohesively to provide a functional MVP for Mind Diverter.