# snap-stanford/biomni architecture

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

- Interactive diagram: https://gitdiagram.com/snap-stanford/biomni
- Repository: https://github.com/snap-stanford/biomni

## Overview

##### Project type and purpose
- Biomni is an open-source Python library and CLI tool implementing a general-purpose biomedical AI agent (no dedicated frontend code in this repo).
- It orchestrates LLM calls, retrieval-augmented planning, domain-specific tools, and code execution to automate research tasks.

##### File structure
- Top-level:
- setup.py, setup.cfg, MANIFEST.in → packaging/build configuration
- biomni_env/ → conda/R environment and CLI tools installation scripts
- biomni/ → core Python package
- tutorials/, fig/, figs/ → usage examples and assets
- Inside biomni/:
- agent/ → agent controllers (A1, planning, react framework)
- model/ → retrieval logic (Vector store, embeddings)
- task/ → abstract Task definition + domain-specific tasks
- tool/ → a registry of domain tools, schemas, and support utilities
- biorxiv_scripts/ → data-prep scripts for generating new tasks from preprints
- utils.py, llm.py, env_desc.py → cross-cutting utilities and LLM wrappers
- Patterns:
- Plugin/registry pattern in tool_registry.py
- Modular package structure (agent – model – tool – task)
- Separation of concerns: planning vs. execution vs. retrieval

