# qodo-ai/qodo-cover architecture

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

- Interactive diagram: https://gitdiagram.com/qodo-ai/qodo-cover
- Repository: https://github.com/qodo-ai/qodo-cover

## Overview

##### Project Identification
- Project Type & Purpose: Qodo-Cover is an automated unit test generation tool that uses Generative AI (via an LLM) to increase code coverage. It is distributed as both a CLI tool and a Pip package, and it integrates into CI/CD pipelines (e.g., GitHub Actions) for development workflows.
- Key Functionality: Generating tests, validating code coverage, running tests and parsing coverage reports, and interfacing with different programming language test templates as seen in the templated_tests folder.

##### Analyzing the File Structure
- The root level includes configuration files (Dockerfile, Makefile, pyproject.toml), CI workflows (.github/workflows), and documentation (docs/).
- The core functionality lies in the “cover_agent” directory, which contains:
- Modules for AI interaction (AICaller.py, AgentCompletionABC.py, DefaultAgentCompletion.py),
- Test generation and validation (UnitTestGenerator.py, UnitTestValidator.py, CoverageProcessor.py, ReportGenerator.py),
- A Runner (Runner.py) that controls the overall test generation pipeline.
- There is an extensive “lsp_logic” submodule that likely provides language server protocols (LSP) integrations. This can be diagrammed as a separate component interacting with the main process.
- The “settings” directory provides runtime and configuration options (various TOML files, config_loader.py).
- “templated_tests” hold working examples for different languages (Python FastAPI, Go, Java, C#/C++, JavaScript, React, Ruby, TypeScript), emphasizing the multi-language support of the system.
- Unit and integration tests are present in “tests” and “tests_integration” directories for verifying core functionality.

##### Components and Their Relationships
a. CLI/Entry Point:
- A primary entrypoint in cover_agent/main.py along with main_full_repo.py. This is the component that starts the process whether as a standalone CLI or within a container.
b. Test Runner:
- Represented by Runner.py and linked to the execution of test commands (passed via CLI arguments).
c. Coverage Parser:
- CoverageProcessor.py that reviews the code coverage reports (e.g., Cobertura XML, Jacoco) and validates coverage improvements.
d. Test Generation Core:
- The Test Generation hub incorporates:
○ UnitTestGenerator.py – which generates tests.
○ UnitTestValidator.py – which validates that generated tests are effective.
e. AI Communication Module:
- AICaller.py and AgentCompletionABC.py (with its DefaultAgentCompletion implementation) manage the prompt creation for the LLM, the LLM call via LiteLLM, and the retrieval of generated tests.
f. LSP and Advanced Integration:
- The “cover_agent/lsp_logic” directory includes:
○ The multilspy module (with its language server implementations and protocol handling).
○ Utility modules for file mapping and scripts/handlers to manage code context for prompt building.
g. Configuration & Settings:
- The “cover_agent/settings” directory which loads and maintains various configuration files (TOML, etc.) used across components.
h. CI/CD Pipelines & Build System:
- .github/workflows and Dockerfile – these define how the project is built, tested, and deployed in CI environments.
i. Example/Test Projects:
- “templated_tests” directory which serves as both usage examples and testing ground for supporting various language ecosystems.

##### Architectural Patterns & Design Principles
- Modularity: Each component (test generation, LLM interfacing, test validation, configuration handling) is in its own module.
- Extensibility: The project is designed to support many languages and integration modes (CLI, CI, LSP), which should be highlighted.
- Plug-in style integration: Using structured configuration and clear boundaries between the AI module and the test generation modules.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Processing Subgraph
    subgraph "Core Processing"
        CLI("CLI/Entry Point"):::internal
        Runner("Test Runner"):::internal
        Coverage("Coverage Parser"):::internal
        TestGen("Test Generation Core"):::internal
        AI("AI Communication Module"):::internal
        Report("Report Generation"):::internal
    end

    %% Auxiliary Modules Subgraph
    subgraph "Auxiliary Modules"
        Config("Configuration Manager"):::internal
        LSP("LSP Integration"):::internal
    end

    %% External Integration Subgraph
    subgraph "External Integrations"
        LLM("LLM API"):::external
        CovTools("Coverage Tools"):::external
        CI_Platform("CI/CD Platforms"):::external
    end

    %% Other External Components
    CI_CD("CI/CD Pipelines & Build System"):::external
    Templated("Example/Test Projects"):::external

    %% Connections between components
    CLI -->|"starts"| Runner
    Runner -->|"executes"| TestGen
    Runner -->|"triggers"| AI
    Runner -->|"runs"| Report
    Runner -->|"analyzes"| Coverage

    Config -->|"feeds"| AI
    Config -->|"feeds"| TestGen

    AI -->|"calls"| LLM
    Coverage -->|"parses"| CovTools

    CLI -->|"integratesWith"| LSP

    Templated -->|"usedBy"| TestGen
    Report -->|"finishes"| Coverage

    CI_CD -->|"triggers"| CLI
    CI_CD -->|"integratesWith"| CI_Platform

    %% Styles
    classDef internal fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef external fill:#ffecb3,stroke:#ff9800,stroke-width:2px;

    %% Click Events
    click CLI "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/main.py"
    click CLI "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/main_full_repo.py"
    click Runner "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/Runner.py"
    click Coverage "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/CoverageProcessor.py"
    click TestGen "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/UnitTestGenerator.py"
    click TestGen "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/UnitTestValidator.py"
    click AI "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/AICaller.py"
    click AI "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/AgentCompletionABC.py"
    click AI "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/DefaultAgentCompletion.py"
    click Report "https://github.com/qodo-ai/qodo-cover/blob/main/cover_agent/ReportGenerator.py"
    click LSP "https://github.com/qodo-ai/qodo-cover/tree/main/cover_agent/lsp_logic"
    click Config "https://github.com/qodo-ai/qodo-cover/tree/main/cover_agent/settings"
    click CI_CD "https://github.com/qodo-ai/qodo-cover/tree/main/.github/workflows"
    click CI_CD "https://github.com/qodo-ai/qodo-cover/tree/main/Dockerfile"
    click Templated "https://github.com/qodo-ai/qodo-cover/tree/main/templated_tests"
```
