You are a senior full-stack developer. Your task is to build a fully functional MVP for a 'Tax Coordinator' application using Next.js 14 with the App Router, TypeScript, Tailwind CSS, and Drizzle ORM connected to a PostgreSQL database. The application should facilitate coordination between family members (parents and students) regarding tax dependency and education credit claims to prevent common filing rejections.
The application must be multi-page and include full CRUD operations for the core entities.
**Database Schema (Drizzle ORM):**
1. **users** table:
* `id`: UUID, primary key, default `sql.gen_random_uuid()`
* `email`: string, unique, not null
* `passwordHash`: string, not null
* `role`: enum ('parent', 'student'), not null, default 'student'
* `familyId`: UUID, nullable, foreign key to `families.id`
* `createdAt`: timestamp, default `sql.now()`
* `updatedAt`: timestamp, default `sql.now()`
2. **families** table:
* `id`: UUID, primary key, default `sql.gen_random_uuid()`
* `familyName`: string, not null
* `inviteCode`: string, unique, not null (autogenerated on creation)
* `createdAt`: timestamp, default `sql.now()`
* `updatedAt`: timestamp, default `sql.now()`
3. **dependentClaims** table:
* `id`: UUID, primary key, default `sql.gen_random_uuid()`
* `claimerUserId`: UUID, not null, foreign key to `users.id`
* `dependentUserId`: UUID, not null, foreign key to `users.id`
* `taxYear`: integer, not null
* `status`: enum ('pending', 'approved_by_dependent', 'rejected_by_dependent', 'confirmed_by_claimer', 'conflict'), not null, default 'pending'
* `notes`: text, nullable
* `createdAt`: timestamp, default `sql.now()`
* `updatedAt`: timestamp, default `sql.now()`
4. **educationCreditClaims** table:
* `id`: UUID, primary key, default `sql.gen_random_uuid()`
* `claimerUserId`: UUID, not null, foreign key to `users.id`
* `taxYear`: integer, not null
* `creditType`: enum ('AOTC', 'LLC', 'other'), not null
* `amountClaimed`: decimal(10, 2), nullable
* `status`: enum ('pending', 'approved', 'rejected', 'conflict'), not null, default 'pending'
* `notes`: text, nullable
* `createdAt`: timestamp, default `sql.now()`
* `updatedAt`: timestamp, default `sql.now()`
**Application Structure (Next.js App Router):**
* **`app/page.tsx`**: A simple landing page.
* **`app/layout.tsx`**: Root layout for global styling and navigation.
* **`app/auth/login/page.tsx`**: User login form.
* **`app/auth/signup/page.tsx`**: User registration form.
* **`app/auth/logout/route.ts`**: API route for logging out.
* **`app/dashboard/page.tsx`**: Main user dashboard displaying a summary of pending claims, conflicts, and family members. This should fetch user-specific data.
* **`app/family/create/page.tsx`**: Form for creating a new family and becoming its first member (parent role). Generates an `inviteCode`.
* **`app/family/join/page.tsx`**: Form for joining an existing family using an `inviteCode`.
* **`app/claims/dependent/new/page.tsx`**: Form for a user to create a new dependent claim (e.g., a parent claiming a student). Should list available family members (students) as options.
* **`app/claims/dependent/[id]/page.tsx`**: Dynamic page to view details of a specific dependent claim. Allows the `dependentUserId` to `approve_by_dependent` or `reject_by_dependent` the claim, and the `claimerUserId` to `confirm_by_claimer`.
* **`app/claims/education/new/page.tsx`**: Form for a user to create a new education credit claim.
* **`app/claims/education/[id]/page.tsx`**: Dynamic page to view and potentially update a specific education credit claim.
**API Routes (`app/api` directory with `route.ts` files):**
* **`app/api/auth/register/route.ts`**: Handles user registration.
* **`app/api/auth/login/route.ts`**: Handles user login and session management (using iron-session or similar for secure cookies).
* **`app/api/families/route.ts`**:
* `POST`: Create a new family (requires authentication).
* **`app/api/families/join/route.ts`**:
* `POST`: Join a family using an invite code (requires authentication).
* **`app/api/users/route.ts`**:
* `GET`: Get current authenticated user details.
* **`app/api/users/[id]/route.ts`**:
* `GET`: Get a specific user's details (e.g., family members).
* **`app/api/claims/dependent/route.ts`**:
* `GET`: Fetch all dependent claims related to the authenticated user's family.
* `POST`: Create a new dependent claim.
* **`app/api/claims/dependent/[id]/route.ts`**:
* `GET`: Fetch a specific dependent claim.
* `PUT`: Update a dependent claim's status or details (e.g., approval/rejection).
* `DELETE`: Delete a dependent claim.
* **`app/api/claims/education/route.ts`**:
* `GET`: Fetch all education credit claims related to the authenticated user's family.
* `POST`: Create a new education credit claim.
* **`app/api/claims/education/[id]/route.ts`**:
* `GET`: Fetch a specific education credit claim.
* `PUT`: Update an education credit claim's status or details.
* `DELETE`: Delete an education credit claim.
**Key Functionality to Implement:**
1. **User Authentication**: Implement secure signup and login flows. Users should be redirected to `/dashboard` upon successful login.
2. **Family Management**: Users can create a family (becoming a 'parent') or join an existing one with an invite code. Students initially register and then join a family.
3. **Dependent Claim Workflow**:
* A parent user can create a claim for a student user within their family.
* The student user receives a notification on their dashboard and can approve or reject the claim.
* Upon approval, the parent can `confirm_by_claimer`. If rejected, the parent sees the rejection.
* **Conflict Detection**: If a student