# sovitchaudhary/aiprephub architecture

> Architecture diagram of the GitHub repository sovitchaudhary/aiprephub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sovitchaudhary/aiprephub
- Repository: https://github.com/sovitchaudhary/aiprephub

## Overview

##### Project Type and Purpose
- This is a full-stack Next.js (v13+) web application that provides AI-powered job-application tooling (cover-letter generation, resume building, interview prep, user dashboards). It uses the Next.js App Router, server components, client components, server actions, API routes, Inngest for background jobs, and Prisma ORM for database access.

##### File Structure & Architectural Insights
- Top-level “app/” directory: defines your route hierarchy using Next.js App Router.
- `app/(auth)/…` – Sign-in and sign-up flows (server components plus dynamic client pages).
- `app/(main)/…` – Main authenticated experience:
– `ai-cover-letter/`, `resume/`, `interview/`, `dashboard/`, `onboarding/`.
– Each has its own layout.js, page.jsx, and nested `_components` subfolders.
- `app/api/inngest/route.js` – HTTP endpoint to accept Inngest-driven webhooks or job kicks.
- `app/lib/` – Shared helper code (helper.js, schema.js).
- “actions/” folder: Next.js 13 server-action modules that encapsulate core business logic (resume.js, cover-letter.js, interview.js, dashboard.js, user.js).
- “lib/inngest/…”: Inngest client setup and function definitions (background job handlers).
- “lib/prisma.js”: Prisma client initialization for connecting to the relational database defined in prisma/schema.prisma.
- “components/”: Reusable UI components (header, hero, theme-provider) and “components/ui/” for lower-level design primitives.
- “hooks/use-fetch.js”: Client hook to wrap fetch calls.
- “prisma/”: Database schema and migration files.

##### External Services & Dependencies
- AI API (e.g., OpenAI) – used by server actions to generate text.
- Inngest – background job orchestration for long-running tasks (bulk generation, email events, analytics).
- Relational database (PostgreSQL or MySQL) via Prisma.
- Vercel / cloud hosting for Next.js SSR/SSG.

##### Key Points to Capture
- Separation of concerns: UI vs. server vs. background.
- Flow of data: User interactions trigger server actions or API routes → AI calls + DB writes → responses or job enqueues.
- Reusability: `actions/` modules and `components/ui`.
- Scalability: Inngest decouples heavy tasks.
- Incremental rendering: App Router, Server & Client Components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Browser + UI)" 
        direction TB
        Browser["User Browser"]:::frontend
        UI_Components["React UI Components"]:::frontend
        Design_Primitives["Design System Primitives"]:::frontend
        Custom_Hook["Custom Fetch Hook"]:::frontend
    end

    %% Server Layer
    subgraph "Next.js Server" 
        direction TB
        Router["Next.js App Router"]:::server
        Auth_Flows["Auth Flows (Sign-in/Sign-up)"]:::server
        Main_Pages["Authenticated Pages (ai-cover-letter, resume, interview, dashboard, onboarding)"]:::server
        Server_Actions["Server Actions (Business Logic)"]:::server
        API_Route["Inngest Webhook API Route"]:::server
        Shared_Lib["Shared Helpers & Schema"]:::server
        Prisma_Client["Prisma Client Init"]:::server
    end

    %% Background Worker
    subgraph "Background Worker" 
        direction TB
        Inngest_Service["Inngest Worker Service"]:::background
    end

    %% Database
    Database[(Database)]:::database

    %% External Services
    subgraph "External Services"
        direction TB
        AI_API["External AI API"]:::external
    end

    %% Connections
    Browser -->|"HTTP GET (SSR/SSG)"| Router
    Browser -->|"UI interactions"| UI_Components
    UI_Components -->|"calls"| Server_Actions
    Router -->|"routes to"| Auth_Flows
    Router -->|"routes to"| Main_Pages
    Server_Actions -->|"CRUD"| Prisma_Client
    Server_Actions -->|"HTTP calls"| AI_API
    Main_Pages -->|"enqueue tasks"| API_Route
    API_Route -->|"enqueue to"| Inngest_Service
    Inngest_Service -->|"calls"| AI_API
    Inngest_Service -->|"CRUD"| Prisma_Client
    Inngest_Service -->|"webhook callback"| API_Route
    Prisma_Client -->|"queries"| Database

    %% Click Events
    click Router "https://github.com/sovitchaudhary/aiprephub/blob/master/app/layout.js"
    click Router "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(auth)/layout.js"
    click Router "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/layout.js"
    click Auth_Flows "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(auth)/sign-in/[[...sign-in]]/page.jsx"
    click Auth_Flows "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(auth)/sign-up/[[...sign-up]]/page.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/ai-cover-letter/page.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/ai-cover-letter/new/page.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/ai-cover-letter/[id]/page.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/tree/master/app/(main)/ai-cover-letter/_components/"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/resume/page.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/resume/layout.js"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/tree/master/app/(main)/resume/_components/"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/interview/page.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/interview/layout.js"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/tree/master/app/(main)/interview/_components/"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/interview/prep/page.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/dashboard/page.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/dashboard/layout.js"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/dashboard/_component/dashboard-view.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/onboarding/page.jsx"
    click Main_Pages "https://github.com/sovitchaudhary/aiprephub/blob/master/app/(main)/onboarding/_components/onboarding-form.jsx"
    click API_Route "https://github.com/sovitchaudhary/aiprephub/blob/master/app/api/inngest/route.js"
    click Server_Actions "https://github.com/sovitchaudhary/aiprephub/blob/master/actions/cover-letter.js"
    click Server_Actions "https://github.com/sovitchaudhary/aiprephub/blob/master/actions/resume.js"
    click Server_Actions "https://github.com/sovitchaudhary/aiprephub/blob/master/actions/interview.js"
    click Server_Actions "https://github.com/sovitchaudhary/aiprephub/blob/master/actions/dashboard.js"
    click Server_Actions "https://github.com/sovitchaudhary/aiprephub/blob/master/actions/user.js"
    click Inngest_Service "https://github.com/sovitchaudhary/aiprephub/blob/master/lib/inngest/client.js"
    click Inngest_Service "https://github.com/sovitchaudhary/aiprephub/blob/master/lib/inngest/functions.js"
    click Prisma_Client "https://github.com/sovitchaudhary/aiprephub/blob/master/lib/prisma.js"
    click Shared_Lib "https://github.com/sovitchaudhary/aiprephub/blob/master/app/lib/helper.js"
    click Shared_Lib "https://github.com/sovitchaudhary/aiprephub/blob/master/app/lib/schema.js"
    click UI_Components "https://github.com/sovitchaudhary/aiprephub/blob/master/components/header.jsx"
    click UI_Components "https://github.com/sovitchaudhary/aiprephub/blob/master/components/hero.jsx"
    click UI_Components "https://github.com/sovitchaudhary/aiprephub/blob/master/components/theme-provider.jsx"
    click Design_Primitives "https://github.com/sovitchaudhary/aiprephub/tree/master/components/ui/"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef server fill:#DFF2D8,stroke:#228B22,color:#228B22;
    classDef background fill:#FFF4C1,stroke:#E5A800,color:#E5A800;
    classDef database fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00;
    classDef external fill:#E8D0FF,stroke:#800080,color:#800080;
```
