# cgoncalves94/multi_agent_system architecture

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

- Interactive diagram: https://gitdiagram.com/cgoncalves94/multi_agent_system
- Repository: https://github.com/cgoncalves94/multi_agent_system

## Overview

##### Project Type and Purpose
- Purpose: accept user queries, decide processing path, run one or more agents (possibly in parallel), synthesize agent outputs, and return a cohesive answer or visualization.

##### File Structure
- Top-level files: configuration (.env.example, langgraph.json, pyproject.toml), docs/, examples/, pre-commit and CI workflows.
- src/agents/: contains subfolders for each agent type:
- orchestrator/ (router logic, graph definitions, prompts & schemas)
- rag/ (retrieval‐augmented generation logic, vector store integration)
- researcher/ (parallel web/wiki search and synthesis)
- summarizer/ (map-reduce document processing)
- src/config.py: global config (API keys, vector store settings).
- src/utils/: file handling, message utilities, debugging helpers.

##### README Insights

- Query → Router → Agent(s) → Synthesis → Response.
- Agent → External Service / Storage → Agent.
- Router/orchestration (e.g., blue).
- Agents (e.g., green).
- Storage (e.g., orange).
- External APIs (e.g., purple).
- “Core Orchestration”, “Agents”, “Storage & State”, “External Services”.
- Architectural patterns (e.g., map-reduce, parallel streams) near the relevant agent.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interface
    subgraph "User Interface"
        User["User (CLI/REST/Chat UI)"]:::ui
    end

    %% Core Orchestration
    subgraph "Core Orchestration"
        Router["Router / Orchestrator"]:::orchestration
    end

    %% Agents
    subgraph "Agents"
        RAG["RAG Agent"]:::agent
        Research["Research Agent"]:::agent
        Summarizer["Summarizer Agent"]:::agent
        Diagram["Diagram Agent"]:::agent
        QuickAnswer["Quick Answer Agent"]:::agent
    end

    %% Synthesis and Response
    Synthesis["Synthesis Module"]:::orchestration
    Response["Final Response"]:::ui

    %% Storage & State
    subgraph "Storage & State"
        VectorStore["Vector Store (Chroma)"]:::storage
        SQLiteState["SQLite Checkpoint"]:::storage
    end

    %% Config & Utilities
    subgraph "Config & Utilities"
        Config["Global Configuration"]:::config
        InspectChroma["Chroma Inspector"]:::utils
        FileUtils["File Utilities"]:::utils
        MessageUtils["Message & Debug Utilities"]:::utils
    end

    %% External Services
    subgraph "External Services"
        WebSearch["Web Search API (TAVILY)"]:::external
        WikiAPI["Wiki API"]:::external
        OpenAI["OpenAI (LLM & Embeddings)"]:::external
    end

    %% Connections
    User -->|"submits query"| Router

    Router -->|"if RAG request"| RAG
    Router -->|"if research request"| Research
    Router -->|"if summarization request"| Summarizer
    Router -->|"if diagram request"| Diagram
    Router -->|"if quick answer"| QuickAnswer

    RAG -->|"retrieves embeddings"| VectorStore
    RAG -->|"calls LLM"| OpenAI
    Research -->|"parallel search"| WebSearch
    Research -->|"parallel search"| WikiAPI
    Research -->|"calls LLM"| OpenAI
    Summarizer -->|"map-reduce synthesis"| OpenAI
    Diagram -->|"generate Mermaid.js"| OpenAI
    QuickAnswer -->|"direct LLM answer"| OpenAI

    RAG --> Synthesis
    Research --> Synthesis
    Summarizer --> Synthesis
    Diagram --> Synthesis
    QuickAnswer --> Synthesis

    Synthesis -->|"compose final output"| Response

    %% Config & Utilities Links
    Router --> Config
    RAG --> Config
    Research --> Config
    Summarizer --> Config
    Diagram --> Config
    QuickAnswer --> Config

    InspectChroma --> VectorStore
    FileUtils --> VectorStore
    MessageUtils --> Router

    %% Click Events
    click Router "https://github.com/cgoncalves94/multi_agent_system/blob/main/src/agents/orchestrator/graph.py"
    click RAG "https://github.com/cgoncalves94/multi_agent_system/blob/main/src/agents/rag/graph.py"
    click Research "https://github.com/cgoncalves94/multi_agent_system/blob/main/src/agents/researcher/graph.py"
    click Summarizer "https://github.com/cgoncalves94/multi_agent_system/blob/main/src/agents/summarizer/graph.py"
    click Diagram "https://github.com/cgoncalves94/multi_agent_system/blob/main/src/agents/react/agent.py"
    click Config "https://github.com/cgoncalves94/multi_agent_system/blob/main/src/config.py"
    click InspectChroma "https://github.com/cgoncalves94/multi_agent_system/blob/main/src/utils/inspect_chroma.py"
    click FileUtils "https://github.com/cgoncalves94/multi_agent_system/blob/main/src/utils/file_utils.py"
    click MessageUtils "https://github.com/cgoncalves94/multi_agent_system/blob/main/src/utils/message_utils.py"
    click Config "https://github.com/cgoncalves94/multi_agent_system/blob/main/.env.example"
    click Config "https://github.com/cgoncalves94/multi_agent_system/blob/main/langgraph.json"

    %% Styles
    classDef ui fill:#f2f2f2,stroke:#333,stroke-width:1px
    classDef orchestration fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef agent fill:#d4edda,stroke:#155724,stroke-width:1px
    classDef storage fill:#fff3cd,stroke:#856404,stroke-width:1px
    classDef config fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
    classDef utils fill:#d1ecf1,stroke:#0c5460,stroke-width:1px
    classDef external fill:#f5c6cb,stroke:#721c24,stroke-width:1px
```
