Generate a fully functional, multi-page Next.js MVP application for 'GovGuard AI'. This application will serve as a SaaS platform to help AI companies manage legal risks and navigate government regulations. The core value proposition is to provide proactive legal risk analysis, automated document review, and strategic defense recommendations, thereby safeguarding AI companies' constitutional rights and business operations against arbitrary governmental actions.
**1. PROJECT OVERVIEW:**
GovGuard AI aims to empower AI companies by providing them with the tools to proactively identify, analyze, and defend against potential legal and regulatory challenges from government entities. The platform will focus on analyzing government actions (like the Anthropic case), identifying legal risks, summarizing complex legal documents, and suggesting defense strategies. The problem it solves is the growing complexity and potential arbitrariness of government oversight on AI companies, which can threaten their operations and constitutional rights. The core value proposition is offering a robust, data-driven legal defense augmentation tool, enabling companies to operate with greater security and confidence.
**2. TECH STACK:**
- **Framework:** Next.js (App Router)
- **Language:** TypeScript
- **Styling:** Tailwind CSS
- **ORM:** Drizzle ORM (PostgreSQL compatible)
- **Database:** PostgreSQL (or a compatible cloud SQL offering like Supabase/Neon)
- **UI Library:** shadcn/ui (for accessible, reusable components)
- **Authentication:** NextAuth.js (or Clerk for a more managed solution)
- **State Management:** React Context API / Zustand (for global state)
- **API Layer:** Server Actions and Route Handlers in Next.js
- **Deployment:** Vercel (recommended)
- **Other Libraries:** `react-hook-form` for forms, `zod` for validation, `date-fns` for date manipulation, a PDF parsing library (e.g., `pdf-parse`), and a charting library (e.g., `chart.js` or `recharts`).
**3. DATABASE SCHEMA:**
We will use PostgreSQL with Drizzle ORM. The schema will include:
- **`users` Table:**
- `id`: UUID (Primary Key)
- `name`: VARCHAR(255)
- `email`: VARCHAR(255) (Unique)
- `emailVerified`: TIMESTAMP WITH TIME ZONE
- `image`: TEXT (URL to profile picture)
- `createdAt`: TIMESTAMP WITH TIME ZONE (Default: now())
- `updatedAt`: TIMESTAMP WITH TIME ZONE (Default: now())
- **`accounts` Table (for NextAuth.js):**
- `id`: BIGSERIAL (Primary Key)
- `userId`: UUID (Foreign Key to `users.id`)
- `type`: VARCHAR(255)
- `provider`: VARCHAR(255)
- `providerAccountId`: VARCHAR(255)
- `refresh_token`: TEXT
- `access_token`: TEXT
- `expires_at`: BIGINT
- `token_type`: VARCHAR(255)
- `scope`: VARCHAR(255)
- `id_token`: TEXT
- `session_token`: TEXT
- **`sessions` Table (for NextAuth.js):**
- `id`: BIGSERIAL (Primary Key)
- `sessionToken`: VARCHAR(255) (Unique)
- `userId`: UUID (Foreign Key to `users.id`)
- `expires`: TIMESTAMP WITH TIME ZONE
- **`verificationTokens` Table (for NextAuth.js):**
- `identifier`: VARCHAR(255)
- `token`: VARCHAR(255)
- `expires`: TIMESTAMP WITH TIME ZONE
- **`companies` Table:**
- `id`: UUID (Primary Key, Default: gen_random_uuid())
- `userId`: UUID (Foreign Key to `users.id`, representing the owner/primary user)
- `name`: VARCHAR(255) (Company Name)
- `industry`: VARCHAR(255) (e.g., 'AI', 'SaaS', 'Biotech')
- `headquarters`: VARCHAR(255)
- `createdAt`: TIMESTAMP WITH TIME ZONE (Default: now())
- `updatedAt`: TIMESTAMP WITH TIME ZONE (Default: now())
- **`legal_risks` Table:**
- `id`: UUID (Primary Key, Default: gen_random_uuid())
- `companyId`: UUID (Foreign Key to `companies.id`)
- `risk_name`: VARCHAR(255) (e.g., 'Supply Chain Risk Label', 'First Amendment Violation')
- `description`: TEXT
- `severity_score`: INTEGER (1-10)
- `status`: VARCHAR(50) ('Identified', 'Mitigating', 'Resolved', 'Monitoring')
- `identified_date`: TIMESTAMP WITH TIME ZONE
- `potential_impact`: TEXT
- `created_at`: TIMESTAMP WITH TIME ZONE (Default: now())
- `updated_at`: TIMESTAMP WITH TIME ZONE (Default: now())
- **`documents` Table:**
- `id`: UUID (Primary Key, Default: gen_random_uuid())
- `companyId`: UUID (Foreign Key to `companies.id`)
- `fileName`: VARCHAR(255)
- `fileUrl`: TEXT (e.g., S3 URL)
- `fileType`: VARCHAR(50) ('PDF', 'DOCX', 'TXT')
- `upload_date`: TIMESTAMP WITH TIME ZONE (Default: now())
- `analysis_status`: VARCHAR(50) ('Pending', 'Processing', 'Completed', 'Failed')
- `analysis_summary`: TEXT (Summary generated by AI)
- `related_risks`: JSONB (Array of `legal_risks.id` related to this document)
- `created_at`: TIMESTAMP WITH TIME ZONE (Default: now())
- **`analysis_reports` Table:**
- `id`: UUID (Primary Key, Default: gen_random_uuid())
- `documentId`: UUID (Foreign Key to `documents.id`, optional, can be standalone analysis)
- `companyId`: UUID (Foreign Key to `companies.id`)
- `report_title`: VARCHAR(255)
- `report_content`: JSONB (Detailed findings, recommendations, strategic insights)
- `generated_at`: TIMESTAMP WITH TIME ZONE (Default: now())
- `created_at`: TIMESTAMP WITH TIME ZONE (Default: now())
- **`case_updates` Table:**
- `id`: UUID (Primary Key, Default: gen_random_uuid())
- `companyId`: UUID (Foreign Key to `companies.id`)
- `title`: VARCHAR(255)
- `update_text`: TEXT
- `source_url`: TEXT (Optional URL to the source of the update)
- `update_date`: TIMESTAMP WITH TIME ZONE
- `created_at`: TIMESTAMP WITH TIME ZONE (Default: now())
**4. CORE FEATURES & USER FLOW:**
**A. User Authentication & Company Onboarding:**
- **Flow:** User signs up via email/password or OAuth (Google/GitHub). Upon first login, they are prompted to create or join a company profile. They enter company name, industry, and headquarters. The company is linked to their user account.
- **Functionality:** Secure auth using NextAuth.js/Clerk, company creation/linking via Server Actions, basic form validation.
**B. Legal Risk Identification & Dashboard:**
- **Flow:** Upon company setup, the dashboard displays an overview. A dedicated section allows users to manually add potential risks (e.g., 'Supply Chain Risk Label'). The system will also automatically suggest risks based on news feeds and regulatory updates (future enhancement, MVP focuses on manual input & analysis).
- **Functionality:** Dashboard page displaying company overview, list of identified risks with severity scores and status. Risk creation form using `react-hook-form` and `zod` validation, saved via Server Actions.
**C. Document Upload & Analysis:**
- **Flow:** User navigates to 'Document Analysis'. Clicks 'Upload Document'. Selects a file (PDF, DOCX, TXT). Upon upload, the file is stored (e.g., AWS S3/Vercel Blob Storage), and an analysis job is triggered. The `analysis_status` is updated. Once complete, the summary and related risks are displayed.
- **Functionality:** File upload component, Server Action to handle upload and trigger backend processing (e.g., a job queue or direct AI call). PDF parsing library to extract text. A placeholder/mock AI analysis function for MVP, returning a structured JSON.
**D. Analysis Report Generation & Viewing:**
- **Flow:** After document analysis, a detailed report is generated. Users can view this report on a dedicated 'Report Details' page. The report includes extracted text summary, identified legal issues, constitutional rights implications (based on analysis), and actionable recommendations.
- **Functionality:** A report viewing component that renders structured JSON data from `analysis_reports` table. Display options for summary, risks, and recommendations.
**E. Case Update Tracking:**
- **Flow:** A 'Case Updates' section where users can manually input significant legal news or government actions relevant to their company or industry. The system stores these updates with dates and sources.
- **Functionality:** Form to add case updates, list view of updates sorted by date. Future enhancement: Integrate RSS feeds or news APIs.
**5. API & DATA FETCHING:**
- **Approach:** Utilize Next.js App Router's Server Actions for mutations (POST, PUT, DELETE) and Server Components / `fetch` API for data fetching (GET).
- **Key Endpoints/Server Actions:**
- `POST /api/auth/signup`, `POST /api/auth/signin` (handled by NextAuth.js/Clerk)
- `POST /api/company/create` (Server Action to create company)
- `POST /api/risks/add` (Server Action to add a legal risk)
- `POST /api/documents/upload` (Server Action for file upload & analysis trigger)
- `GET /api/dashboard/data` (Server Component fetching company data, risks)
- `GET /api/reports/{reportId}` (Server Component fetching specific report)
- `GET /api/case-updates` (Server Component fetching case updates)
- **Data Flow:** Data is fetched directly on the server in Server Components or accessed via Server Actions. Client components can trigger Server Actions or fetch data from API routes if needed, but the preference is server-centric data loading for performance and security.
**6. COMPONENT BREAKDOWN (Next.js App Router):**
- **`app/layout.tsx`:** Root layout (includes `<html>`, `<body>`, global providers, Tailwind CSS setup, shadcn/ui ThemeProvider).
- **`app/page.tsx`:** Landing Page (Marketing content, CTA for signup/login).
- **`app/auth/signin/page.tsx`:** Sign In page.
- **`app/auth/signup/page.tsx`:** Sign Up page.
- **`app/(protected)/layout.tsx`:** Protected layout (checks authentication status, applies common UI elements like sidebar/header).
- **`app/(protected)/dashboard/page.tsx`:** Dashboard - Overview of company risks, recent activity, quick links.
- **Components:** `CompanyOverviewCard`, `RiskList`, `RecentUpdatesList`, `QuickActionButtons`.
- **`app/(protected)/company/settings/page.tsx`:** Company Settings - Edit company profile.
- **Components:** `CompanySettingsForm`.
- **`app/(protected)/risks/page.tsx`:** Risk Management - View, add, edit legal risks.
- **Components:** `RiskTable`, `AddRiskForm`, `RiskDetailView`.
- **`app/(protected)/documents/page.tsx`:** Document Upload & Management.
- **Components:** `DocumentUploadForm`, `DocumentList`.
- **`app/(protected)/documents/[documentId]/page.tsx`:** Document Analysis Result / Report View.
- **Components:** `AnalysisReportViewer` (displays summary, findings, recommendations).
- **`app/(protected)/case-updates/page.tsx`:** Case Updates - View tracked legal updates.
- **Components:** `CaseUpdateList`, `AddCaseUpdateForm`.
- **`app/api/...`:** API routes (e.g., for auth, potentially dynamic data fetching if needed).
- **`components/ui/...`:** Reusable UI components from shadcn/ui (Button, Input, Card, Table, etc.).
- **`components/layout/...`:** Layout components (Navbar, Sidebar, Footer).
- **`components/forms/...`:** Custom form components (e.g., `RiskForm`, `DocumentUploadForm`).
- **`lib/...`:** Utility functions, database client setup (Drizzle), AI service wrappers.
- **`hooks/...`:** Custom React hooks.
**7. UI/UX DESIGN & VISUAL IDENTITY:**
- **Style:** "Modern Minimalist Professional" - Clean lines, ample whitespace, professional typography, subtle interactions.
- **Color Palette:**
- Primary: `#007AFF` (Modern Blue)
- Secondary: `#5AC8FA` (Light Blue Accent)
- Accent/Success: `#34C759` (Green)
- Warning/Alert: `#FF9500` (Orange)
- Danger: `#FF3B30` (Red)
- Background: `#FFFFFF` (White)
- Card/Element Background: `#F2F2F7` (Light Gray)
- Text Primary: `#1C1C1E` (Near Black)
- Text Secondary: `#8E8E93` (Gray)
- **Typography:** Use a clean, sans-serif font family like Inter or SF Pro.
- Headings: Inter Bold (e.g., 36px for H1, 28px for H2)
- Body Text: Inter Regular (e.g., 16px)
- **Layout:** Dashboard and internal pages will feature a persistent sidebar navigation on larger screens, collapsing to a hamburger menu on mobile. Content areas will be well-structured with clear headings and cards.
- **Responsive Rules:** Mobile-first approach. Sidebar collapses, content stacks vertically. Ensure all forms and tables are usable on small screens. Use Tailwind CSS's responsive prefixes (`sm:`, `md:`, `lg:`).
**8. SAMPLE/MOCK DATA:**
- **`users`:**
- `{ id: '...', name: 'Alice Johnson', email: 'alice.j@example-ai.com', emailVerified: '2023-10-26T10:00:00Z' }`
- **`companies`:**
- `{ id: '...', userId: '...', name: 'InnovateAI Corp', industry: 'AI Research', headquarters: 'San Francisco, CA' }`
- **`legal_risks`:**
- `{ id: '...', companyId: '...', risk_name: 'Supply Chain Risk Label', description: 'Potential classification as a supply chain risk by Pentagon.', severity_score: 8, status: 'Identified', identified_date: '2023-10-25T00:00:00Z', potential_impact: 'Loss of government contracts, reputational damage.' }`
- `{ id: '...', companyId: '...', risk_name: 'First Amendment Violation Claim', description: 'Allegation that government actions infringed on company's free speech rights.', severity_score: 7, status: 'Monitoring', identified_date: '2023-10-26T00:00:00Z', potential_impact: 'Precedent setting, potential legal fees.' }`
- **`documents`:**
- `{ id: '...', companyId: '...', fileName: 'Pentagon_Notice_Oct2023.pdf', upload_date: '2023-10-26T11:00:00Z', analysis_status: 'Completed', analysis_summary: 'Summary of notice regarding supply chain protocols...' }`
- **`analysis_reports`:**
- `{ id: '...', documentId: '...', companyId: '...', report_title: 'Analysis of Pentagon Notice Oct 2023', report_content: { summary: '...', findings: ['Government action may violate...', 'Constitutional rights implications...'], recommendations: ['Prepare legal defense strategy...', 'Draft counter-argument...', 'Review internal policies...'] }, generated_at: '2023-10-26T12:00:00Z' }`
- **`case_updates`:**
- `{ id: '...', companyId: '...', title: 'Judge Blocks Pentagon AI Risk Label', update_text: 'Federal judge ruled indefinitely blocked the Pentagon’s effort...', source_url: 'https://example-news.com/article-url', update_date: '2023-10-26T00:00:00Z' }`
**9. ANIMATIONS:**
- **Page Transitions:** Subtle fade-in/out transitions using Next.js `next/transition` or Framer Motion if needed.
- **Element Transitions:** Smooth transitions on hover states for buttons and links (e.g., background color change, slight scale-up).
- **Loading States:** Skeleton loaders or spinners (`react-spinners` or custom CSS spinners) for data fetching and processing (e.g., document analysis status).
- **Form Feedback:** Subtle animations for validation errors (e.g., shake effect) and success messages.
**10. EDGE CASES:**
- **Authentication:** Handle unauthenticated access gracefully (redirect to login). Implement password reset flow. Ensure secure session management.
- **Authorization:** Ensure users can only access/modify data belonging to their associated company.
- **Empty States:** Design informative empty states for Dashboard, Risk List, Document List, Case Updates when no data is present (e.g., 'No risks identified yet. Add your first risk.', 'Upload your first document to analyze.').
- **Error Handling:** Implement robust error handling for API requests, database operations, and file uploads. Display user-friendly error messages (e.g., using `try...catch` blocks in Server Actions, displaying toast notifications).
- **Validation:** Use `zod` for comprehensive client-side and server-side validation of all form inputs (company details, risks, document metadata, etc.).
- **File Uploads:** Handle large file uploads, check file types, implement retry mechanisms if processing fails.
- **AI Analysis Failures:** If the AI analysis fails, clearly indicate this to the user and provide options to retry or contact support.
**11. TURKISH TRANSLATIONS (Key UI Elements):**
- **App Title:** GovGuard AI
- **Navigation:**
- Dashboard: `Gösterge Paneli`
- Company Settings: `Şirket Ayarları`
- Risks: `Yasal Riskler`
- Documents: `Belgeler`
- Case Updates: `Dava Güncellemeleri`
- **Buttons:**
- Sign In: `Giriş Yap`
- Sign Up: `Kayıt Ol`
- Upload Document: `Belge Yükle`
- Add Risk: `Risk Ekle`
- Save: `Kaydet`
- Analyze: `Analiz Et`
- **Placeholders/Labels:**
- Email: `E-posta`
- Password: `Şifre`
- Company Name: `Şirket Adı`
- Risk Name: `Risk Adı`
- Description: `Açıklama`
- Severity Score: `Önem Derecesi (1-10)`
- File Upload: `Dosya Yükleme`
- **Headings:**
- Welcome to GovGuard AI: `GovGuard AI'a Hoş Geldiniz`
- Your Legal Risk Dashboard: `Yasal Risk Gösterge Paneli`
- Identified Risks: `Tespit Edilen Riskler`
- Document Analysis Results: `Belge Analizi Sonuçları`
- Key Case Updates: `Önemli Dava Güncellemeleri`
- **Status Messages:**
- Analysis Pending: `Analiz Bekliyor`
- Analysis in Progress: `Analiz Devam Ediyor`
- Analysis Complete: `Analiz Tamamlandı`
- Error: `Hata`
- **Empty States:**
- No risks found: `Henüz risk bulunamadı.`
- Upload a document to start analysis: `Analize başlamak için bir belge yükleyin.`
This comprehensive prompt provides all necessary details to generate a robust MVP of the GovGuard AI platform, focusing on core functionality, security, usability, and a professional aesthetic, fulfilling the requirement for a multi-page, database-backed Next.js application.