You are an expert full-stack developer specializing in Next.js App Router, Drizzle ORM, and building robust, multi-page web applications with full CRUD functionality. Your task is to develop a complete MVP for a "Customer Advocate Tracking and Empowerment" SaaS application called "Advocate Radar." The application should allow SaaS companies to identify, track, and gently empower their most effective customer advocates. Here's a detailed breakdown of the requirements: Project Setup: Initialize a Next.js 14 project using the App Router (`app/` directory structure). Use TypeScript. Integrate Drizzle ORM with a PostgreSQL database (provide a `drizzle.config.ts` and `schema.ts` file, and example database connection setup). Implement Tailwind CSS for styling. Use NextAuth.js for authentication (email/password and Google provider, with Drizzle adapter). Structure the project for multi-page functionality with distinct routes. Core Features (MVP): 1. Authentication & Authorization: User registration and login (email/password, Google). User profiles associated with their respective SaaS companies (each company can have multiple users/admins). Dashboard accessible only to authenticated users. 2. Company Onboarding/Management: A 'Company' entity to represent the SaaS client using Advocate Radar. Upon first user registration, prompt to create a new Company or join an existing one (via invitation code). CRUD operations for Company profiles (name, industry, website). 3. Customer Management (within a Company): Customer Schema: Each 'Customer' belongs to a 'Company'. Fields: `id`, `companyId`, `externalCustomerId` (ID from client's CRM), `name`, `email`, `referralLink` (unique link generated for tracking), `createdAt`, `updatedAt`. CRUD for Customers: Ability to add new customers manually. Ability to import customers via CSV (simple upload, parse, and save). View a list of all customers associated with the logged-in company. Edit customer details. Delete customers. Referral Link Generation: Automatically generate a unique, trackable referral link for each customer. This link should append parameters to the client's SaaS product signup URL (e.g., `https://my-saas.com/signup?refId=CUSTOMER_ID`). Store this link in the database. 4. Advocate Identification & Profiling: Advocate Schema: Extends 'Customer'. Fields: `customerId`, `isAdvocate` (boolean), `totalReferrals` (number), `convertedReferrals` (number), `totalMRRGenerated` (decimal), `lastActivityAt`. Advocate Detection Logic (simplified for MVP): Initially, an advocate can be manually flagged by a company user. In a more advanced version, this would be based on `totalReferrals > X`. Advocate Profile Page: A dedicated page for each identified advocate, showing: Customer details (name, email). Referral link. Key metrics: Total Referrals, Converted Referrals, Total MRR Generated. A simple list of new customers acquired through this advocate's link (showing their name, signup date, plan). 5. Referral Tracking & Attribution (API Routes): Referral API Endpoint: A public API route (`/api/track-referral`) that receives `refId` from the generated referral links. This endpoint should: Record an `Impression` event (e.g., `referralClicks` in `Advocate` table or a separate `ReferralEvent` table). Return a redirect to the actual SaaS product's signup page. Conversion API Endpoint: Another API route (`/api/record-conversion`) that the client's SaaS product can call *post-signup* or *post-payment*. This endpoint should: Receive `refId` and `newCustomerId` (from the client's system). Update the `Advocate` record: increment `convertedReferrals`, add `newCustomerId` to a list (or create a `ConvertedCustomer` entity linking back to `Advocate`), potentially update `totalMRRGenerated` (can be a fixed default for MVP or provided in the payload). Database Schema for Tracking: `ReferralEvent`: `id`, `advocateId`, `type` (e.g., 'click', 'signup', 'conversion'), `timestamp`, `referredCustomerId` (nullable). 6. Basic Analytics Dashboard: On the main dashboard, display: Total advocates identified. Total referrals (clicks). Total converted customers. Total estimated MRR generated from advocates. A list of top 5 advocates by converted referrals. Technical Implementation Details: Next.js App Router: Organize pages (e.g., `/dashboard`, `/customers`, `/advocates/[id]`, `/settings`, `/auth/signin`). Drizzle ORM: Define `schema.ts` for all entities: `users`, `accounts`, `sessions`, `verificationTokens` (for NextAuth), `companies`, `customers`, `advocates`, `referralEvents`. Use `drizzle-kit` for migrations. Provide example Drizzle queries in server components or API routes. API Routes: Implement specific API routes for customer CRUD and the referral/conversion tracking endpoints. Client-Side: Use React Server Components for data fetching where appropriate, and client components for interactive elements (forms, lists with client-side filtering). Error Handling: Basic error handling for API calls and form submissions. Input Validation: Use Zod for schema validation on API inputs and form data. Styling: Use Tailwind CSS for a clean, functional UI. No need for complex design, focus on functionality. Output: Provide all necessary files: `package.json` (with dependencies) `next.config.js` `tailwind.config.ts` `drizzle.config.ts` `src/app/layout.tsx` (basic layout) `src/app/page.tsx` (redirect to dashboard if authenticated) `src/app/dashboard/page.tsx` (main dashboard) `src/app/customers/page.tsx` (list customers) `src/app/customers/new/page.tsx` (add new customer form) `src/app/customers/[id]/edit/page.tsx` (edit customer form) `src/app/advocates/page.tsx` (list advocates) `src/app/advocates/[id]/page.tsx` (individual advocate profile) `src/app/api/customers/route.ts` (CRUD for customers) `src/app/api/track-referral/route.ts` (public endpoint) `src/app/api/record-conversion/route.ts` (public endpoint) `src/lib/db.ts` (Drizzle client setup) `src/db/schema.ts` (Drizzle schema for all entities) `s