# mantrakp04/manusmcp architecture

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

- Interactive diagram: https://gitdiagram.com/mantrakp04/manusmcp
- Repository: https://github.com/mantrakp04/manusmcp

## Overview

##### Project’s Key Components
a. Runtime & Services (.runtime):
- Contains the core runtime code, written in TypeScript and executed using Bun.
- Provides low-level services such as browserService, fileService, and shellService.
- Includes reusable types and templates (e.g., a Next.js template) which hint at generating UI or server components dynamically.
b. AI Agent Logic & Flows (pytools):
- Contains Python tools and configurations.
- Holds “flows” (e.g., Agents.json files for both v2.2 and v2.3 versions) that define the behavior and interactions of the AI agents.
- Includes deployment scripts (flowise.sh) and Docker configurations for containerized execution.
c. Frontend & Web Server (site):
- Contains a Next.js application that serves as the user interface.
- Provides components for interacting with chat, posts, and other UI elements which can be used to interact with the AI agents.
- Houses API endpoints (including trpc endpoints and REST routes) that bridge frontend actions to backend services.
- Implements API routes bringing in agent interactions and commands.
d. Orchestration & Communication:
- The MCP Server (possibly invoked via bunx @modelcontextprotocol/inspector uv run manusmcp) ties together these components.
- There’s the overarching use of Docker (docker-compose.yml at the root, pytools, and site) which orchestrates containers for different layers (runtime, web server, and agent flows).

- Frontend (Next.js Application, located in the “site” directory).
- API / Server Backend (inside “site/src/server”, “site/api”, and TRPC integration).
- Agent Orchestration & Services (represented by the “pytools” components handling flows and configurations).
- Core Services Engine & Utilities (encapsulated in “.runtime”, which includes services and templates to support both development and deployment).
- External Services: Flowise UI (accessible on a dedicated port) for designing agent flows and integration with Anthropic model endpoints (as noted in the README).
b. How these components interconnect:
- The Core Services (.runtime) provide essential utilities (file, shell, browser services) to both the Frontend and backend environments. Indicate helper relationships or dependency links.
- Use a Docker container block to represent the containerized deployment of the runtime, webserver, and agent modules orchestrated via docker-compose.
c. Important architectural patterns:
- Modularization: Each folder (runtime, pytools, site) stands as a modular component.
- Service Orchestration: The MCP server and Flowise integration abstract the complex communication among specialized agents.
- API Gateway: The separation of frontend and API endpoints (using TRPC routing) showcases a layered architecture for request routing.

##### Detail the Interactions and Technologies
- Technologies & Frameworks:
- Bun runtime for TypeScript execution.
- Next.js framework for the frontend.
- TRPC for building type-safe APIs.
- Docker for container orchestration.
- Python based agent flows and configuration for AI tasks.
- Data Flow:
- User interacts with the site application – this sends requests to the backend API.
- The backend processes these requests, potentially delegating tasks to the AI agents defined in pytools.
- The core runtime services in .runtime handle underpinning tasks (file manipulations, executing shell commands, managing browser tasks) supporting both the agent logic and the UI templates.
- Flowise acts as an external orchestration layer where agents’ flows can be viewed and managed.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% User Interaction
    U1["Browser (User)"]:::external

    %% Docker Compose Files
    subgraph "Docker Compose Files"
        D1["Root docker-compose.yml"]:::docker
        D2["pytools/docker-compose.yml"]:::docker
        D3["site/docker-compose.yml"]:::docker
    end

    %% Docker Environment
    subgraph "Docker Environment"
        
        %% Frontend & API Layer (site)
        subgraph "Frontend & API (site)"
            A1["Next.js Frontend (site)"]:::frontend
            A2["API Endpoints (site)"]:::frontend
            A3["UI Components (site)"]:::frontend
        end

        %% AI Agent Orchestration (pytools)
        subgraph "Agent Orchestration (pytools)"
            B1["Agent Flows (pytools)"]:::agent
            B2["Deployment Script (pytools)"]:::agent
            B3["MCP Server (pytools)"]:::agent
        end

        %% Core Utility Services (.runtime)
        subgraph "Core Utility Services (.runtime)"
            C1["Services (.runtime)"]:::core
            C2["Types (.runtime)"]:::core
            C3["Templates (.runtime)"]:::core
        end
    end

    %% External Integration
    E1["Flowise UI"]:::external

    %% Interactions
    U1 -->|"interacts"| A1
    A1 -->|"renders"| A3
    A1 -->|"APIcalls"| A2
    A2 -->|"delegates"| B1
    A2 -->|"utilizes"| C1
    B1 -->|"depends"| C1
    B1 -->|"invokes"| B3
    B1 -->|"integrates"| E1

    %% Docker orchestration arrows
    D1 ---|"orchestrates"| A1
    D2 ---|"orchestrates"| B1
    D3 ---|"orchestrates"| C1

    %% Styling Classes
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef agent fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef core fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef docker fill:#FFA500,stroke:#000,stroke-width:2px;

    %% Click Events for .runtime
    click C1 "https://github.com/mantrakp04/manusmcp/tree/main/.runtime/src/services"
    click C2 "https://github.com/mantrakp04/manusmcp/blob/main/.runtime/src/types/index.ts"
    click C3 "https://github.com/mantrakp04/manusmcp/tree/main/.runtime/templates/nextjs"

    %% Click Events for pytools
    click B1 "https://github.com/mantrakp04/manusmcp/tree/main/pytools/flows"
    click B2 "https://github.com/mantrakp04/manusmcp/blob/main/pytools/flowise.sh"
    click B3 "https://github.com/mantrakp04/manusmcp/tree/main/pytools/src/manusmcp"

    %% Click Events for site
    click A1 "https://github.com/mantrakp04/manusmcp/tree/main/site"
    click A2 "https://github.com/mantrakp04/manusmcp/tree/main/site/src/app/api"
    click A3 "https://github.com/mantrakp04/manusmcp/tree/main/site/src/app/_components"

    %% Click Events for Docker Compose Files
    click D1 "https://github.com/mantrakp04/manusmcp/blob/main/docker-compose.yml"
    click D2 "https://github.com/mantrakp04/manusmcp/blob/main/pytools/docker-compose.yml"
    click D3 "https://github.com/mantrakp04/manusmcp/blob/main/site/docker-compose.yml"
```
