Develop a full-stack MVP application named 'Experiment-Driven Growth' using Next.js 14+ (App Router), TypeScript, Tailwind CSS, and Drizzle ORM. The application aims to help small and medium-sized businesses define, track, and learn from growth experiments systematically, focusing on actionable outcomes rather than just data collection.The application should include the following features and technical specifications:
**Database Schema (Drizzle ORM):**
Implement the following Drizzle schema for a PostgreSQL database. Ensure proper relationships and index definitions.
* `users`: id (PK), email (UNIQUE), passwordHash, organizationId (FK to organizations), createdAt, updatedAt.
* `organizations`: id (PK), name, ownerId (FK to users), createdAt, updatedAt.
* `experiments`: id (PK), organizationId (FK to organizations), name, description, hypothesis, primaryMetricId (FK to metrics, nullable), startDate, endDate, status (ENUM: 'Planned', 'Active', 'Completed', 'Archived'), outcome (ENUM: 'Success', 'Failure', 'Inconclusive', nullable), learningsSummary, createdAt, updatedAt.
* `metrics`: id (PK), organizationId (FK to organizations), experimentId (FK to experiments, nullable for organization-wide metrics), name, description, targetValue (number), currentValue (number), unit (e.g., 'percentage', 'count'), createdAt, updatedAt.
* `tasks`: id (PK), experimentId (FK to experiments), description, assignedToUserId (FK to users, nullable), dueDate, status (ENUM: 'Todo', 'InProgress', 'Done'), createdAt, updatedAt.
* `learnings`: id (PK), experimentId (FK to experiments), title, description, recommendation (ENUM: 'Scale', 'Iterate', 'Stop', 'Archive'), createdAt, updatedAt.
**Authentication:**
Implement a basic email/password authentication system for user registration and login. Users should be associated with an `organization` (either by creating a new one or joining an existing one via an invitation flow - simplified for MVP to create new organization on signup).
**Core Functionality (CRUD API Routes & Pages):**
1. **User Authentication:**
* `POST /api/auth/register`: Register a new user and create a new organization for them.
* `POST /api/auth/login`: Authenticate an existing user.
* `GET /api/auth/me`: Get current user details (protected route).
* Pages: `/auth/register`, `/auth/login`.
2. **Dashboard Page (`/dashboard`):**
* Display an overview for the logged-in user's organization.
* Show counts of active, planned, and completed experiments.
* List top 3 upcoming tasks across all active experiments.
* Show a quick summary or progress of the most critical active experiment.
3. **Experiments List Page (`/experiments`):**
* Display a paginated list of all experiments for the user's organization.
* Allow filtering experiments by `status` (Planned, Active, Completed, Archived).
* Display key information for each experiment: name, status, start/end dates, primary metric progress.
* Link to individual experiment detail pages.
4. **Create New Experiment Page (`/experiments/new`):**
* A form to create a new experiment with fields: `name`, `description`, `hypothesis`, `startDate`, `endDate`, initial `status` (defaults to 'Planned').
* Optionally allow defining an initial `primaryMetric` (name, targetValue, unit).
* `POST /api/experiments`: API endpoint to handle experiment creation.
5. **Experiment Detail Page (`/experiments/[id]`):**
* **Experiment Overview:** Display full details of a specific experiment including `name`, `description`, `hypothesis`, `startDate`, `endDate`, current `status`, `outcome` (if completed), and `learningsSummary`.
* **Manage Tasks:**
* List all `tasks` associated with this experiment.
* `POST /api/experiments/[id]/tasks`: Create a new task.
* `PUT /api/tasks/[taskId]`: Update an existing task (e.g., status, description, assignedToUserId, dueDate).
* `DELETE /api/tasks/[taskId]`: Delete a task.
* UI to add, edit, mark as done, and delete tasks.
* **Manage Metrics:**
* List all `metrics` associated with this experiment (including the primary metric).
* `POST /api/experiments/[id]/metrics`: Create a new metric for the experiment.
* `PUT /api/metrics/[metricId]`: Update an existing metric (e.g., `currentValue`, `targetValue`).
* `DELETE /api/metrics/[metricId]`: Delete a metric.
* UI to add, edit, and delete metrics. Display current vs. target value visually.
* **Manage Learnings:**
* List all `learnings` captured for this experiment.
* `POST /api/experiments/[id]/learnings`: Create a new learning entry.
* `PUT /api/learnings/[learningId]`: Update an existing learning.
* `DELETE /api/learnings/[learningId]`: Delete a learning.
* UI to add, edit, and delete learnings.
* **Experiment Actions:**
* `PUT /api/experiments/[id]`: Endpoint to update experiment details, `status`, or `outcome`.
* Buttons/forms to change experiment `status` (e.g., 'Activate', 'Complete', 'Archive') and set `outcome` (Success, Failure, Inconclusive).
**Technical Requirements:**
* **Framework:** Next.js 14+ with App Router for all pages and API routes.
* **Language:** TypeScript for all code.
* **Styling:** Tailwind CSS for all UI components and layout.
* **ORM:** Drizzle ORM for all database interactions. Use Drizzle's `pg-core` for PostgreSQL compatibility.
* **Validation:** Use Zod for API request payload validation on the server-side.
* **Error Handling:** Implement robust error handling for API routes and display user-friendly error messages on the client-side.
* **Code Structure:** Organize files logically within the `app/` directory (e.g., `app/dashboard`, `app/experiments`, `app/api`, `components`, `db/schema`, `lib`).
* **Data Fetching:** Utilize Next.js data fetching stra