# rnwl/ml-pdf-splitter architecture

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

- Interactive diagram: https://gitdiagram.com/rnwl/ml-pdf-splitter
- Repository: https://github.com/rnwl/ml-pdf-splitter

## Overview

Below are detailed guidelines and instructions for capturing the architecture:

- ML PDF Splitter Service (Containerized App)
- This as the primary processing component. It hosts your core logic (see files in the src directory such as api.py, pdf2text.py, timed_logger.py, and utils.py) that handles the PDF splitting and parallel orchestration.
- That it is deployed on Azure Container Apps.
- PDF Extraction Azure Function
- This as a separate, external service that performs the extraction of text from each PDF chunk.
- That it is deployed on Azure Functions and is invoked by the splitter app.
- Data Store/File Repository (optional)
- Depending on whether the incoming PDFs are stored or managed as files within a repository (as hinted by the data directory), include a component that represents input (and possibly output) file storage.
- Deployment and CI/CD
- Components for CI/CD pipelines using GitHub workflows (see .github/workflows) and deployment scripts/configurations (Dockerfile, docker-compose.yml, Pipfile files).

##### Relationships and Interactions
- Client / User Request:
- If applicable, include an entry point or client that triggers the application – this could be shown as a user uploading PDF files, which then get routed to the ML PDF Splitter container.
- Communication Flow:
- Data Flow:
- If there’s intermediate storage involved (e.g., for storing chunks or logging results), represent this connection.

##### Architectural Patterns and Technologies
- Containerization & Cloud Deployment:
- That the app is containerized (as indicated by the Dockerfile and docker-compose configuration) and deployed on Azure Container Apps.
- Separation between the processing layer (Container App) and the function layer (Azure Functions).
- Parallel Processing:
- Design principle of making parallel asynchronous calls to the Azure Function, enabling rapid PDF decoding.
- Logging and Monitoring:
- Optionally, include a component for logging (referenced by timed_logger.py) to capture and monitor application behavior.
- Development and Operations:
- That the CI/CD process is handled via GitHub workflows, ensuring updates and deployments are continuously integrated and delivered.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "User Interaction"
        user["User/Client"]:::client
    end

    subgraph "Core Services"
        ml_pdf_splitter["ML PDF Splitter Service (Azure Container Apps)"]:::container
        pdf_extraction["PDF Extraction Azure Function (Azure Functions)"]:::function
        data_store["Data Store/File Repository"]:::datastore
    end

    subgraph "DevOps"
        deployment["Deployment & CI/CD"]:::deployment
    end

    user -->|"uploadPDF"| ml_pdf_splitter
    ml_pdf_splitter -->|"parallelCalls"| pdf_extraction
    ml_pdf_splitter -->|"storePDFs"| data_store
    deployment -->|"deploys"| ml_pdf_splitter

    %% Click Events for ML PDF Splitter Service components
    click ml_pdf_splitter "https://github.com/rnwl/ml-pdf-splitter/tree/main/src/"
    click ml_pdf_splitter "https://github.com/rnwl/ml-pdf-splitter/tree/main/Dockerfile"
    click ml_pdf_splitter "https://github.com/rnwl/ml-pdf-splitter/blob/main/docker-compose.yml"
    
    %% Click Events for Data Store/File Repository
    click data_store "https://github.com/rnwl/ml-pdf-splitter/tree/main/data/"

    %% Click Events for Deployment & CI/CD components
    click deployment "https://github.com/rnwl/ml-pdf-splitter/tree/main/.github/workflows/"
    click deployment "https://github.com/rnwl/ml-pdf-splitter/tree/main/Pipfile"
    click deployment "https://github.com/rnwl/ml-pdf-splitter/blob/main/docker-compose.yml"
    click deployment "https://github.com/rnwl/ml-pdf-splitter/tree/main/Dockerfile"

    %% Styles
    classDef client fill:#f4f4f4,stroke:#333,stroke-width:2px;
    classDef container fill:#c2f0c2,stroke:#2e8540,stroke-width:2px;
    classDef function fill:#c2d9f0,stroke:#2e5e85,stroke-width:2px;
    classDef datastore fill:#f0d9c2,stroke:#854e2e,stroke-width:2px;
    classDef deployment fill:#e3c2f0,stroke:#853e7e,stroke-width:2px;
```
