# maotouhu/byte-langmanus architecture

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

## Overview

##### Project Type and Purpose
- LangManus is an academically driven, open-source automation framework that leverages a hierarchical multi-agent system. Its main goal is to coordinate specialized agents (e.g., coordinator, planner, supervisor, researcher, coder, browser, reporter) for tasks like web search, crawling, and Python code execution.
- The project is structured to demonstrate multi-agent orchestration, advanced LLM (Large Language Model) integration, and several external tool integrations (e.g., web crawlers, Jina for neural search, browser control).

##### File Structure
- Top-Level Files and Directories:
– “main.py” and “server.py” indicate both a CLI entry point and a web/API server.
– The “src” directory is rich with subcomponents: “agents” (for agent logic), “api” (FastAPI-based endpoints), “config” (configuration management for tools and agents), “crawler”, “llms” (LLM integrations), “prompts” (defining agent behavior), “service” (workflow orchestration), “tools” (utility and helper functions), and “utils”.
- Supporting Material:
– Dockerfile and docker-compose.yml for containerized deployment.
– Extensive test structure under “tests/integration” ensuring component and integration validation.

##### Key Components
a. Client/Entry Points:
– API Clients (e.g., web UI, API consumers utilizing FastAPI endpoints as seen with server.py and docker-compose setup)
– CLI interactions (via main.py)
b. API Server & Web Service:
– FastAPI-based server hosted as “server.py”
– Endpoints like “POST /api/chat/stream” to allow communication with the agent system
c. Multi-Agent Orchestration System:
– Core agents (Coordinator/Entry point, Planner, Supervisor, Researcher, Coder, Browser, Reporter)
– Each agent is defined and managed under “src/agents” and further detailed through prompts in “src/prompts”. Show that the Supervisor manages task delegation and workflow transitions.
d. LLM and Tool Integration:
– Modules under “src/llms” integrate with external and open source LLM providers.
– Tools from “src/tools” (e.g., browser control, file management, search, etc.) support the agents.
e. Workflow and Graph Visualization:
– “src/graph” and “src/service/workflow_service.py” indicate a workflow graph supporting visualization and control (as mentioned in the README).
f. Configuration Management:
– “src/config” and the use of environment files (.env.example) and conf.yaml show a flexible multi-layer configuration system.
g. External Services and Dependencies:
– Mention integrations with external APIs such as Tavily for search, Jina for neural search, and third-party LLM providers (litellm).
– Docker infrastructure for deployment.

##### Relationships and Interactions
– From External Clients (Users/CLI) → to API Server (FastAPI endpoints)
– From the API Server → to the Multi-Agent Orchestrator (where the Supervisor delegates tasks)
– From the agents to external tool integrations (for web crawling, LLM decision making, file operations, etc.)

