# jeff14994/summary-llm architecture

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

- Interactive diagram: https://gitdiagram.com/jeff14994/summary-llm
- Repository: https://github.com/jeff14994/summary-llm

## Overview

##### Main Components
- Summarizer Module: The core logic is encapsulated in several modules:
- html_extractor.py: Handles fetching and parsing HTML content.
- prompt_builder.py: Constructs prompts for the LLM.
- local_llm.py: Interfaces with the local Ollama LLM for inference.
- output_formatter.py: Formats the LLM output into structured JSON summaries.
- Main Application Layers:
- CLI-based main execution via main.py (and main1.py, if applicable).
- API Server via api_server.py: Provides REST endpoints for summarization, including health checks and Swagger documentation.
- Configuration and Environment:
- The .env file holds key configuration parameters (e.g., LLM model, timeouts, output directories).
- Testing Suite: The tests directory includes unit tests for each major component.
- Deployment Infrastructure: Docker support is provided, meaning you have a Dockerfile and instructions to containerize the app.

##### Out Relationships and Interactions
- Data Flow:
- For CLI usage: The user provides a URL to main.py → html_extractor fetches HTML → prompt_builder constructs a prompt → local_llm generates summaries → output_formatter creates the final JSON output.
- For API usage: A POST to /summarize on the REST API triggers a similar flow, where api_server.py orchestrates the call to the summarizer module.
- External Dependencies:
- The project depends on the local Ollama runtime for LLM inference.
- Docker serves as a containerization technology for deployment.

##### Architectural Patterns & Design Principles
- Modularity: Clear separation of concerns among the modules (extractor, builder, inference, and formatter).
- API Layer: The REST API server abstracts the summarization service for external integrations.
- Configurability: Environment variables (.env) allow the behavior of the summarizer to be customized.
- Testing: The test suite ensures component reliability.

##### Relevant Technologies
- Python 3.9+ for coding.
- Docker for containerization.
- Ollama for local LLM inference.
- REST API documentation tools (Swagger, ReDoc) available in the API server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Docker Container"]:::docker
    A --> B["User Interfaces"]:::interface

    subgraph "User Interfaces"
        B1["CLI Entry Points"]
        C["main.py"]:::cli
        C2["main1.py"]:::cli
        B1 --> C
        B1 --> C2
        B2["API Server (/summarize, /health, /docs, /redoc)"]:::api
    end

    %% Both CLI and API trigger the summarization pipeline
    B --> D["HTML Extractor"]:::module
    D --> E["Prompt Builder"]:::module
    E --> F["Local LLM"]:::module
    F --> G["Output Formatter"]:::module
    G --> H["JSON Summary Output"]:::module

    %% Configuration node
    O[".env Configuration"]:::config
    O --- D

    %% External dependency: Ollama Runtime
    R["Ollama Runtime"]:::external
    R --- F

    %% Testing Suite subgraph
    subgraph "Tests Suite"
        T1["Test HTML Extractor"]:::testing
        T2["Test Prompt Builder"]:::testing
        T3["Test Local LLM"]:::testing
        T4["Test Output Formatter"]:::testing
        T5["Test Parser"]:::testing
        T6["Test LLM"]:::testing
    end
    H --> I["Validation & Tests"]:::testing
    I --- T1
    I --- T2
    I --- T3
    I --- T4
    I --- T5
    I --- T6

    %% Click Events
    click D "https://github.com/jeff14994/summary-llm/blob/main/summarizer/html_extractor.py"
    click E "https://github.com/jeff14994/summary-llm/blob/main/summarizer/prompt_builder.py"
    click F "https://github.com/jeff14994/summary-llm/blob/main/summarizer/local_llm.py"
    click G "https://github.com/jeff14994/summary-llm/blob/main/summarizer/output_formatter.py"
    click C "https://github.com/jeff14994/summary-llm/blob/main/main.py"
    click C2 "https://github.com/jeff14994/summary-llm/blob/main/main1.py"
    click B2 "https://github.com/jeff14994/summary-llm/blob/main/api_server.py"
    click O "https://github.com/jeff14994/summary-llm/blob/main/.env"
    click T1 "https://github.com/jeff14994/summary-llm/blob/main/tests/test_html_extractor.py"
    click T2 "https://github.com/jeff14994/summary-llm/blob/main/tests/test_prompt_builder.py"
    click T3 "https://github.com/jeff14994/summary-llm/blob/main/tests/test_local_llm.py"
    click T4 "https://github.com/jeff14994/summary-llm/blob/main/tests/test_output_formatter.py"
    click T5 "https://github.com/jeff14994/summary-llm/blob/main/tests/test_parser.py"
    click T6 "https://github.com/jeff14994/summary-llm/blob/main/tests/test_llm.py"

    %% Style Definitions
    classDef docker fill:#D1C4E9,stroke:#000,stroke-width:2px;
    classDef interface fill:#FFDAB9,stroke:#000,stroke-width:2px;
    classDef cli fill:#CCE5FF,stroke:#000,stroke-width:2px;
    classDef api fill:#D1E7DD,stroke:#000,stroke-width:2px;
    classDef module fill:#FFF3CD,stroke:#000,stroke-width:2px;
    classDef config fill:#E2E3E5,stroke:#000,stroke-width:2px;
    classDef external fill:#B3E5FC,stroke:#000,stroke-width:2px;
    classDef testing fill:#F8D7DA,stroke:#000,stroke-width:2px;
```
