# diegopluna/vitaes architecture

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

- Interactive diagram: https://gitdiagram.com/diegopluna/vitaes
- Repository: https://github.com/diegopluna/vitaes

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (app directory structure)
- UI Components (components directory)
- State Management (store directory)

b) API Layer:
- Authentication endpoints (app/api/auth)
- PDF generation endpoints (app/api/pdf)
- File upload handling (app/api/uploadthing)

c) Database Layer:
- Neon PostgreSQL Database
- Drizzle ORM integration

##### Key Architectural Elements to Highlight

Frontend:
- Main UI Routes (/dashboard, /builder, /cv_only)
- Template System (components/cv/templates)
- Form Components (components/cv/form)
- Shared Components (components/ui)

Backend:
- Authentication System (Auth.js)
- PDF Generation Service (Puppeteer)
- File Upload Service (UploadThing)
- Database Operations (Drizzle ORM)

##### Flow Representations

- User authentication flow
- Resume creation and editing flow
- PDF generation and export flow
- Data persistence flow

##### Specific Implementation Details

a) Frontend Architecture:
- Next.js 13+ App Router structure
- Component hierarchy (templates, forms, UI elements)
- State management with stores

b) Backend Services:
- API route handlers
- Authentication flow with Github
- PDF generation pipeline
- File upload handling

c) Data Flow:
- User session management
- Resume data persistence
- Template rendering
- Export operations

##### Integration Points

Connections with:
- Github OAuth
- Neon Database
- UploadThing service
- Vercel deployment

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        FE[Frontend Core]
        UI[UI Components]
        STATE[State Management]
        
        subgraph Routes["Application Routes"]
            DASH["Dashboard"]
            BUILD["CV Builder"]
            CVO["CV Only View"]
        end

        subgraph Components["Component System"]
            TEMP["Template System"]
            FORM["Form System"]
            SHARED["Shared Components"]
        end
    end

    subgraph API["API Layer"]
        AUTH["Authentication API"]
        PDF["PDF Generation"]
        UPLOAD["File Upload Service"]
    end

    subgraph Data["Data Layer"]
        DB[(Neon PostgreSQL)]
        DRIZZLE["Drizzle ORM"]
        SCHEMA["Database Schema"]
    end

    subgraph External["External Services"]
        GITHUB["GitHub OAuth"]
        UPTH["UploadThing"]
        VERCEL["Vercel Deploy"]
    end

    %% Relationships
    FE --> Routes
    FE --> Components
    STATE --> FE
    UI --> FE
    
    FORM --> PDF
    TEMP --> PDF
    
    AUTH --> GITHUB
    UPLOAD --> UPTH
    
    DRIZZLE --> DB
    SCHEMA --> DRIZZLE
    
    API --> Data
    Client --> API

    %% Click Events
    click FE "https://github.com/diegopluna/vitaes/tree/main/app/(ui)"
    click BUILD "https://github.com/diegopluna/vitaes/tree/main/app/(ui)/builder"
    click DASH "https://github.com/diegopluna/vitaes/tree/main/app/(ui)/dashboard"
    click TEMP "https://github.com/diegopluna/vitaes/tree/main/components/cv/templates"
    click FORM "https://github.com/diegopluna/vitaes/tree/main/components/cv/form"
    click AUTH "https://github.com/diegopluna/vitaes/blob/main/app/api/auth/[...nextauth]"
    click PDF "https://github.com/diegopluna/vitaes/blob/main/app/api/pdf/route.ts"
    click UPLOAD "https://github.com/diegopluna/vitaes/tree/main/app/api/uploadthing"
    click DRIZZLE "https://github.com/diegopluna/vitaes/blob/main/db/drizzle.ts"
    click SCHEMA "https://github.com/diegopluna/vitaes/blob/main/db/schema.ts"
    click STATE "https://github.com/diegopluna/vitaes/blob/main/store/use-modal-store.ts"
    click UI "https://github.com/diegopluna/vitaes/tree/main/components/ui"
    click SHARED "https://github.com/diegopluna/vitaes/tree/main/components/navbar"

    %% Styling
    classDef frontend fill:#3b82f6,color:white
    classDef api fill:#22c55e,color:white
    classDef external fill:#eab308,color:white
    classDef database fill:#a855f7,color:white
    classDef pdf fill:#ef4444,color:white

    class FE,UI,STATE,Routes,Components,DASH,BUILD,CVO,TEMP,FORM,SHARED frontend
    class AUTH,PDF,UPLOAD api
    class GITHUB,UPTH,VERCEL external
    class DB,DRIZZLE,SCHEMA database
    class PDF pdf

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        A[API Services]:::api
        E[External Services]:::external
        D[Database]:::database
        P[PDF Generation]:::pdf
    end
```
