# toumask/pdf_api architecture

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

- Interactive diagram: https://gitdiagram.com/toumask/pdf_api
- Repository: https://github.com/toumask/pdf_api

## Overview

##### Project Type Analysis
This is a specialized REST API service with a single focused purpose: PDF generation for cancellation letters. The project appears to be a lightweight, single-service application.

##### Key Components

a. External Interface Layer:
- REST API Endpoint (represented by an API Gateway symbol)
- HTTP Request/Response handlers

b. Core Service Layer:
- PDF Generation Service (centered around generate_pdf.py)
- Main Application Server (main.py)

c. Storage Layer:
- Generated PDF Storage (generated_pdf directory)

**[Client/External Systems]**
- ↓ HTTP
**[API Gateway/Endpoint]**
- ↓
**[Main Application Server]**
- ↓
**[PDF Generation Service]**
- ↓
**[PDF Storage]**

##### Specific Elements

- Rectangle: External clients
- Hexagon: API endpoint
- Rectangle with rounded corners: Core services

c. Labels:
- Input: JSON/Form data for cancellation details
- Output: PDF file path/download URL
- Process: PDF generation workflow

##### Additional Details

a. Technical Specifications:
- Python-based REST API (indicated by main.py)
- PDF generation library (from generate_pdf.py)
- File system storage

b. Process Flow:
1. Request reception
2. Data validation
3. PDF generation
4. Storage
5. Response delivery

##### Important Notes

- Keep the focus on the PDF generation workflow
- REST API nature of the service
- Clear separation between the API handling and PDF generation logic
- Where generated files are stored

##### Deployment Context (Optional)
Since there's a Procfile present, include a small section showing:
- Heroku deployment
- Web server configuration

Remember to include any specific requirements or constraints mentioned in the requirements.txt file that might affect the architecture (e.g., specific PDF generation libraries or web frameworks).

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Layer
    Client(["External Client"]):::external

    %% API Layer
    subgraph API
        APIEndpoint[["REST API Endpoint"]]:::api
        MainServer["Main Application Server"]:::server
    end

    %% Core Service Layer
    subgraph Service
        PDFGen["PDF Generation Service"]:::service
        Validation["Data Validation"]:::service
    end

    %% Storage Layer
    subgraph Storage
        PDFStore[("Generated PDF Storage")]:::storage
    end

    %% Deployment
    subgraph Deployment
        Heroku["Heroku Platform"]:::deployment
    end

    %% Connections
    Client -->|HTTP Request| APIEndpoint
    APIEndpoint -->|Forward Request| MainServer
    MainServer -->|Validate Data| Validation
    Validation -->|Generate PDF| PDFGen
    PDFGen -->|Store PDF| PDFStore
    PDFStore -.->|Return PDF URL| MainServer
    MainServer -.->|HTTP Response| Client
    Heroku ---|Hosts| MainServer

    %% Click Events
    click MainServer "https://github.com/Toumask/pdf_api/blob/main/main.py"
    click PDFGen "https://github.com/Toumask/pdf_api/blob/main/generate_pdf.py"
    click PDFStore "https://github.com/Toumask/pdf_api/tree/main/generated_pdf/"
    click Heroku "https://github.com/Toumask/pdf_api/tree/main/Procfile"

    %% Styles
    classDef external fill:#68B587,stroke:#333,stroke-width:2px
    classDef api fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px
    classDef service fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef storage fill:#DEB887,stroke:#333,stroke-width:2px
    classDef deployment fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1(["External System"]):::external
        L2[["API Component"]]:::api
        L3["Service Component"]:::service
        L4[("Storage")]:::storage
        L5["Deployment"]:::deployment
    end
```
