šļø Complete Multi-Agent System Architecture
Diagrams a multi-agent system with a supervisor that routes user requests to calendar, email, or unified agents.
What this file does
Diagrams a multi-agent system with a supervisor that routes user requests to calendar, email, or unified agents.
When to use it
- Designing an architecture doc for a multi-agent app
- Planning a supervisor agent that delegates to specialized sub-agents
- Documenting a FastAPI backend with Google Calendar and Gmail integration
- Creating a visual reference for agent routing and decision logic
Assumes this stack
šļø Complete Multi-Agent System Architecture
šÆ System Overview
This document provides a visual representation of the complete multi-agent system architecture, showing how all components interact and work together.
šļø High-Level Architecture
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā USER INTERFACE ā
ā ā
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā ā
ā ā Web Client ā ā Mobile App ā ā API Client ā ā
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā ā
ā ā ā ā ā
ā āāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā ā¼ ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā FASTAPI SERVER ā ā
ā ā (Port 8000) ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā ā¼ ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā SUPERVISOR AGENT ā ā
ā ā (Intelligent Router) ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā ā¼ ā
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā ā
ā ā CALENDAR ā ā GMAIL ā ā UNIFIED ā ā
ā ā AGENT ā ā AGENT ā ā AGENT ā ā
ā ā (Specialized) ā ā (Specialized) ā ā (Combined) ā ā
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā ā
ā ā ā ā ā
ā ā¼ ā¼ ā¼ ā
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā ā
ā ā CALENDAR ā ā GMAIL ā ā BOTH ā ā
ā ā SERVICE ā ā SERVICE ā ā SERVICES ā ā
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā ā
ā ā ā ā ā
ā āāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā ā¼ ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā EXTERNAL APIs ā ā
ā ā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā ā
ā ā ā Google ā ā Gmail āā ā
ā ā ā Calendar ā ā API āā ā
ā ā ā API ā ā āā ā
ā ā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š Detailed Component Flow
1. Request Flow
User Request
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā FastAPI ā ā HTTP POST /api/supervisor/chat
ā Server ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Supervisor ā ā Intelligent task analysis
ā Agent ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Agent ā ā Route to appropriate agent
ā Selection ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Selected ā ā Execute task
ā Agent ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Service ā ā Make API calls
ā Layer ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā External ā ā Google APIs
ā APIs ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Response ā ā Format and return
ā Aggregation ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
User Response
šÆ Agent Capabilities Matrix
| Agent Type | Calendar Operations | Email Operations | Complex Workflows | Tools Available |
|---|---|---|---|---|
| Calendar Agent | ā Full Support | ā None | ā None | 8 tools |
| Gmail Agent | ā None | ā Full Support | ā None | 12 tools |
| Unified Agent | ā Full Support | ā Full Support | ā Full Support | 15 tools |
| Supervisor Agent | ā Routing | ā Routing | ā Routing | 0 tools |
š§ Technical Stack
Frontend Layer
- Web Clients: HTML/JS, React, Vue.js
- Mobile Apps: iOS, Android
- API Clients: Python, JavaScript, cURL
API Layer
- Framework: FastAPI
- Port: 8000
- Protocol: HTTP/HTTPS
- Authentication: API Keys, OAuth 2.0
Agent Layer
- Framework: LangChain
- LLM: OpenAI GPT-4o-mini
- Memory: ConversationBufferMemory
- Tools: StructuredTool
Service Layer
- Calendar Service: Google Calendar API
- Gmail Service: Gmail API
- HTTP Client: httpx
- Validation: Pydantic
External APIs
- Google Calendar API: v3
- Gmail API: v1
- Authentication: OAuth 2.0
š Data Flow Architecture
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā User Input āāāāā¶ā Supervisor āāāāā¶ā Task ā
ā ā ā Agent ā ā Analysis ā
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā ā
ā¼ ā¼
āāāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā Agent ā ā LLM + ā
ā Selection ā ā Keywords ā
āāāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāā
ā Route to ā
ā Agent ā
āāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāā
ā ā ā
ā¼ ā¼ ā¼
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā Calendar ā ā Gmail ā ā Unified ā
ā Agent ā ā Agent ā ā Agent ā
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā ā ā
ā¼ ā¼ ā¼
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā Calendar ā ā Gmail ā ā Both ā
ā Service ā ā Service ā ā Services ā
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā ā ā
ā¼ ā¼ ā¼
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā Google ā ā Gmail ā ā Google ā
ā Calendar ā ā API ā ā APIs ā
ā API ā ā ā ā ā
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
ā ā ā
āāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāā
ā Response ā
ā Aggregation ā
āāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāā
ā API Response ā
ā to User ā
āāāāāāāāāāāāāāāā
šÆ Decision Points
1. Supervisor Agent Decision Tree
User Request
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Task Analysis ā ā LLM + Keywords
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Agent ā ā Calendar | Gmail | Unified
ā Selection ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Execution ā ā Route to selected agent
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Response ā ā Format and return
ā Aggregation ā
āāāāāāāāāāāāāāāāāāā
2. Agent Selection Logic
Task Analysis
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Calendar ā ā Keywords: schedule, meeting, calendar
ā Keywords > 0? ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Email ā ā Keywords: email, send, mail
ā Keywords > 0? ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Complex ā ā Keywords: and, then, also
ā Keywords > 0? ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Select Agent ā ā Calendar | Gmail | Unified
āāāāāāāāāāāāāāāāāāā
š§ File Structure
multi_agent_supervisor/
āāā app/
ā āāā agents/
ā ā āāā calendar_agent.py # Calendar operations
ā ā āāā gmail_agent.py # Email operations
ā ā āāā unified_agent.py # Combined operations
ā ā āāā supervisor_agent.py # Intelligent router
ā āāā api/
ā ā āāā endpoints/
ā ā āāā __init__.py # Router aggregation
ā ā āāā calendar.py # Calendar endpoints
ā ā āāā gmail.py # Gmail endpoints
ā ā āāā unified.py # Unified endpoints
ā ā āāā supervisor.py # Supervisor endpoints
ā āāā services/
ā ā āāā calendar_service.py # Google Calendar API
ā ā āāā gmail_service.py # Gmail API
ā āāā tools/
ā ā āāā calendar_tool.py # Calendar tools
ā ā āāā gmail_tool.py # Gmail tools
ā ā āāā time_tool.py # Time utilities
ā āāā schema/
ā ā āāā calendar_schema.py # Calendar models
ā ā āāā gmail_schema.py # Gmail models
ā āāā config.py # Environment variables
ā āāā main.py # FastAPI app
āāā tests/
ā āāā test_supervisor_agent.py # Supervisor tests
ā āāā test_gmail.py # Gmail tests
ā āāā test_unified_agent.py # Unified tests
āāā docs/
ā āāā SUPERVISOR_AGENT_README.md
ā āāā SUPERVISOR_AGENT_FLOW.md
ā āāā GMAIL_README.md
ā āāā UNIFIED_AGENT_README.md
āāā requirements.txt
āāā README.md
š Performance Metrics
Response Times
- Supervisor Analysis: 1-2 seconds
- Calendar Agent: 2-3 seconds
- Gmail Agent: 2-3 seconds
- Unified Agent: 4-6 seconds
Throughput
- Concurrent Requests: 10-50 requests/second
- Memory Usage: 100-500 MB
- CPU Usage: 20-60%
Scalability
- Horizontal: Add more agent instances
- Vertical: Scale individual agents
- Load Balancing: Route by agent type
š Monitoring Points
1. Request Monitoring
- Request volume per agent
- Response times per agent
- Error rates per agent
- Success rates per agent
2. Agent Monitoring
- Agent selection frequency
- Tool usage patterns
- Memory usage per agent
- CPU usage per agent
3. API Monitoring
- External API response times
- API error rates
- Rate limiting status
- Token usage
4. System Monitoring
- Overall system health
- Resource utilization
- Network connectivity
- Database performance
š Deployment Architecture
Development Environment
āāāāāāāāāāāāāāāāāāā
ā Local Machine ā
ā (Development) ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā FastAPI ā
ā (Port 8000) ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Agents ā
ā (Local) ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Google APIs ā
ā (External) ā
āāāāāāāāāāāāāāāāāāā
Production Environment
āāāāāāāāāāāāāāāāāāā
ā Load Balancer ā
ā (Nginx) ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā FastAPI ā
ā (Multiple) ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Agent Pool ā
ā (Scaled) ā
āāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Google APIs ā
ā (External) ā
āāāāāāāāāāāāāāāāāāā
šÆ Key Benefits
1. Intelligent Routing
- Automatically selects most efficient agent
- Optimizes performance and cost
- Reduces unnecessary complexity
2. Scalable Architecture
- Modular design
- Independent agent scaling
- Easy to add new agents
3. Robust Error Handling
- Multiple fallback strategies
- Graceful degradation
- Comprehensive error reporting
4. User Experience
- Single entry point
- Consistent interface
- Detailed response information
š System Summary
The multi-agent system provides:
- 4 Specialized Agents: Calendar, Gmail, Unified, Supervisor
- Intelligent Routing: Automatic agent selection
- Comprehensive APIs: Full calendar and email functionality
- Robust Architecture: Scalable and maintainable
- Production Ready: Error handling and monitoring
This architecture enables efficient, intelligent, and scalable calendar and email management through a single, unified interface.
What's inside
7 architecture diagrams, 1 agent capabilities matrix, 1 file tree, 1 technical stack table, and 1 deployment diagram
Change this for your project
- Replace
multi_agent_supervisor/with your own project name - Replace
Amanastel/multi_agent_supervisorwith your repository path - Replace
OpenAI GPT-4o-miniwith your chosen LLM model - Replace
Port 8000with your actual server port
Where it goes
Save in docs/ or the repository root. Gives agents and new contributors a map of the codebase.
Worth borrowing
- Use a decision tree diagram to show how the supervisor selects an agent based on keyword presence
- Separate agent capabilities into a matrix so readers can see which agent handles which operations at a glance
Related Documents
Design Document: BharatSeva AI
Describes a 10-agent AWS system that helps India's informal workers access government schemes via voice-first, serverless architecture.
OpenClaw Enterprise Transformation Plan
Transforms a single-user AI agent into a dual-mode platform supporting both viral open-source and Fortune 500 enterprise deployments through phased security, IAM, audit, multi-tenancy, and Kubernetes features.
Qwen Image and Edit: Open-sourcing and Local GGUF Generations with Lightning
Documents the Qwen-Image and Qwen-Image-Edit models, covering architecture, training, benchmarks, ComfyUI setup, and prompting techniques for local GGUF deployment.
University of Guelph Rocketry Club - Complete Tech Stack
Documents the full tech stack of a university rocketry club website with AI chatbot, member management, and project showcases.