Please act as an expert Next.js developer. Your task is to develop a fully functional MVP for 'Mind Awakener', a smart alarm application designed to force users to engage their brains to wake up. The application must leverage the latest Next.js 14 App Router, TypeScript, Tailwind CSS for styling, and Drizzle ORM with a PostgreSQL database. Implement full CRUD functionality for managing alarms and user data. Do not generate a simple landing page or a single-page application; build a multi-page application with distinct server and client components where appropriate.Database Schema (Drizzle ORM for PostgreSQL):1. `users` table: * `id`: `uuid` (primary key, default `gen_random_uuid()`) * `email`: `text` (unique, not null) * `passwordHash`: `text` (not null) * `createdAt`: `timestamp` (default `now()`) * `updatedAt`: `timestamp` (on update `now()`)2. `alarms` table: * `id`: `uuid` (primary key, default `gen_random_uuid()`) * `userId`: `uuid` (foreign key to `users.id`, not null) * `time`: `text` (e.g., "07:30", not null) * `daysOfWeek`: `text[]` (array of strings, e.g., ["MON", "WED", "FRI"], not null) * `isActive`: `boolean` (default `true`, not null) * `taskType`: `text` (e.g., "MATH", "MEMORY", "PUZZLE", not null) * `taskDifficulty`: `text` (e.g., "EASY", "MEDIUM", "HARD", not null) * `createdAt`: `timestamp` (default `now()`) * `updatedAt`: `timestamp` (on update `now()`)3. `alarmHistory` table: * `id`: `uuid` (primary key, default `gen_random_uuid()`) * `alarmId`: `uuid` (foreign key to `alarms.id`, not null) * `userId`: `uuid` (foreign key to `users.id`, not null) * `wakeUpTime`: `timestamp` (when the task was completed, not null) * `taskCompletedSuccessfully`: `boolean` (not null) * `createdAt`: `timestamp` (default `now()`)Pages and Routes (Next.js App Router):1. Authentication (`/login`, `/register`): * `app/(auth)/login/page.tsx`: Login form (client component). * `app/(auth)/register/page.tsx`: Registration form (client component). * `app/api/auth/login/route.ts`: API route for user login. * `app/api/auth/register/route.ts`: API route for user registration. * Implement secure password hashing (e.g., `bcrypt`).2. Dashboard (`/dashboard`): * `app/dashboard/page.tsx`: Displays a list of all active and inactive alarms for the authenticated user. Includes buttons to edit, delete, or toggle alarm status. (Server component fetching data, client components for interactivity).3. Alarm Management (`/alarms/new`, `/alarms/[id]/edit`): * `app/alarms/new/page.tsx`: Form to create a new alarm (client component). User selects time, days, task type (math, memory), and difficulty. * `app/alarms/[id]/edit/page.tsx`: Form to edit an existing alarm (client component). Populates with current alarm data. * `app/api/alarms/route.ts`: * `POST`: Create a new alarm for the authenticated user. * `GET`: Fetch all alarms for the authenticated user. * `app/api/alarms/[id]/route.ts`: * `GET`: Fetch a single alarm by ID. * `PUT`: Update an existing alarm by ID. * `DELETE`: Delete an alarm by ID.4. Wake-up Task (`/wakeup/[id]`): * `app/wakeup/[id]/page.tsx`: This is the core "alarm" page. * When an alarm is triggered (simulated for MVP, e.g., by directly navigating to this URL), this page loads. * It fetches the alarm details using the `id` from the URL params. * Displays a dynamic mental task based on `taskType` and `taskDifficulty` (e.g., a math problem, a simple memory game, or a word unscramble). * Crucial: The alarm sound starts playing and CANNOT be stopped until the user correctly completes the task. * Upon successful task completion: * Stops the alarm sound. * Records `taskCompletedSuccessfully: true` in `alarmHistory`. * Implements a "re-sleep prevention" mechanism (e.g., a 5-minute lockout timer on the phone, or a prompt for a secondary, very simple task to ensure alertness). For MVP, a simple success message and a "Go to Dashboard" button will suffice, ensuring the alarm doesn't re-trigger immediately. * If the user fails or tries to exit without completing, the alarm continues. * `app/api/alarm-history/route.ts`: * `POST`: Record an alarm event (e.g., when a task is completed).5. Statistics (`/stats`): * `app/stats/page.tsx`: Displays simple user statistics (e.g., number of successful wake-ups, completion rate for tasks, average time to complete tasks). (Server component fetching data). * `app/api/stats/route.ts`: * `GET`: Fetch statistics for the authenticated user based on `alarmHistory`.Additional Requirements: * User Interface: Use Tailwind CSS for a modern, responsive design. * Authentication State: Implement a basic session management (e.g., using `next/headers` for server components and Context API or `zustand` for client components, or simple `localStorage` with tokens). * Error Handling: Implement basic error handling and loading states for API calls. * Environment Variables: Use `.env.local` for sensitive data like database connection strings. * File Structure: Adhere to the Next.js App Router structure (`app/`, `components/`, `lib/db.ts`, `drizzle/schema.ts`, etc.). * Task Logic: Provide examples for at least two `taskType` implementations within the `/wakeup/[id]` page (e.g., simple arithmetic for MATH, matching pairs for MEMORY). Ensure the logic to check task completion is robust. * Client-Side Alarm Triggering (MVP Simplification): For MVP, assume the user manually navigates to `/wakeup/[id]` to test the alarm. A real-world app would need native mobile features or a background process, which is out of scope for a web MVP coded by AI. Focus on the web functionality once the `wakeup` page is loaded.The AI should generate all ne