You are an expert full-stack developer tasked with building a Minimum Viable Product (MVP) for a task management application called 'Clear Task' (Net Görev). The core problem this application solves is the lack of clarity in user tasks, leading to procrastination. The MVP should not be a simple landing page or a single-page application. It must implement a multi-page structure using Next.js App Router (using the `app/` directory), a robust backend with a database, and full CRUD (Create, Read, Update, Delete) functionality for all core entities.
**Project Structure:**
- Use Next.js App Router (`app/` directory).
- Organize routes logically (e.g., `app/(auth)/login/page.tsx`, `app/(app)/dashboard/page.tsx`, `app/(app)/tasks/page.tsx`, `app/(app)/tasks/[id]/page.tsx`).
- Implement protected routes that require user authentication.
**Database Schema (using Drizzle ORM with PostgreSQL):**
Define the following tables:
1. **users:**
- `id` (UUID, Primary Key)
- `email` (VARCHAR, Unique, Not Null)
- `passwordHash` (VARCHAR, Not Null)
- `createdAt` (TIMESTAMP, Default NOW())
- `updatedAt` (TIMESTAMP, Default NOW())
2. **tasks:**
- `id` (UUID, Primary Key)
- `userId` (UUID, Foreign Key to users.id, Not Null)
- `title` (VARCHAR, Not Null)
- `description` (TEXT)
- `parentTaskId` (UUID, Foreign Key to tasks.id, Nullable) - For sub-tasks.
- `isClear` (BOOLEAN, Default: false) - Indicates if the task has been broken down into clear steps.
- `status` (VARCHAR, Default: 'todo') - e.g., 'todo', 'in_progress', 'done'
- `createdAt` (TIMESTAMP, Default NOW())
- `updatedAt` (TIMESTAMP, Default NOW())
3. **clearSteps:**
- `id` (UUID, Primary Key)
- `taskId` (UUID, Foreign Key to tasks.id, Not Null)
- `description` (VARCHAR, Not Null) - The specific, actionable step.
- `order` (INTEGER, Not Null) - Order of the step within a task.
- `isCompleted` (BOOLEAN, Default: false)
- `createdAt` (TIMESTAMP, Default NOW())
- `updatedAt` (TIMESTAMP, Default NOW())
**Backend Implementation:**
- **API Routes:** Create API routes within `app/api/` for all CRUD operations for `tasks` and `clearSteps`.
- Example: `app/api/tasks/route.ts` (POST for create, GET for read all tasks for user).
- Example: `app/api/tasks/[id]/route.ts` (GET for single task, PUT for update, DELETE for delete).
- Example: `app/api/tasks/[id]/clear/route.ts` (POST to trigger AI breakdown, GET to fetch clear steps).
- **Authentication:** Implement user registration, login, and session management (e.g., using NextAuth.js or custom JWT implementation).
- **AI Integration:** For the task breakdown feature (`POST /api/tasks/[id]/clear`):
- When a user requests to 'clarify' a task, send the `tasks.title` and `tasks.description` to a simulated AI service (for MVP, you can hardcode sample responses or use a placeholder function).
- The AI should return an array of `clearSteps` descriptions.
- Store these `clearSteps` in the `clearSteps` table, linked to the `taskId`, and set `tasks.isClear` to `true`.
- **Drizzle ORM:** Use Drizzle ORM for all database interactions. Configure it for PostgreSQL.
**Frontend Implementation:**
- **Pages:** Create distinct pages for:
- Authentication (Login, Register)
- Dashboard (Overview, possibly a summary of tasks)
- Task List (`/tasks`): Display all tasks for the logged-in user. Allow filtering/sorting.
- Task Detail (`/tasks/[id]`): Show task details, description, and associated `clearSteps`. Include a button to trigger the AI clarification if `isClear` is false.
- **UI Components:** Develop reusable UI components for forms, task cards, buttons, etc.
- **State Management:** Use React Server Components and Client Components appropriately. Consider using a client-side state management library if needed for complex interactions.
- **User Experience:** Focus on a clean and intuitive user interface. Ensure smooth transitions between pages and clear feedback on user actions.
**Core Functionality to Implement:**
1. User Registration & Login.
2. Create a new task with a title and optional description.
3. View a list of all created tasks.
4. View a single task's details.
5. Update an existing task (title, description, status).
6. Delete a task.
7. Trigger the AI 'clarify' function for a task.
8. View the generated `clearSteps` for a clarified task.
9. Mark individual `clearSteps` as completed.
10. Update the `status` of the main `task` based on `clearSteps` completion (e.g., if all steps are done, mark task as 'done').
**Deliverables:**
Provide a full Next.js project setup with the described database schema, API routes, authentication, and frontend pages. The AI clarification feature should be implemented with placeholder logic if actual API integration is not feasible for the MVP prompt context, but the API endpoint and data flow must be present.