Build a full-stack application using Next.js App Router (app directory), Drizzle ORM with PostgreSQL, and Tailwind CSS. The application should allow users to track and analyze their daily energy levels, sleep quality and duration, diet (meals, content, time), activities, and mood. The goal is to help users identify patterns related to chronic fatigue. The application must have a multi-page structure and implement full CRUD (Create, Read, Update, Delete) functionality for all tracked data.
**Core Features:**
1. **User Authentication:** Implement secure user registration, login, and logout using NextAuth.js or a similar library.
2. **Dashboard (Home Page):** Display a summary of the user's current day's data (energy, sleep, mood, etc.) and key insights or tips. This page should be under `/`.
3. **Data Entry Modules:**
* **Energy Tracking:** A page (e.g., `/log/energy`) for users to log their perceived energy level on a scale (e.g., 1-10) and time of day.
* **Sleep Tracking:** A page (e.g., `/log/sleep`) for users to log bedtime, wake-up time, and perceived sleep quality.
* **Diet Tracking:** A page (e.g., `/log/diet`) for users to log meals, including meal type, food items, and time.
* **Activity Tracking:** A page (e.g., `/log/activity`) for users to log physical activities, duration, and intensity.
* **Mood Tracking:** A page (e.g., `/log/mood`) for users to log their mood and associated events.
4. **Data Visualization & Analysis:**
* A dedicated analytics page (e.g., `/analytics`) showing historical data trends via charts and graphs (e.g., daily energy vs. sleep duration, mood vs. diet). Use a charting library like Chart.js or Recharts.
* Implement a basic analysis engine that identifies simple correlations and provides actionable tips (e.g., 'Higher energy levels reported on days with X type of breakfast'). This logic should be implemented server-side.
5. **User Profile & Settings:** A page (e.g., `/profile`) for users to manage their account information and application settings.
**Technical Stack & Requirements:**
* **Framework:** Next.js (App Router - `/app` directory).
* **Database:** PostgreSQL with Drizzle ORM for type-safe database interactions. Define schemas for users, energy logs, sleep logs, diet logs, activity logs, and mood logs.
* **Styling:** Tailwind CSS for a responsive and modern UI.
* **Authentication:** NextAuth.js (or similar) for secure authentication.
* **API Routes:** Create API routes (e.g., `app/api/logs/...`) for all CRUD operations.
* **Backend Logic:** All data processing, analysis, and business logic should be handled on the server-side (API routes or Server Components).
* **Error Handling:** Implement robust error handling for API requests and user inputs.
* **Deployment:** The project should be structured for easy deployment to platforms like Vercel or Netlify.
**Database Schema (Drizzle):**
* `users` table (id, name, email, password_hash, created_at)
* `energy_logs` table (id, user_id, energy_level, log_time, created_at)
* `sleep_logs` table (id, user_id, bed_time, wake_time, sleep_quality, created_at)
* `diet_logs` table (id, user_id, meal_type, food_items, meal_time, created_at)
* `activity_logs` table (id, user_id, activity_type, duration_minutes, intensity, log_time, created_at)
* `mood_logs` table (id, user_id, mood, notes, log_time, created_at)
Ensure the code is clean, well-commented, and follows best practices for Next.js and Drizzle ORM development. The MVP should be a functional application demonstrating the core concept of tracking and analyzing personal wellness data to combat fatigue.