# justintimejt/crackdresume architecture

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

- Interactive diagram: https://gitdiagram.com/justintimejt/crackdresume
- Repository: https://github.com/justintimejt/crackdresume

## Overview

##### Project type and purpose
- Project type: Full-stack web application built with Next.js 15 (React + TypeScript).
- Purpose: AI-powered resume generation—take user input, invoke Google Gemini to produce LaTeX, compile to PDF, return outputs, optionally open in Overleaf, all without requiring login.

##### File structure
- src/app: Next.js “App Router” layers (pages, layouts, client/server components).
- /api/compile-pdf-online and /api/generate – serverless API routes.
- /build – React pages for the LaTeX compile flow.
- /components – shared UI pieces (Form, TemplateSelector, LoadScreen).
- /result – render final PDF download page.
- src/lib: wrappers for Supabase admin (server) and client (browser) SDKs.
- public/assets: static images.
- Config files: next.config.ts, postcss.config.mjs, eslint.config.mjs, tsconfig.json.

##### Extract architecture insights from README
- Frontend: React + Next.js + Tailwind CSS
- Backend: Next.js serverless API routes running Node.js
- Database: Supabase (PostgreSQL) accessed via RLS, temporary storage of resume data
- AI Engine: Google Gemini Flash 1.5 external API
- Deployment: Vercel (serverless functions + CDN)

##### Main components
a. User’s Browser (Client)
b. Next.js Frontend (React pages & client components)
c. Next.js Server (Serverless Functions):
- compile-pdf-online route
- generate route
d. Supabase Database (PostgreSQL) + RLS policies
e. Supabase Admin & Client SDK layers
f. Google Gemini Flash 1.5 AI API
g. LaTeX Compiler (built into serverless function runtime)
h. Overleaf (external link/integration)
i. Deployment Platform: Vercel

##### Relationships & data flows
1) User inputs resume content via Next.js Form component.
2) Frontend posts to /api/generate →
- Next.js function uses Gemini API key to call Google Gemini.
- Receives enhanced content/LaTeX source.
- Optionally stores raw input + generated LaTeX in Supabase via Admin SDK.
3) Frontend invokes /api/compile-pdf-online →
- Takes LaTeX, compiles to PDF in the serverless environment.
- Stores PDF blob temporarily (e.g., Supabase Storage or in-memory).
4) Next.js returns download URL or PDF stream to client.
5) Client displays PDF and “Edit in Overleaf” link pointing to externally hosted Overleaf project.
6) Supabase enforces RLS to ensure data expires after 24h, no persistent user accounts.

##### Architectural patterns and design principles
- Monolithic Next.js app with clear separation:
- Frontend (React + client components)
- Backend (API routes = serverless functions)
- Server-side rendering / client-side hydration hybrid.
- “Backend-for-Frontend” pattern: API routes tailor responses to the UI needs.
- External service integration: Google Gemini and Overleaf.
- Data layer abstraction: src/lib/supabase-admin.ts (server) vs. src/lib/supabase-client.ts (client).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        UB["User Browser"]:::client
        subgraph "Next.js Frontend"
            HP["Home Page"]:::frontend
            BEP["Build Entry Page"]:::frontend
            RB["Resume Builder Component"]:::frontend
            FORM["Form Component"]:::frontend
            TS["Template Selector"]:::frontend
            LS["Loading Screen"]:::frontend
            RP["Result / PDF Display Page"]:::frontend
        end
    end

    %% Server Layer
    subgraph "Server Layer"
        subgraph "Next.js Serverless Functions"
            GEN["Next.js /api/generate"]:::backend
            CMP["Next.js /api/compile-pdf-online"]:::backend
        end
        LATEX["LaTeX Compiler Module"]:::compute
        SASDK["Supabase Admin SDK"]:::storage
    end

    %% External Services
    subgraph "External Services"
        GEM["Google Gemini Flash 1.5 API"]:::external
        DB["Supabase PostgreSQL"]:::storage
        OVL["Overleaf"]:::external
    end

    %% Data Flows
    UB -->|"navigates to"| HP
    HP -->|"click Build Resume"| BEP
    BEP -->|"loads builder"| RB
    RB -->|"renders form"| FORM
    RB -->|"renders templates"| TS
    FORM -->|"submit resume JSON"| GEN
    GEN -->|"call AI API"| GEM
    GEM -->|"returns LaTeX source"| GEN
    GEN -->|"store raw & LaTeX"| SASDK
    SASDK -->|"writes data"| DB
    GEN -->|"respond LaTeX"| RB
    RB -->|"request compile"| CMP
    CMP -->|"invoke compiler"| LATEX
    LATEX -->|"PDF blob"| CMP
    CMP -->|"return PDF stream"| RP
    RP -->|"display PDF"| UB
    RP -->|"Edit in Overleaf"| OVL

    %% Click Events
    click HP "https://github.com/justintimejt/crackdresume/blob/main/src/app/page.tsx"
    click BEP "https://github.com/justintimejt/crackdresume/blob/main/src/app/build/page.tsx"
    click RB "https://github.com/justintimejt/crackdresume/blob/main/src/app/build/resumebuilder.tsx"
    click FORM "https://github.com/justintimejt/crackdresume/blob/main/src/app/components/Form.tsx"
    click TS "https://github.com/justintimejt/crackdresume/blob/main/src/app/components/TemplateSelector.tsx"
    click LS "https://github.com/justintimejt/crackdresume/blob/main/src/app/components/LoadScreen.tsx"
    click RP "https://github.com/justintimejt/crackdresume/blob/main/src/app/result/page.tsx"
    click GEN "https://github.com/justintimejt/crackdresume/blob/main/src/app/api/generate/route.ts"
    click CMP "https://github.com/justintimejt/crackdresume/blob/main/src/app/api/compile-pdf-online/route.ts"
    click SASDK "https://github.com/justintimejt/crackdresume/blob/main/src/lib/supabase-admin.ts"

    %% Styles
    classDef client fill:#E3F2FD,stroke:#2196F3,stroke-width:1px
    classDef frontend fill:#BBDEFB,stroke:#1E88E5,stroke-width:1px
    classDef backend fill:#FFE0B2,stroke:#FB8C00,stroke-width:1px
    classDef compute fill:#FFCCBC,stroke:#D84315,stroke-width:1px
    classDef storage fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px
    classDef external fill:#C8E6C9,stroke:#43A047,stroke-width:1px
```
