# joshuachou2018/autoba architecture

> Architecture diagram of the GitHub repository joshuachou2018/autoba, 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/joshuachou2018/autoba
- Repository: https://github.com/joshuachou2018/autoba

## Overview

##### And Label Main Components
- Client Interface:
- CLI Interface: Driven by app.py (and configuration files such as config.yaml within the examples/ directory).
- GUI Interface: Provided by gui.py (using Gradio).
- Configuration & Input Manager:
- The “examples” directory holds sample configuration files (config.yaml) that define the analysis tasks, input data paths, and goal descriptions.
- Core AI Agent:
- The engine that parses configurations and initiates the analysis pipeline is distributed within src files like agent.py, local_llm.py, prompt.py, and executor.py.
- The Automatic Code Repair (ACR) module and RAG (retrieval-augmented generation) functionalities are integrated here (see references in build_RAG_private.py and updates in the README).
- LLM Integration Modules:
- Two key submodules in src – “codellama-main” and “llama-main” – incorporate support for local LLM-based processing.
- The “deepseek” directory provides additional LLM backends.
- These modules are responsible for interacting with both remote APIs (e.g., openai) and local LLM services (via ollama or direct downloads).
- Bioinformatics Pipeline & Software Management:
- The “softwares_config” directory contains configuration files for various bioinformatics tools (e.g., bowtie2, hisat2, macs2, etc.).
- The “softwares_database” directory maintains databases (or listings) for these tools.
- Utility & External Resource Manager:
- The “media” directory (with publication PDFs) and the “src” folder’s additional scripts (like merge_weights.py, spinner.py) help coordinate modules and resources.

##### Relationships and Data Flow
- User (via CLI/GUI) selects or creates a config.yaml file defining data inputs, output directory, and analysis goals.
- Configuration Parsing:
- The configuration is loaded by app.py (or gui.py) and passed to the Core AI Agent.
- Core AI Agent Operation:
- The Agent (src/agent.py) interprets the user-specified goal.
- It then coordinates with the LLM modules (located in src/codellama-main, src/llama-main, src/deepseek) to generate the code or pipeline steps.
- The agent may also invoke the ACR module (as mentioned in the README updates).
- Execution Flow:
- The Executor (src/executor.py) takes the AI-generated or predefined pipeline instructions and interfaces with bioinformatics tools.
- The actual bioinformatics analyses are managed by calling external software configured in “softwares_config” and referenced in “softwares_database.”
- Output Generation:
- Results are saved to the designated output directory, while the system may also provide real-time feedback (via the GUI) and logs.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- User interface, core AI logic, LLM integration, and bioinformatics pipelines are clearly separated.
- Modularity:
- Different directories (src, softwares_config, softwares_database) indicate modular design making it easier to extend or swap components.
- Extensibility:
- The system is built to integrate additional bioinformatics case studies (as seen in various example cases) and LLM backends.
- Flexible Integration:
- Multiple methods of interfacing with LLMs (remote API vs. local llm via ollama, code llama, deepseek) allow easy adaptation based on the deployment environment.

##### Technologies and Details
- Programming Language: Python is the primary language.
- LLM Technologies: OpenAI GPT models, CodeLlama, and other local LLMs support.
- GUI: Gradio is used for the GUI (installed via pip).
- Containerization: Docker support is provided (see Docker instructions in the README).
- Conda/Mamba: Used for environment management.
- External Bioinformatics Tools: The system integrates tools like STAR-Fusion, scanpy, fastqc, cutadapt, and many configured via configuration files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User("User"):::user

    %% Client Interfaces
    subgraph "Client Interfaces"
        CLI("CLI Interface (app.py)"):::interface
        GUI("GUI Interface (gui.py)"):::interface
    end

    %% Configuration & Input Manager
    ConfM("Configuration Manager (examples/...)"):::interface

    %% Core AI Agent
    subgraph "Core AI Agent"
        A1("Agent (agent.py)"):::core
        A2("Local LLM (local_llm.py)"):::core
        A3("Prompt (prompt.py)"):::core
        A4("Executor (executor.py)"):::core
        A5("RAG/ACR (build_RAG_private.py)"):::core
    end

    %% LLM Integration Modules
    subgraph "LLM Integration Modules"
        L1("CodeLlama Module (codellama-main)"):::llm
        L2("Llama Module (llama-main)"):::llm
        L3("Deepseek Module (deepseek)"):::llm
    end

    %% Bioinformatics Pipeline & Software Management
    subgraph "Bioinformatics Pipeline & Software"
        B1("Tools Config (softwares_config)"):::bio
        B2("Tools Database (softwares_database)"):::bio
    end

    %% Utility & External Resource Manager
    subgraph "Utility & External Resources"
        U1("Media Resources (media)"):::utility
        U2("Merge Weights (merge_weights.py)"):::utility
        U3("Spinner (spinner.py)"):::utility
    end

    %% Data Flow Connections
    User --> CLI
    User --> GUI

    CLI --> ConfM
    GUI --> ConfM

    ConfM --> A1

    %% Core AI Agent coordinating with LLM Modules
    A1 -->|"calls"| L1
    A1 -->|"calls"| L2
    A1 -->|"calls"| L3
    L1 -->|"results"| A1
    L2 -->|"results"| A1
    L3 -->|"results"| A1

    %% Executor passing instructions to Bioinformatics tools
    A4 --> B1
    A4 --> B2

    %% Core AI Agent interacting with Utility Resources
    A1 --> U1
    A1 --> U2
    A1 --> U3

    %% Styles
    classDef user fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef interface fill:#cce5ff,stroke:#007bff,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef llm fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef bio fill:#e2d6f3,stroke:#6f42c1,stroke-width:2px;
    classDef utility fill:#fff9c4,stroke:#f9a825,stroke-width:2px;

    %% Click Events
    click CLI "https://github.com/joshuachou2018/autoba/blob/main/app.py"
    click GUI "https://github.com/joshuachou2018/autoba/blob/main/gui.py"
    click ConfM "https://github.com/joshuachou2018/autoba/tree/main/examples/"
    click A1 "https://github.com/joshuachou2018/autoba/blob/main/src/agent.py"
    click A2 "https://github.com/joshuachou2018/autoba/blob/main/src/local_llm.py"
    click A3 "https://github.com/joshuachou2018/autoba/blob/main/src/prompt.py"
    click A4 "https://github.com/joshuachou2018/autoba/blob/main/src/executor.py"
    click A5 "https://github.com/joshuachou2018/autoba/blob/main/src/build_RAG_private.py"
    click L1 "https://github.com/joshuachou2018/autoba/tree/main/src/codellama-main/"
    click L2 "https://github.com/joshuachou2018/autoba/tree/main/src/llama-main/"
    click L3 "https://github.com/joshuachou2018/autoba/tree/main/src/deepseek/"
    click B1 "https://github.com/joshuachou2018/autoba/tree/main/softwares_config/"
    click B2 "https://github.com/joshuachou2018/autoba/tree/main/softwares_database/"
    click U1 "https://github.com/joshuachou2018/autoba/tree/main/media/"
    click U2 "https://github.com/joshuachou2018/autoba/blob/main/src/merge_weights.py"
    click U3 "https://github.com/joshuachou2018/autoba/blob/main/src/spinner.py"
```
