# wesslen/llm-evaluation-framework architecture

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

- Interactive diagram: https://gitdiagram.com/wesslen/llm-evaluation-framework
- Repository: https://github.com/wesslen/llm-evaluation-framework

## Overview

##### Main Components
- GitHub Actions & CI/CD Pipeline: Represent the workflows in .github/workflows (e.g., run_tests.yml and functional_tests.yml) that trigger the automated tests, database updates, and ultimately commit the new test results back to the repository.
- Test Suite: Include the suite of tests located in the tests directory (e.g., test_summarization.py, test_reasoning.py, etc.) that simulate different evaluation scenarios.
- Core Application (src): Break down the internal modules:
- Configuration (config.py) for environment and global settings.
- llm_client.py for interfacing with the LLM (sending prompts and receiving outputs).
- metrics.py and test_aggregator.py for processing and summarizing test results.
- database.py for abstraction of database operations.
- Database Layer: This comprises the SQLite database (llm_evaluation.db) under the database/ directory, including initialization (init_db.py) and migration scripts (migrations/001_initial_schema.sql). This is where all test results are persisted.
- Datasette Integration: Represent the datasette.yaml configuration and the Datasette server used for local development and exploration. This component exposes endpoints (JSON API, web interface) that let users query the evolving test results.

##### Relationships and Data Flows
- GitHub Actions trigger the test suite, which in turn runs the evaluation logic (invoking the LLM via llm_client.py) and aggregating results (using metrics.py and test_aggregator.py).

##### Important Architectural Patterns
- Separation of concerns: The design clearly separates testing logic, LLM interaction, metrics processing, and database operations.
- Version-controlled data store: The SQLite database is not only used as the runtime store but is kept under version control to preserve historical test runs.
- Automated CI/CD loops: GitHub Actions workflows ensure that test execution, result recording, and database updates happen automatically.

##### Relevant Technologies and Frameworks
- Python 3.9+ (used for the main code in src/ and for test execution).
- GitHub Actions for CI/CD.
- SQLite for persistent storage.
- Datasette for serving and querying the evaluation database.
- Pytest (implied by the tests and usage instructions in the README).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Continuous Integration Layer
    subgraph "Continuous Integration"
        GA["GitHub Actions & CI/CD Pipeline"]:::ci
    end

    %% Testing Layer
    subgraph "Test Execution"
        TS["Test Suite (pytest)"]:::test
    end

    GA -->|"triggers"| TS

    %% Core Application Layer
    subgraph "Core Application"
        CFG["Configuration"]:::core
        LLM["LLM Client"]:::core
        MET["Metrics Processing"]:::core
        AGG["Test Aggregator"]:::core
    end

    %% Connections from Test Suite to Core Application modules
    TS -->|"executes"| CFG
    TS -->|"executes"| LLM
    TS -->|"executes"| MET
    TS -->|"executes"| AGG

    %% Internal Core Application Data Flow
    CFG -->|"loads env"| LLM
    LLM -->|"processes prompts"| MET
    AGG -->|"aggregates results"| MET

    %% Database Layer
    subgraph "Database Layer"
        DBINIT["DB Initialization"]:::db
        DBFILE["SQLite Database"]:::db
        MIG["Migration Script"]:::db
    end

    %% Core Application writes to Database Layer
    MET -->|"writes results"| DBINIT
    AGG -->|"writes results"| DBINIT
    LLM -->|"logs interactions"| DBFILE

    DBINIT -->|"updates"| DBFILE
    MIG -->|"applies schema"| DBFILE

    %% External Systems Layer
    subgraph "External Systems"
        DS["Datasette"]:::external
        REPO["Git Repository"]:::external
    end

    DBFILE -->|"serves data"| DS
    DBFILE -->|"commits updates"| REPO

    %% Click Events
    click GA "https://github.com/wesslen/llm-evaluation-framework/tree/main/.github/workflows"
    click TS "https://github.com/wesslen/llm-evaluation-framework/tree/main/tests"
    click CFG "https://github.com/wesslen/llm-evaluation-framework/blob/main/src/config.py"
    click LLM "https://github.com/wesslen/llm-evaluation-framework/blob/main/src/llm_client.py"
    click MET "https://github.com/wesslen/llm-evaluation-framework/blob/main/src/metrics.py"
    click AGG "https://github.com/wesslen/llm-evaluation-framework/blob/main/src/test_aggregator.py"
    click DBINIT "https://github.com/wesslen/llm-evaluation-framework/blob/main/database/init_db.py"
    click DBFILE "https://github.com/wesslen/llm-evaluation-framework/blob/main/database/llm_evaluation.db"
    click MIG "https://github.com/wesslen/llm-evaluation-framework/blob/main/database/migrations/001_initial_schema.sql"
    click DS "https://github.com/wesslen/llm-evaluation-framework/blob/main/datasette.yaml"

    %% Styles
    classDef ci fill:#a0d3a0,stroke:#333,stroke-width:2px;
    classDef test fill:#f9d5bb,stroke:#333,stroke-width:2px;
    classDef core fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef db fill:#ffe4b5,stroke:#333,stroke-width:2px;
    classDef external fill:#ffb6c1,stroke:#333,stroke-width:2px;
```
