# felipesanma/pdf-comparison architecture

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

- Interactive diagram: https://gitdiagram.com/felipesanma/pdf-comparison
- Repository: https://github.com/felipesanma/pdf-comparison

## Overview

##### Project type and purpose
- This is a Python-based service (“pdf-comparison”) whose goal is to compare two PDF documents using a Large Language Model (LLM).
- The README and file names (app.py, lang_utils.py) indicate a single‐service application that:
- Accepts or ingests PDF files
- Extracts text from them
- Forwards text (or embeddings) to an LLM provider
- Computes and returns a comparison/diff to the caller

##### File structure
- .env – environment variables (e.g., LLM API key, configuration)
- requirements.txt – Python dependencies (e.g., pdf parser library, OpenAI or other LLM SDK, web framework)
- app.py – main application entrypoint, likely exposes a REST or CLI interface
- lang_utils.py – library module for text extraction, chunking, prompting the LLM, and result post-processing

##### README for additional insights
– The “Arquitecture” section references pdf‐comparison-arq.png. Although we can’t see it here, it likely shows:
- An ingress point (user/client)
- A PDF parsing component
- LLM API callouts
- A comparison engine
- A response payload

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    ClientUI["Client/User Interface"]:::external
    AppServer["Application Server (app.py)"]:::internal
    Config["Configuration Store (.env)"]:::config
    subgraph "pdf-comparison Service"
        PDFProcessing["PDF Processing Module"]:::internal
        LLMIntegration["LLM Integration Layer"]:::internal
        ComparisonEngine["Comparison Engine"]:::internal
    end
    ExternalLLMAPI["External LLM API"]:::external

    %% Connections
    ClientUI -->|"upload PDF (HTTP/REST, multipart/form-data)"| AppServer
    Config -->|"injects env vars"| AppServer
    AppServer -->|"extract text"| PDFProcessing
    PDFProcessing -->|"text chunks"| LLMIntegration
    LLMIntegration -->|"LLM request (JSON)"| ExternalLLMAPI
    ExternalLLMAPI -->|"LLM response (JSON)"| LLMIntegration
    LLMIntegration -->|"semantic output"| ComparisonEngine
    ComparisonEngine -->|"diff report"| AppServer
    AppServer -->|"comparison report (JSON)"| ClientUI

    %% Click Events
    click ClientUI "https://github.com/felipesanma/pdf-comparison/blob/main/app.py"
    click AppServer "https://github.com/felipesanma/pdf-comparison/blob/main/app.py"
    click PDFProcessing "https://github.com/felipesanma/pdf-comparison/blob/main/lang_utils.py"
    click LLMIntegration "https://github.com/felipesanma/pdf-comparison/blob/main/lang_utils.py"
    click ComparisonEngine "https://github.com/felipesanma/pdf-comparison/blob/main/lang_utils.py"
    click Config "https://github.com/felipesanma/pdf-comparison/blob/main/.env"

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#90EE90,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
```
