You are tasked with building a full-stack Minimum Viable Product (MVP) for 'Partnership Ledger', a SaaS application designed to manage co-founder agreements and track contributions in startups. The application should use Next.js 14 with the App Router, React, TypeScript, Tailwind CSS for styling, Drizzle ORM with PostgreSQL for the database, and NextAuth.js for authentication.
**Core Requirements & Features:**
1. **Database Schema (Drizzle ORM):**
* `users`: id, name, email, hashedPassword, createdAt, updatedAt
* `startups`: id, name, description, ownerId (FK to users.id), createdAt, updatedAt
* `co_founders`: id, userId (FK to users.id), startupId (FK to startups.id), role, equityPercentage, status, createdAt, updatedAt
* `contributions`: id, coFounderId (FK to co_founders.id), type (ENUM: 'code', 'design', 'finance', 'idea', 'marketing', 'legal', 'other'), description, valueEstimate (numeric, optional), date, createdAt, updatedAt
* `agreements`: id, startupId (FK to startups.id), title, content (JSONB/TEXT for document content), status (ENUM: 'draft', 'signed', 'revised'), createdAt, updatedAt
* `agreement_signatures`: id, agreementId (FK to agreements.id), coFounderId (FK to co_founders.id), signedAt, createdAt, updatedAt
* `tasks`: id, startupId (FK to startups.id), assignedToCoFounderId (FK to co_founders.id), title, description, status (ENUM: 'todo', 'in-progress', 'completed'), dueDate (optional), createdAt, updatedAt
* `communication_logs`: id, startupId (FK to startups.id), senderId (FK to users.id), message, type (ENUM: 'meeting_note', 'decision', 'discussion'), createdAt, updatedAt
2. **Next.js App Router Structure:**
* Public Routes: `/`, `/auth/signin`, `/auth/signup`
* Protected Routes (authenticated users only):
* `/dashboard`: User's main dashboard, listing their owned/associated startups.
* `/startups/create`: Form to create a new startup entry.
* `/startups/[id]`: Dynamic page to view a specific startup's details, including its co-founders, their contributions, agreements, tasks, and communication logs. This page should serve as the main hub for a startup.
* `/startups/[id]/co-founders/add`: Form to add a new co-founder to the current startup.
* `/startups/[id]/contributions/add`: Form to log a new contribution for a specific co-founder within the current startup.
* `/startups/[id]/agreements/create`: Form to create or edit an agreement for the current startup.
* `/startups/[id]/tasks/create`: Form to create and assign a new task to a co-founder within the current startup.
* `/profile`: User profile management (name, email update).
3. **API Routes (`app/api`):**
* Implement full CRUD (Create, Read, Update, Delete) API endpoints for:
* `startups`
* `co_founders` (including association with users and startups)
* `contributions`
* `agreements` (including signing mechanism)
* `tasks`
* `communication_logs`
* All API routes must be protected, ensuring that only authenticated users can access them, and enforce authorization (e.g., a user can only manage data for startups they own or are a co-founder of).
4. **Authentication & Authorization:**
* Implement user registration and login using NextAuth.js (email/password provider).
* Protect all routes under `/dashboard` and `/startups` to ensure only authenticated users can access them.
* Implement server-side authorization checks in API routes and server components/actions to ensure users can only modify data they are authorized for.
5. **User Interface:**
* Use Tailwind CSS for responsive and modern UI styling.
* Forms should include basic client-side validation (e.g., required fields).
* Display lists of co-founders, contributions, agreements, tasks, and communication logs on the respective startup detail page.
6. **Full CRUD Functionality:**
* For each major entity (Startups, Co-Founders, Contributions, Agreements, Tasks, Communication Logs), ensure that users can:
* **C**reate new records.
* **R**ead/View existing records (lists and individual details).
* **U**pdate existing records.
* **D**elete existing records.
7. **Technical Implementation Details:**
* Set up Drizzle ORM with `drizzle-kit` for schema definition and migrations. Include a basic `drizzle.config.ts`.
* Utilize Next.js Server Actions for form submissions where appropriate to demonstrate modern Next.js patterns.
* Demonstrate how to handle relationships between tables using Drizzle ORM (e.g., fetching a startup along with its associated co-founders and their contributions).
**Output:** Provide a comprehensive project structure (directories, key files), essential code snippets (database schema, API routes examples, a page component with server action), and clear instructions that would allow a developer to fully set up and run this MVP locally. Focus on functional implementation rather than just static UI.