# kshitijjain21/certification-tool-cli architecture

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

- Interactive diagram: https://gitdiagram.com/kshitijjain21/certification-tool-cli
- Repository: https://github.com/kshitijjain21/certification-tool-cli

## Overview

##### Project Type and Purpose
- This is a CLI tool built in Python (with Poetry for dependency management) which acts as a front-end for interacting with a Test Harness backend.
- The main purpose is to allow users to run tests, query test execution history, manage projects (create, list, delete, update), and interact with the Test Harness API.
- It also includes an auto-generated API client (using fastapi_client) to communicate with the backend and a client generator module that can produce client code based on OpenAPI specifications.

##### File Structure for Architectural Clues
- The “app” directory is the core of the CLI tool:
- app/main.py serves as the CLI’s entry point.
- app/commands contains different Click-based command implementations (e.g., available-tests, run-tests, test-run-execution-history).
- app/api_lib_autogen holds the auto-generated API client code (with subdirectories for API endpoints, documentation, models, and exceptions) that wraps the Test Harness API.
- Other modules in “app” (like config.py, async_cmd.py, and modules under app/test_run such as logging and websocket) indicate responsibilities for configuration, asynchronous command execution, and managing test-run details.
- Outside “app”, the client_generator folder is dedicated to generating client code (has Dockerfiles, examples, and mustache templates) showing integration with the OpenAPI specifications.
- Additional files (openapi.json, config.json.example, Dockerfile, scripts folder) indicate support for automated client generation, linting, formatting, and deployment support.

##### Key Components and Their Relationships
- CLI Entry Point:
- The CLI entry is triggered via a shell script (cli.sh) that calls the app/main.py.
- Command Processing Layer:
- Under app/commands, different commands are implemented using the Click framework. These commands collect user input/options and then dispatch actions.
- API Client Layer:
- Within app/api_lib_autogen, the auto-generated API client (including various endpoints like devices_api, projects_api, etc.) abstracts the interaction with the external Test Harness API.
- This component is a major interface between the CLI commands and the remote backend.
- Configuration:
- The config.py, and config.json (template provided), manage settings such as the hostname for the Test Harness.
- Test-Run Manager:
- The app/test_run component manages aspects of test execution (logging, websocket communications, prompt handling).
- Client Generator:
- The client_generator folder provides tooling to generate client libraries from an OpenAPI specification. It is designed for extendibility and maintenance of clients for the Test Harness API.
- DevOps / Environment Tools:
- Dev container configurations (.devcontainer), Dockerfiles, GitHub workflows, and scripts show that containerized development and CI/CD are part of the design.

##### Architectural Patterns and Design Principles
- Layered Architecture:
- Each “layer” (CLI interface, business/command logic, API client integration, asynchronous test run handling) plays a well-defined role.
- Modularity and Separation of Concerns:
- Commands are modularized under app/commands.
- API communication is separated into the api_lib_autogen.
- Client generation is encapsulated in its own folder.
- Auto-Generation and Integration:
- The auto-generated API client demonstrates an integration pattern, reducing manual API wrapper code and ensuring consistency with the backend’s OpenAPI spec.
- Containerization:
- Docker and a VS Code dev-container ensure consistent development/deployment environments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User/Terminal"]:::external

    subgraph "CLI Interface"
        cliSh["Shell Script (CLI)"]:::cli
        cliMain["Main Application (CLI)"]:::cli
        cliSh -->|"triggers"| cliMain
    end

    CP["Command Processing"]:::internal
    API["API Client Module"]:::internal
    TRM["Test Run Manager"]:::internal
    CFG["Configuration"]:::internal
    CG["Client Generator"]:::tooling
    THAPI["Test Harness API Spec"]:::external
    DO["DevOps Tools"]:::tooling

    User -->|"executes"| cliSh
    cliMain -->|"handles_command"| CP
    CP -->|"calls_API"| API
    API -->|"HTTP_request"| THAPI
    CP -->|"async_dispatch"| TRM
    CFG -->|"configures"| cliMain
    CG -->|"updates_client"| API
    DO -->|"supports"| CFG
    DO -->|"supports"| CG

    click cliSh "https://github.com/kshitijjain21/certification-tool-cli/blob/main/cli.sh"
    click cliMain "https://github.com/kshitijjain21/certification-tool-cli/blob/main/app/main.py"
    click CP "https://github.com/kshitijjain21/certification-tool-cli/tree/main/app/commands"
    click API "https://github.com/kshitijjain21/certification-tool-cli/tree/main/app/api_lib_autogen"
    click TRM "https://github.com/kshitijjain21/certification-tool-cli/tree/main/app/test_run"
    click TRM "https://github.com/kshitijjain21/certification-tool-cli/blob/main/app/test_run/logging.py"
    click TRM "https://github.com/kshitijjain21/certification-tool-cli/blob/main/app/test_run/prompt_manager.py"
    click TRM "https://github.com/kshitijjain21/certification-tool-cli/blob/main/app/test_run/websocket.py"
    click CFG "https://github.com/kshitijjain21/certification-tool-cli/blob/main/app/config.py"
    click CFG "https://github.com/kshitijjain21/certification-tool-cli/blob/main/config.json.example"
    click CG "https://github.com/kshitijjain21/certification-tool-cli/tree/main/client_generator"
    click THAPI "https://github.com/kshitijjain21/certification-tool-cli/blob/main/openapi.json"
    click DO "https://github.com/kshitijjain21/certification-tool-cli/blob/main/.devcontainer"
    click DO "https://github.com/kshitijjain21/certification-tool-cli/tree/main/Dockerfile"
    click DO "https://github.com/kshitijjain21/certification-tool-cli/tree/main/.github/workflows"
    click DO "https://github.com/kshitijjain21/certification-tool-cli/tree/main/scripts"

    classDef external fill:#f9c,stroke:#333,stroke-width:2px
    classDef internal fill:#bbf,stroke:#333,stroke-width:2px
    classDef tooling fill:#dfd,stroke:#333,stroke-width:2px
    classDef cli fill:#ffe599,stroke:#333,stroke-width:2px
```