##### Architectural Patterns and Design
- Hierarchical multi-agent pattern – show how a supervisor coordinates specialized agents.
- Separation of concerns between different modules: API handling, business logic (agents), tool integrations, and configuration.
- Use labels that identify each component, and (if applicable) the purpose (e.g., “LLM Integration” or “Crawler Module”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        C_CLI["CLI (main.py)"]:::client
        C_Web["Web UI / API Client"]:::client
    end

    %% API Layer
    subgraph "API Layer"
        API["API Server (FastAPI, server.py)"]:::api
        Endpoints["API Endpoints (src/api/app.py)"]:::api
    end

    %% Orchestration Layer
    subgraph "Multi-Agent Orchestration"
        AgentsModule["Agents Module (src/agents)"]:::orchestration
        Prompts["Prompts (src/prompts)"]:::orchestration
        Supervisor["Supervisor Agent"]:::agent
        Coordinator["Coordinator Agent"]:::agent
        Planner["Planner Agent"]:::agent
        Researcher["Researcher Agent"]:::agent
        Coder["Coder Agent"]:::agent
        Browser["Browser Agent"]:::agent
        Reporter["Reporter Agent"]:::agent
    end

    %% Integration Modules
    subgraph "LLM & Tools Integration"
        LLM["LLM Integration (src/llms)"]:::llm
        Tools["Tools Module (src/tools)"]:::tools
    end

    subgraph "Crawler Module"
        Crawler["Crawler Module (src/crawler)"]:::crawler
    end

    subgraph "Workflow & Configuration"
        Workflow["Workflow Visualization (src/service/workflow_service.py)"]:::workflow
        Config["Configuration Management (src/config)"]:::config
    end

    %% Deployment Infrastructure
    subgraph "Deployment"
        Deploy["Deployment Infrastructure (Dockerfile)"]:::deploy
        Deploy2["Docker Compose (docker-compose.yml)"]:::deploy
    end

    %% Connections: Clients to API
    C_CLI -->|"initiate"| API
    C_Web -->|"request"| API

    %% API Layer Internal
    API -->|"routes to"| Endpoints
    Endpoints -->|"triggers"| Supervisor

    %% Orchestration: Agents Module & Prompts support the system
    AgentsModule ---|"provides logic"| Supervisor
    Prompts ---|"defines behaviors"| Supervisor

    %% Supervisor delegations to specialized agents
    Supervisor -->|"delegates"| Coordinator
    Supervisor -->|"delegates"| Planner
    Supervisor -->|"delegates"| Researcher
    Supervisor -->|"delegates"| Coder
    Supervisor -->|"delegates"| Browser
    Supervisor -->|"delegates"| Reporter

    %% Agents interact with integration components
    Supervisor ---|"calls"| LLM
    Coordinator ---|"requests"| LLM
    Planner ---|"queries"| Tools
    Researcher ---|"utilizes"| Tools
    Coder ---|"executes via"| Tools
    Browser ---|"controls"| Tools
    Reporter ---|"sends report to"| Workflow
    Supervisor ---|"updates"| Workflow
    Supervisor ---|"reads config from"| Config
    API ---|"loads settings from"| Config

    %% External module interactions
    Planner ---|"fetches data"| Crawler
    Researcher ---|"analyzes content from"| Crawler

    %% Feedback loop from Workflow Visualization to API layer
    Workflow -->|"feedback"| API

    %% Deployment connection (infrastructure supports entire system)
    API ---|"deployed using"| Deploy
    API ---|"orchestrated via"| Deploy2

    %% Click Events
    click C_CLI "https://github.com/maotouhu/byte-langmanus/blob/main/main.py"
    click API "https://github.com/maotouhu/byte-langmanus/blob/main/server.py"
    click Endpoints "https://github.com/maotouhu/byte-langmanus/blob/main/src/api/app.py"
    click AgentsModule "https://github.com/maotouhu/byte-langmanus/tree/main/src/agents"
    click Prompts "https://github.com/maotouhu/byte-langmanus/tree/main/src/prompts"
    click LLM "https://github.com/maotouhu/byte-langmanus/blob/main/src/llms/litellm_v2.py"
    click Tools "https://github.com/maotouhu/byte-langmanus/blob/main/src/tools/browser.py"
    click Crawler "https://github.com/maotouhu/byte-langmanus/blob/main/src/crawler/crawler.py"
    click Workflow "https://github.com/maotouhu/byte-langmanus/blob/main/src/service/workflow_service.py"
    click Config "https://github.com/maotouhu/byte-langmanus/tree/main/src/config"
    click Deploy "https://github.com/maotouhu/byte-langmanus/tree/main/Dockerfile"
    click Deploy2 "https://github.com/maotouhu/byte-langmanus/blob/main/docker-compose.yml"

    %% Styles
    classDef client fill:#ffdead,stroke:#8b4513,stroke-width:2px;
    classDef api fill:#add8e6,stroke:#00008b,stroke-width:2px;
    classDef orchestration fill:#98fb98,stroke:#006400,stroke-width:2px;
    classDef agent fill:#90ee90,stroke:#006400,stroke-width:2px;
    classDef llm fill:#ccffff,stroke:#008b8b,stroke-width:2px;
    classDef tools fill:#ffcccb,stroke:#8b0000,stroke-width:2px;
    classDef crawler fill:#cce5ff,stroke:#00008b,stroke-width:2px;
    classDef workflow fill:#e6ccff,stroke:#800080,stroke-width:2px;
    classDef config fill:#fffacd,stroke:#b8860b,stroke-width:2px;
    classDef deploy fill:#d3d3d3,stroke:#696969,stroke-width:2px;
```