##### README for additional insights
- Confirms core components: agent.go(), environment setup, tool/database integrations
- Emphasis on extensibility: add new tools, datasets, benchmarks
- Mentions Web UI separately (hosted outside this repo)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI / SDK Layer"
        CLI["CLI / Python SDK"]:::entry
    end
    subgraph "Environment Bootstrap"
        Env["Conda/R Setup"]:::process
    end
    subgraph "Core Engine"
        subgraph "Agent Orchestrator"
            A1["A1 Controller"]:::agent
            React["React Framework"]:::agent
            QA["QA LLM Wrapper"]:::agent
            EnvColl["Env Data Collection"]:::agent
        end
        subgraph "LLM Interface"
            LLM["LLM Interface"]:::api
        end
        subgraph "Retrieval Engine"
            Retriever["Retriever"]:::model
        end
        subgraph "Task Framework"
            BaseTask["BaseTask"]:::task
            HLE["HLE Tasks"]:::task
            LabBench["LabBench Tasks"]:::task
        end
        subgraph "Tool Registry & Domain Tools"
            ToolReg["Tool Registry"]:::tool
            Support["Support Tools"]:::tool
            subgraph "Domain Tools"
                BChem["biochemistry"]:::tool
                BEng["bioengineering"]:::tool
                BPhys["biophysics"]:::tool
                Cancer["cancer_biology"]:::tool
                CellBio["cell_biology"]:::tool
                DB["database"]:::tool
                Genetics["genetics"]:::tool
                Genomics["genomics"]:::tool
                Immunology["immunology"]:::tool
                Literature["literature"]:::tool
                Micro["microbiology"]:::tool
                MolBio["molecular_biology"]:::tool
                Pathology["pathology"]:::tool
                Pharmacology["pharmacology"]:::tool
                Physiology["physiology"]:::tool
                Synthetic["synthetic_biology"]:::tool
                Systems["systems_biology"]:::tool
            end
            SchemaDB["Tool SchemaDB"]:::tool
            Descriptions["Tool Descriptions"]:::tool
        end
        subgraph "Utilities"
            EnvDesc["Env Descriptions"]:::util
            Utils["General Utilities"]:::util
            Version["Version Info"]:::util
        end
    end
    subgraph "Data Lake & External"
        API["LLM APIs\n(OpenAI/Anthropic)"]:::external
        DataLake["Data Lake"]:::external
    end
    subgraph "Data Population Scripts"
        Extract["extract_biorxiv_tasks.py"]:::script
        GenFunc["generate_function.py"]:::script
        GenAll["generation_tools_all_subjects.py"]:::script
        ProcessAll["process_all_subjects.py"]:::script
    end
    subgraph "Tutorials & Assets"
        Tutorials["Tutorials"]:::docs
        Examples["Examples"]:::docs
        Figs["fig/, figs/"]:::assets
    end

    CLI --> A1
    CLI --> BaseTask
    A1 --> LLM
    A1 --> Retriever
    A1 --> BaseTask
    A1 --> ToolReg
    LLM --> API
    Retriever --> DataLake
    DataLake --> Retriever
    ToolReg --> SchemaDB
    ToolReg --> Descriptions
    Extract --> DataLake
    GenFunc --> BaseTask
    GenAll --> BaseTask
    ProcessAll --> DataLake

    click CLI "https://github.com/snap-stanford/biomni/blob/main/setup.py"
    click Env "https://github.com/snap-stanford/biomni/tree/main/biomni_env/"
    click A1 "https://github.com/snap-stanford/biomni/blob/main/biomni/agent/a1.py"
    click React "https://github.com/snap-stanford/biomni/blob/main/biomni/agent/react.py"
    click QA "https://github.com/snap-stanford/biomni/blob/main/biomni/agent/qa_llm.py"
    click EnvColl "https://github.com/snap-stanford/biomni/blob/main/biomni/agent/env_collection.py"
    click LLM "https://github.com/snap-stanford/biomni/blob/main/biomni/llm.py"
    click Retriever "https://github.com/snap-stanford/biomni/blob/main/biomni/model/retriever.py"
    click BaseTask "https://github.com/snap-stanford/biomni/blob/main/biomni/task/base_task.py"
    click HLE "https://github.com/snap-stanford/biomni/blob/main/biomni/task/hle.py"
    click LabBench "https://github.com/snap-stanford/biomni/blob/main/biomni/task/lab_bench.py"
    click ToolReg "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/tool_registry.py"
    click Support "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/support_tools.py"
    click BChem "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/biochemistry.py"
    click BEng "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/bioengineering.py"
    click BPhys "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/biophysics.py"
    click Cancer "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/cancer_biology.py"
    click CellBio "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/cell_biology.py"
    click DB "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/database.py"
    click Genetics "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/genetics.py"
    click Genomics "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/genomics.py"
    click Immunology "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/immunology.py"
    click Literature "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/literature.py"
    click Micro "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/microbiology.py"
    click MolBio "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/molecular_biology.py"
    click Pathology "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/pathology.py"
    click Pharmacology "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/pharmacology.py"
    click Physiology "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/physiology.py"
    click Synthetic "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/synthetic_biology.py"
    click Systems "https://github.com/snap-stanford/biomni/blob/main/biomni/tool/systems_biology.py"
    click SchemaDB "https://github.com/snap-stanford/biomni/tree/main/biomni/tool/schema_db/"
    click Descriptions "https://github.com/snap-stanford/biomni/tree/main/biomni/tool/tool_description/"
    click Extract "https://github.com/snap-stanford/biomni/blob/main/biomni/biorxiv_scripts/extract_biorxiv_tasks.py"
    click GenFunc "https://github.com/snap-stanford/biomni/blob/main/biomni/biorxiv_scripts/generate_function.py"
    click GenAll "https://github.com/snap-stanford/biomni/blob/main/biomni/biorxiv_scripts/generation_tools_all_subjects.py"
    click ProcessAll "https://github.com/snap-stanford/biomni/blob/main/biomni/biorxiv_scripts/process_all_subjects.py"
    click EnvDesc "https://github.com/snap-stanford/biomni/blob/main/biomni/env_desc.py"
    click Utils "https://github.com/snap-stanford/biomni/blob/main/biomni/utils.py"
    click Version "https://github.com/snap-stanford/biomni/blob/main/biomni/version.py"
    click Tutorials "https://github.com/snap-stanford/biomni/tree/main/tutorials/"
    click Examples "https://github.com/snap-stanford/biomni/tree/main/tutorials/examples/"
    click Figs "https://github.com/snap-stanford/biomni/tree/main/fig/"

    classDef entry fill:#f9f,stroke:#333,stroke-width:1px
    classDef process fill:#ff9,stroke:#333
    classDef agent fill:#bbf,stroke:#333
    classDef api fill:#fb0,stroke:#333
    classDef model fill:#bfb,stroke:#333
    classDef task fill:#fbb,stroke:#333
    classDef tool fill:#ffb,stroke:#333
    classDef util fill:#ddd,stroke:#333
    classDef external fill:#fdd,stroke:#333
    classDef script fill:#dfd,stroke:#333
    classDef docs fill:#ddf,stroke:#333
    classDef assets fill:#dff,stroke:#333
```
