# aakriti1318/multi-agent-generator architecture

> Architecture diagram of the GitHub repository aakriti1318/multi-agent-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aakriti1318/multi-agent-generator
- Repository: https://github.com/aakriti1318/multi-agent-generator

## Overview

##### Project Type & Purpose
- This is an open-source Python tool that:
- Provides a CLI (`multi-agent-generator`) and optional Streamlit UI (`streamlit_app.py`).
- Leverages LiteLLM to remain provider-agnostic (OpenAI, WatsonX, Ollama, Anthropic, etc.).
- Generates multi-agent code or JSON configs for multiple frameworks (CrewAI, CrewAI Flow, LangGraph, ReAct variants).

##### File Structure
Top-level:
- `multi_agent_generator/` – core package
– `__main__.py` (CLI entry point)
– `generator.py` (orchestrates code generation)
– `model_inference.py` (wraps LiteLLM calls)
– `frameworks/` (one module per supported framework)
- `streamlit_app.py` – optional UI front-end
- `docs/`, `mkdocs.yml` – documentation site
- `setup.py`, `pyproject.toml`, `requirements.txt` – packaging & dependencies

##### Key Components
A. User Interfaces
1. CLI Interface (`__main__.py`)
2. GUI Interface (Streamlit in `streamlit_app.py`)
B. Core Orchestrator
– `generator.py`: parses instruction, chosen framework & output format
C. Inference Layer
– `model_inference.py`: abstracted LiteLLM client
– External LLM Providers (OpenAI, WatsonX, Ollama, Anthropic)
D. Framework Plugins
– `frameworks/crewai_generator.py`
– `frameworks/crewai_flow_generator.py`
– `frameworks/langgraph_generator.py`
– `frameworks/react_generator.py`
– `frameworks/react_lcel_generator.py`
E. Output Handlers
– Python code emitter
– JSON config emitter
F. Documentation Site
– MkDocs (`docs/` + `mkdocs.yml`)

##### Relationships & Data Flow
- Users invoke either CLI or Streamlit UI → passes instructions + flags (framework, provider, output) to the Core Orchestrator.
- Core Orchestrator → calls Inference Layer → dispatches prompt to LiteLLM → LiteLLM forwards to chosen external LLM → responses returned.
- Core Orchestrator → selects appropriate Framework Plugin → plugin ingests LLM output → generates code or JSON.
- Output Handler formats and writes to stdout, file, or downloads via UI.
- Documentation is maintained separately (MkDocs) and serves static site; not in the runtime flow but part of the ecosystem.

##### Architectural Patterns & Principles
- Modular Plugin Architecture: each framework generator is a drop-in module under `frameworks/`.
- Provider-Agnostic Abstraction: model_inference.py wraps all LLM providers via LiteLLM.
- Separation of Concerns: UI, orchestration, inference, generation, and output each live in their own layer.

##### Final Checklist
- [ ] All main components labeled
- [ ] Call out external LLM providers separately
- [ ] Note configurable flags/env-vars at UI layer (e.g., `--provider`, API_KEY)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "User Interfaces"
        CLI["CLI Interface"]:::ui
        GUI["Streamlit UI"]:::ui
    end

    %% Core Orchestrator
    Core["Core Orchestrator<br/>(generator.py)"]:::core

    %% Inference Layer
    Inference["Inference Layer<br/>(model_inference.py)"]:::core

    %% External LLM Providers
    subgraph "External LLM Providers"
        direction TB
        OpenAI["OpenAI"]:::external
        WatsonX["WatsonX"]:::external
        Ollama["Ollama"]:::external
        Anthropic["Anthropic"]:::external
    end

    %% Framework Plugins
    subgraph "Framework Plugins"
        direction TB
        CrewAI["CrewAI Generator"]:::plugin
        CrewAIFlow["CrewAI Flow Generator"]:::plugin
        LangGraph["LangGraph Generator"]:::plugin
        ReAct["ReAct Generator"]:::plugin
    end

    %% Output Handlers
    subgraph "Output Handlers"
        CodeEmitter["Python Code Emitter"]:::core
        JSONEmitter["JSON Config Emitter"]:::core
    end

    %% Documentation & Packaging
    Docs["Documentation Site<br/>(MkDocs)"]:::docs
    Packaging["Packaging & Dependencies"]:::docs

    %% Flow
    CLI -->|"instructions + flags"| Core
    GUI -->|"instructions + flags"| Core
    Core -->|"prepare prompt"| Inference
    Inference -->|"dispatch to provider"| OpenAI
    Inference -->|"dispatch to provider"| WatsonX
    Inference -->|"dispatch to provider"| Ollama
    Inference -->|"dispatch to provider"| Anthropic
    OpenAI -->|"response"| Inference
    WatsonX -->|"response"| Inference
    Ollama -->|"response"| Inference
    Anthropic -->|"response"| Inference
    Inference -->|"LLM output"| Core
    Core -->|"select plugin"| CrewAI
    Core -->|"select plugin"| CrewAIFlow
    Core -->|"select plugin"| LangGraph
    Core -->|"select plugin"| ReAct
    CrewAI -->|"generate code/json"| CodeEmitter
    CrewAIFlow -->|"generate code/json"| CodeEmitter
    LangGraph -->|"generate code/json"| CodeEmitter
    ReAct -->|"generate code/json"| CodeEmitter
    CodeEmitter -->|"output"| CLI
    JSONEmitter -->|"output"| CLI
    CodeEmitter -->|"output/download"| GUI
    JSONEmitter -->|"output/download"| GUI

    %% Click Events
    click CLI "https://github.com/aakriti1318/multi-agent-generator/blob/main/multi_agent_generator/__main__.py"
    click GUI "https://github.com/aakriti1318/multi-agent-generator/blob/main/streamlit_app.py"
    click Core "https://github.com/aakriti1318/multi-agent-generator/blob/main/multi_agent_generator/generator.py"
    click Inference "https://github.com/aakriti1318/multi-agent-generator/blob/main/multi_agent_generator/model_inference.py"
    click CrewAI "https://github.com/aakriti1318/multi-agent-generator/blob/main/multi_agent_generator/frameworks/crewai_generator.py"
    click CrewAIFlow "https://github.com/aakriti1318/multi-agent-generator/blob/main/multi_agent_generator/frameworks/crewai_flow_generator.py"
    click LangGraph "https://github.com/aakriti1318/multi-agent-generator/blob/main/multi_agent_generator/frameworks/langgraph_generator.py"
    click ReAct "https://github.com/aakriti1318/multi-agent-generator/blob/main/multi_agent_generator/frameworks/react_generator.py"
    click Docs "https://github.com/aakriti1318/multi-agent-generator/tree/main/docs/"
    click Packaging "https://github.com/aakriti1318/multi-agent-generator/blob/main/setup.py"

    %% Styles
    classDef ui fill:#d0e1f9,stroke:#3b73af,color:#0a225c,stroke-width:1px;
    classDef core fill:#e8f1e8,stroke:#3a763a,color:#1f3d1f,stroke-width:1px;
    classDef external fill:#e0ffe0,stroke:#28a728,color:#174d17,stroke-width:1px,stroke-dasharray: 5 5;
    classDef plugin fill:#fff4d6,stroke:#c79c1a,color:#5a4a0c,stroke-width:1px;
    classDef docs fill:#f0f0f0,stroke:#999999,color:#555555,stroke-width:1px,stroke-dasharray: 2 2;
```
