# yiyihum/da-code architecture

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

- Interactive diagram: https://gitdiagram.com/yiyihum/da-code
- Repository: https://github.com/yiyihum/da-code

## Overview

- Agent Module – Represented by the “da_agent” directory. This contains submodules such as:
○ agent: The core mechanisms for taking an input prompt and generating actions (agent/agents.py, models.py, etc.).
○ configs: Configuration for various aspects including BigQuery, post-processing, and SQL templates.
○ controllers: Likely used to route or adapt inputs (e.g., python.py, setup.py).
○ evaluators: Contains logic for evaluating the generated data science tasks. Within evaluators, there are getter modules for retrieving evaluation data and metrics modules to compute evaluation values.
○ envs: Provides the sandboxed environments (da_agent/da_agent.py and associated utilities) that encapsulate the runtime context.
○ images: Dockerfile and container configuration to ensure that the agent runs inside a secured, reproducible environment.

- Benchmark Code and Data – Located primarily in the “da_code” folder:
○ source: Contains datasets and examples that are used during benchmark runs.
○ gold: Storage for gold standards/results against which generated outputs are compared.
○ configs: Contains evaluation and task configuration files.

- Execution and Evaluation Scripts:
○ run.py – The main entry point to start the benchmark process.
○ evaluate.py – A script to run comparisons between benchmark outputs and gold answers.
○ requirements.txt – Defines required packages.

- External Integrations:
○ Docker – The project requires running inside a Docker container, so include a Docker environment (image and Dockerfile in da_agent/images) as part of the architecture.
○ LLM APIs – Environment variables indicate integration with major LLM providers (Azure, OpenAI, Gemini API).

##### Relationships & Interactions
- The “run.py” engine orchestrates benchmark experiments by invoking the agent components.
- The agent module loads configurations (from “configs”) and uses its agent and controller components to generate code instructions.
- The generated code and outputs are evaluated by the evaluators module, which then compares against “gold” data from da_code/gold.
- The “evaluate.py” script is used as a post-run assessment to compute metrics (using components in evaluators/metrics) and output the results.
- All operations run inside a Dockerized sandbox environment, ensuring reproducibility and security.
- There is a clear data flow: source examples from da_code/source → processing/generation by da_agent → evaluation against da_code/gold → reporting of benchmark performance.

##### Architectural Patterns & Design Principles
- Modular decomposition: The project is split into distinct directories by responsibility (agent, configs, controllers, evaluators, and envs).
- Separation of concerns: Code generation (agents), configuration (configs), and evaluations (evaluators) are well separated.
- Configurable Execution: Use of command-line arguments in run.py and evaluate.py as well as environment variables for API keys make the system flexible for different benchmark runs.
- Containerization: Docker images are used to manage dependencies and run agents in a sandbox.

##### Be Detailed and Component-Rich
- That the initial load flow (from the run.py entry point) and subsequent evaluation (via evaluate.py) are clearly shown and connected.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Top-level Execution
    RUN["run.py"]:::execution
    EVAL_SCRIPT["evaluate.py"]:::execution
    DEPS["requirements.txt"]:::dependency

    %% Benchmark Data Subgraph
    subgraph "Benchmark Data"
        SRC["Source Data"]:::data
        GOLD["Gold Standard Data"]:::data
    end

    %% Agent Module Subgraph
    subgraph "Agent Module"
        A_AGENT["Agent Logic & Models"]:::agent
        A_CONFIG["Configurations"]:::config
        A_CTRL["Controllers"]:::controller
        A_EVAL["Evaluators (Metrics&Getters)"]:::evaluator
        A_ENVS["Sandbox Environment"]:::environment
    end

    %% External Docker Integration
    DOCKER["Docker Image Environment"]:::docker

    %% Data Flow Connections
    RUN -->|"triggers"| A_AGENT
    RUN -->|"loads"| A_CONFIG
    RUN -->|"routes"| A_CTRL
    SRC -->|"provides_input"| A_AGENT
    A_AGENT -->|"executes_in"| A_ENVS
    A_ENVS -->|"runs_on"| DOCKER
    A_AGENT -->|"outputs_to"| A_EVAL
    GOLD -->|"compares_with"| A_EVAL
    A_EVAL -->|"evaluates_results"| EVAL_SCRIPT
    RUN -->|"relies_on"| DEPS

    %% Styles
    classDef agent fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef config fill:#D2B4DE,stroke:#512E5F,stroke-width:2px;
    classDef controller fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef evaluator fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef environment fill:#D5F5E3,stroke:#1E8449,stroke-width:2px;
    classDef data fill:#82E0AA,stroke:#145A32,stroke-width:2px;
    classDef docker fill:#E8DAEF,stroke:#512E5F,stroke-width:2px;
    classDef execution fill:#FDEBD0,stroke:#D35400,stroke-width:2px;
    classDef dependency fill:#D6EAF8,stroke:#2E86C1,stroke-width:2px;

    %% Click Events
    click A_AGENT "https://github.com/yiyihum/da-code/tree/main/da_agent/agent"
    click A_CONFIG "https://github.com/yiyihum/da-code/tree/main/da_agent/configs"
    click A_CTRL "https://github.com/yiyihum/da-code/tree/main/da_agent/controllers"
    click A_ENVS "https://github.com/yiyihum/da-code/tree/main/da_agent/envs"
    click DOCKER "https://github.com/yiyihum/da-code/tree/main/da_agent/images/da_agent-image/Dockerfile"
    click A_EVAL "https://github.com/yiyihum/da-code/tree/main/da_agent/evaluators"
    click SRC "https://github.com/yiyihum/da-code/tree/main/da_code/source"
    click GOLD "https://github.com/yiyihum/da-code/tree/main/da_code/gold"
    click EVAL_SCRIPT "https://github.com/yiyihum/da-code/blob/main/evaluate.py"
    click RUN "https://github.com/yiyihum/da-code/blob/main/run.py"
    click DEPS "https://github.com/yiyihum/da-code/blob/main/requirements.txt"
```
