# srivinaya/json-to-latex architecture

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

- Interactive diagram: https://gitdiagram.com/srivinaya/json-to-latex
- Repository: https://github.com/srivinaya/json-to-latex

## Overview

##### Main Components Involved with main.py
- FastAPI Server (main.py) – This is the entry point for your backend API.
- API Endpoints – As detailed in the README, endpoints such as /process_application, /customize_resume, /download_pdf, /view_pdf, /view_latex, and /health.
- PDF Generation Module – Represent the pdf_generator submodule (including generate_pdf.py, json_to_pdf.py, constants, and LaTeX template management) that main.py calls to return professional PDFs.
- External Services/Dependencies:
- DeepSeek AI – Used for processing resume and job description data.
- LaTeX – The external dependency (installed separately) that is used to generate the final PDF from a TeX template.
- Environment Variables – The .env file holds secrets (e.g., DEEPSEEK_API_KEY) that main.py utilizes for secure access to external services.

a. Central Block – Main.py as the FastAPI application server:
c. Integration with PDF Generation:
- Inside this module, indicate that main.py leverages functions (like generate_pdf and json_to_pdf) to produce the PDF output.
d. Communication with External Services:
- Link from the PDF Generator Module to a “LaTeX Engine” block, indicating that LaTeX is used to compile templates (e.g., template.tex) into PDFs.
e. Environment Management:

##### Architectural Patterns and Design Principles
- The separation of concerns is evident – main.py handles API routing while the pdf_generator module encapsulates PDF creation logic.
- Modularity of the system: the FastAPI server, PDF creation, and the external DeepSeek AI integration are clearly modularized.
- Users (or APIs) call endpoints in main.py.
- main.py orchestrates calls to the PDF module and external AI services.
- Results flow back through main.py to the client.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% API Endpoints Subgraph (Top)
    subgraph "API Endpoints"
        EP1["POST /process_application"]:::endpoint
        EP2["POST /customize_resume"]:::endpoint
        EP3["GET /download_pdf"]:::endpoint
        EP4["GET /view_pdf"]:::endpoint
        EP5["GET /view_latex"]:::endpoint
        EP6["GET /health"]:::endpoint
    end

    %% Central FastAPI Server Node
    M["FastAPI Server (main.py)"]:::api

    %% Connect API Endpoints to FastAPI Server
    EP1 -->|"calls"| M
    EP2 -->|"calls"| M
    EP3 -->|"calls"| M
    EP4 -->|"calls"| M
    EP5 -->|"calls"| M
    EP6 -->|"calls"| M

    %% PDF Generation Module Subgraph (Left Branch)
    subgraph "PDF Generation Module"
        PD1["generate_pdf.py"]:::module
        PD2["json_to_pdf.py"]:::module
        PD3["constants.py"]:::module
        PD4["LaTeX Template (template.tex)"]:::module
    end

    %% External DeepSeek AI Service (Center-Bottom)
    DS["DeepSeek AI – Resume Parsing"]:::external

    %% Environment Variables Node (Right Branch)
    ENV[".env (Environment Variables)"]:::config

    %% LaTeX Engine Node (Below PDF Module)
    LA["LaTeX Engine – PDF Compilation"]:::external

    %% Connections from FastAPI Server
    M -->|"calls_PDF_functions"| PD1
    M -->|"processes_resume_data"| DS
    M -->|"retrieves_API_Key"| ENV

    %% Connection from PDF Module to LaTeX Engine
    PD4 -->|"compiles_template"| LA

    %% Click Events
    click M "https://github.com/srivinaya/json-to-latex/blob/main/backend/main.py"
    click ENV "https://github.com/srivinaya/json-to-latex/blob/main/backend/.env"
    click PD1 "https://github.com/srivinaya/json-to-latex/blob/main/backend/pdf_generator/generate_pdf.py"
    click PD2 "https://github.com/srivinaya/json-to-latex/blob/main/backend/pdf_generator/json_to_pdf.py"
    click PD3 "https://github.com/srivinaya/json-to-latex/blob/main/backend/pdf_generator/constants.py"
    click PD4 "https://github.com/srivinaya/json-to-latex/blob/main/backend/pdf_generator/templates/template.tex"
    click EP1 "https://github.com/srivinaya/json-to-latex/blob/main/backend/main.py"
    click EP2 "https://github.com/srivinaya/json-to-latex/blob/main/backend/main.py"
    click EP3 "https://github.com/srivinaya/json-to-latex/blob/main/backend/main.py"
    click EP4 "https://github.com/srivinaya/json-to-latex/blob/main/backend/main.py"
    click EP5 "https://github.com/srivinaya/json-to-latex/blob/main/backend/main.py"
    click EP6 "https://github.com/srivinaya/json-to-latex/blob/main/backend/main.py"

    %% Styles
    classDef api fill:#E0F7FA,stroke:#00796B,stroke-width:2px;
    classDef endpoint fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef module fill:#FFECB3,stroke:#FBC02D,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef config fill:#E0E0E0,stroke:#757575,stroke-width:2px;
```
