# pavelihno/smart-resume architecture

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

- Interactive diagram: https://gitdiagram.com/pavelihno/smart-resume
- Repository: https://github.com/pavelihno/smart-resume

## Overview

##### Project type and purpose
- Smart Resume is a containerized, full-stack résumé + cover-letter builder.
- Front end: React SPA served by Nginx (or dev server).
- Back end: Express.js API that talks to MongoDB and renders LaTeX templates.
- Database: MongoDB (with optional mongo-express UI).
- PDF engine: either in-container LaTeX compilation or external `.tex` download.

##### File structure
- Top-level: `.env`, `docker-compose.yml`, `db/`, `client/`, `server/`.
- client/: React source (`src/`), build configurations, Dockerfiles, Nginx config.
- server/: Express entrypoints (`app.js`, `server.js`), MVC directories (controllers, models, routes), static LaTeX templates, utility libs (errors, latex).
- db/: MongoDB initialization script.

##### README
- Describes Docker-first workflow and two PDF modes (local vs external).
- Shows how environment variables drive which Dockerfiles get used.
- Mentions ports: client on 80 or 3000, API on 8080.

##### Main components & interactions
a. Client container
- React SPA + JS code calls `api.js` → Express server.
- Served via Nginx (production) or React dev server (development).
b. Server container
- Exposes REST endpoints (`/profiles`, `/projects`, `/coverLetters`, etc.).
- Uses controllers → models → MongoDB.
- On export: reads LaTeX templates from `server/static/templates`, merges with data, and either:
- Runs `node-latex` locally → PDF
- Skips compilation → returns `.tex`
c. MongoDB container
- Primary data store for user profiles, projects, work experience, etc.
- Initialized by `db/mongo-init.js` for user/roles.
d. (Optional) mongo-express container
- UI for browsing/editing the DB.

e. Docker Compose
- Defines and links: react/nginx, express, mongo, (mongo-express).
- Shared `.env` mounts into each container.

##### Architectural patterns & design principles
- Separation of concerns:
- Front end (presentation) vs API (business logic) vs Database (persistence).
- MVC in the server: routes → controllers → models.
- Containerized microservices style: each major tier in its own container.
- Environment-driven builds: `NODE_ENV` and `REACT_APP_PDF_GENERATION_MODE` select Dockerfiles.

##### Detailed elements
- Labels for each container (“React Client”, “Express API”, “MongoDB”).
- Port mappings (Client: 80/3000, API: 8080).
- Directories only if needed: e.g. inside Express, call out `controllers/`, `models/`, `static/templates`.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Docker Compose Layer
    subgraph "Docker Compose Network" 
        direction TB
        Env[".env (shared)"]:::config
        subgraph "React Client Container" 
            direction TB
            ClientIndex["src/index.js"]:::frontend
            ClientAPI["src/api.js"]:::frontend
            NginxConf["nginx.conf"]:::config
            DockerDevClient["Dockerfile.development"]:::config
            DockerProdClient["Dockerfile.production"]:::config
        end
        subgraph "Express API Container" 
            direction TB
            ServerJS["server.js"]:::backend
            AppJS["app.js"]:::backend
            subgraph "MVC & Utils"
                direction TB
                Controllers["controllers/"]:::backend
                Routes["routes/"]:::backend
                Models["models/"]:::backend
                LatexUtil["utils/latex.js"]:::backend
                ErrorUtil["utils/errors.js"]:::backend
            end
            subgraph "Static Templates"
                direction TB
                ResumeTex["templates/resume/default.tex"]:::backend
                LetterTex["templates/letter/default.tex"]:::backend
            end
            subgraph "Dockerfiles" 
                direction TB
                DevLocal["Dockerfile.local.development"]:::config
                ProdLocal["Dockerfile.local.production"]:::config
                DevExt["Dockerfile.external.development"]:::config
                ProdExt["Dockerfile.external.production"]:::config
            end
        end
        MongoDB["MongoDB"]:::database
        InitScript["mongo-init.js"]:::config
        subgraph "mongo-express (optional)" 
            direction TB
            MEUI["mongo-express UI"]:::database
        end
    end

    %% User flow
    User["User"]:::external
    User -->|"HTTP UI"| ClientIndex
    ClientIndex -->|"REST JSON (8080)"| ServerJS
    ServerJS -->|"MongoDB Driver"| MongoDB
    MongoDB --> InitScript
    ServerJS -->|"Read .tex"| ResumeTex
    ServerJS -->|"Read .tex"| LetterTex
    ResumeTex -->|"Compile (node-latex)"| PDF["PDF"]:::document
    LetterTex -->|"Skip compile → .tex"| TEXFILE[".tex"]:::document
    ServerJS -->|"Send PDF/.tex"| ClientIndex
    ServerJS --> MEUI
    Env --> ClientIndex
    Env --> ServerJS
    Env --> MongoDB
    Env -.-> MEUI

    %% Click Events
    click ClientIndex "https://github.com/pavelihno/smart-resume/blob/main/client/src/index.js"
    click ClientAPI "https://github.com/pavelihno/smart-resume/blob/main/client/src/api.js"
    click NginxConf "https://github.com/pavelihno/smart-resume/blob/main/client/nginx.conf"
    click DockerDevClient "https://github.com/pavelihno/smart-resume/blob/main/client/Dockerfile.development"
    click DockerProdClient "https://github.com/pavelihno/smart-resume/blob/main/client/Dockerfile.production"
    click ServerJS "https://github.com/pavelihno/smart-resume/blob/main/server/server.js"
    click AppJS "https://github.com/pavelihno/smart-resume/blob/main/server/app.js"
    click Controllers "https://github.com/pavelihno/smart-resume/tree/main/server/controllers/"
    click Routes "https://github.com/pavelihno/smart-resume/tree/main/server/routes/"
    click Models "https://github.com/pavelihno/smart-resume/tree/main/server/models/"
    click LatexUtil "https://github.com/pavelihno/smart-resume/blob/main/server/utils/latex.js"
    click ErrorUtil "https://github.com/pavelihno/smart-resume/blob/main/server/utils/errors.js"
    click ResumeTex "https://github.com/pavelihno/smart-resume/blob/main/server/static/templates/resume/default.tex"
    click LetterTex "https://github.com/pavelihno/smart-resume/blob/main/server/static/templates/letter/default.tex"
    click DevLocal "https://github.com/pavelihno/smart-resume/blob/main/server/Dockerfile.local.development"
    click ProdLocal "https://github.com/pavelihno/smart-resume/blob/main/server/Dockerfile.local.production"
    click DevExt "https://github.com/pavelihno/smart-resume/blob/main/server/Dockerfile.external.development"
    click ProdExt "https://github.com/pavelihno/smart-resume/blob/main/server/Dockerfile.external.production"
    click InitScript "https://github.com/pavelihno/smart-resume/blob/main/db/mongo-init.js"
    click Env "https://github.com/pavelihno/smart-resume/blob/main/.env.example"
    click Compose "https://github.com/pavelihno/smart-resume/blob/main/docker-compose.yml"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef database fill:#ffeeba,stroke:#856404,color:#856404
    classDef config fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef document fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef external fill:#ffffff,stroke:#000000
    class Compose,Env external
```
