# krishnanshu-khanna/chat-resume-ai architecture

> Architecture diagram of the GitHub repository krishnanshu-khanna/chat-resume-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krishnanshu-khanna/chat-resume-ai
- Repository: https://github.com/krishnanshu-khanna/chat-resume-ai

## Overview

##### Project type and purpose
- CVHelper is a full-stack resume builder web application built with Next.js.
- It provides AI-powered features: resume editing, ATS-optimized chat, interview practice, PDF parsing/generation, user auth, and paid subscriptions.

##### High-level components
Module-wise (to fit a portrait-oriented canvas), group the system into these main blocks:
a. Client (Browser) – Next.js React components
b. Next.js Application Layer – server-side rendering & API routes
c. Data Layer – Prisma + PostgreSQL
d. External Services – Clerk (Auth), Stripe (Payments), AI APIs (OpenAI, Gemini), Langchain, Pinecone, Vercel Neon Blob

##### Relationships & data flows
- The browser loads pages and invokes React UI components in `src/app` and `src/components`.
- UI triggers Next.js server (via page requests, app router, and `app/api` routes).
- The Next.js server communicates with:
- Prisma client → Postgres database (user data, resumes, chats, interviews, subscriptions)
- Clerk SDK (authentication middleware)
- Stripe API & `stripe-webhook` route (billing management)
- File upload route (`/api/upload`) → Blob storage (Vercel Neon Blob)
- AI modules in `src/lib` (langchain + pinecone for ATS chat, Gemini/OpenAI for text generation)

##### Architectural patterns & design principles
- Componentized UI (atomic + module-level components under `src/components` and `src/app/(main)`).
- Modular services per feature: auth, billing, chat, interview, editor.
- Serverless functions / API routes for integration points (Stripe webhooks, file uploads).
- Prisma ORM for data modeling and type safety.
- Third-party SDKs isolated in `src/lib`.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Browser)"
        UI["Next.js React UI"]:::frontend
    end

    %% Next.js App Server
    subgraph "Next.js App Server"
        subgraph "App Router (Pages & Components)"
            AuthModule["Auth Module"]:::server
            EditorModule["Editor Module"]:::server
            ChatModule["Chat Module"]:::server
            InterviewModule["Interview Module"]:::server
            BillingModule["Billing Module"]:::server
            ResumesModule["Resumes List Module"]:::server
        end
        subgraph "API Routes"
            StripeWebhook["/api/stripe-webhook"]:::server
            UploadAPI["/api/upload"]:::server
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["Prisma Client → PostgreSQL"]:::db
    end

    %% External Services
    subgraph "External Services"
        AuthService["Clerk Auth"]:::external
        StripeService["Stripe Billing"]:::external
        BlobStorage["Blob Storage (Vercel Neon)"]:::external
        AIServices["AI Services (OpenAI, Gemini)"]:::external
        VectorStore["Langchain + Pinecone"]:::external
    end

    %% Utility & Common
    subgraph "Utility & Common"
        UIComponents["UI Components & Hooks"]:::frontend
        Utils["Utils, Validation, Types"]:::server
    end

    %% Connections: Client to Server
    UI -->|"HTTP/SSR, API calls"| AuthModule
    UI --> EditorModule
    UI --> ChatModule
    UI --> InterviewModule
    UI --> BillingModule
    UI --> ResumesModule

    %% Server to Data Layer
    AuthModule -->|"SQL Queries"| DB
    EditorModule --> DB
    ChatModule --> DB
    InterviewModule --> DB
    BillingModule --> DB
    ResumesModule --> DB
    StripeWebhook --> DB
    UploadAPI --> DB

    %% Server to External
    AuthModule -->|"REST API"| AuthService
    BillingModule -->|"REST API"| StripeService
    StripeWebhook -->|"Webhook Event"| StripeService
    UploadAPI -->|"Direct Upload"| BlobStorage
    ChatModule -->|"LangChain API"| VectorStore
    VectorStore -->|"Vector Search"| AIServices
    ChatModule -->|"Text Generation"| AIServices
    InterviewModule -->|"Text Generation"| AIServices
    EditorModule -->|"PDF Generation"| AIServices

    %% Utility usage
    AuthModule --> UIComponents
    EditorModule --> UIComponents
    ChatModule --> UIComponents
    InterviewModule --> UIComponents
    BillingModule --> UIComponents
    ResumesModule --> UIComponents
    AuthModule --> Utils
    EditorModule --> Utils
    ChatModule --> Utils
    InterviewModule --> Utils
    BillingModule --> Utils
    ResumesModule --> Utils

    %% Click Events
    click UI "https://github.com/krishnanshu-khanna/chat-resume-ai/tree/main/src/app"
    click UI "https://github.com/krishnanshu-khanna/chat-resume-ai/tree/main/src/components"

    click AuthModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(auth)/sign-in/[[...sign-in]]/page.tsx"
    click AuthModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(auth)/sign-up/[[...sign-up]]/page.tsx"
    click AuthModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/middleware.ts"

    click EditorModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/editor/page.tsx"
    click EditorModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/editor/ResumeEditor.tsx"
    click EditorModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/editor/actions.ts"
    click EditorModule "https://github.com/krishnanshu-khanna/chat-resume-ai/tree/main/src/app/(main)/editor/forms"

    click ChatModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/chat/page.tsx"
    click ChatModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/chat/[chatId]/page.tsx"
    click ChatModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/chat/[chatId]/action.ts"
    click ChatModule "https://github.com/krishnanshu-khanna/chat-resume-ai/tree/main/src/app/(main)/chat/_components"
    click ChatModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/chat/_components/Chat.tsx"

    click InterviewModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/interview/page.tsx"
    click InterviewModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/interview/[interviewId]/page.tsx"
    click InterviewModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/interview/[interviewId]/start/action.ts"
    click InterviewModule "https://github.com/krishnanshu-khanna/chat-resume-ai/tree/main/src/app/(main)/interview/_components"

    click BillingModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/billing/page.tsx"
    click BillingModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/billing/actions.ts"
    click BillingModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/billing/GetSubscriptionButton.tsx"
    click BillingModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/billing/ManageSubscriptionButton.tsx"
    click BillingModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/billing/success/page.tsx"

    click ResumesModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/resumes/page.tsx"
    click ResumesModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/resumes/actions.ts"
    click ResumesModule "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/(main)/resumes/ResumeItem.tsx"

    click StripeWebhook "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/api/stripe-webhook/route.ts"
    click UploadAPI "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/app/api/upload/route.ts"

    click DB "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/prisma/schema.prisma"
    click DB "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/lib/prisma.ts"

    click AIServices "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/lib/gemini.ts"
    click VectorStore "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/lib/langchain.ts"
    click VectorStore "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/lib/pinecone.ts"

    click StripeService "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/lib/stripe.ts"
    click StripeService "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/lib/subscription.ts"

    click UIComponents "https://github.com/krishnanshu-khanna/chat-resume-ai/tree/main/src/components/ui"
    click UIComponents "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/hooks/use-toast.ts"
    click UIComponents "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/hooks/usePremiumModal.ts"
    click Utils "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/lib/utils.ts"
    click Utils "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/lib/validation.ts"
    click Utils "https://github.com/krishnanshu-khanna/chat-resume-ai/blob/main/src/lib/types.ts"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0288d1
    classDef server fill:#e8f5e9,stroke:#2e7d32
    classDef db fill:#ffe0b2,stroke:#ef6c00
    classDef external fill:#f3e5f5,stroke:#6a1b9a
```
