Skip to content

mafaq229/multi-agent-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Multi-Agent System for Munder Difflin Paper Company

CI codecov Python 3.11+ Code style: ruff

A production-ready, industry-grade multi-agent system for automating business operations at Munder Difflin Paper Company. This project demonstrates advanced software engineering practices combined with modern agentic AI patterns.

🎯 Overview

This system coordinates four specialized AI agents to handle:

  • Inventory Management: Stock monitoring, reorder decisions, supplier coordination
  • Quote Generation: Pricing calculations, bulk discounts, historical analysis
  • Order Fulfillment: Order processing, inventory allocation, transaction recording
  • Orchestration: Workflow coordination, intent routing, customer communication

✨ Features

Core Capabilities

  • πŸ€– Multi-Agent Architecture: Specialized agents with clear responsibilities
  • πŸ”„ Workflow Orchestration: Seamless coordination between agents
  • πŸ’Ύ Database Management: SQLAlchemy ORM with Alembic migrations
  • 🌐 REST API: FastAPI with automatic OpenAPI documentation
  • πŸ“Š Financial Reporting: Real-time cash balance and inventory valuation
  • πŸ” Historical Analysis: Quote history search and pricing guidance

Advanced Features

  • ⚑ Caching Layer: Redis for performance optimization
  • πŸ”„ Background Jobs: Celery for async processing
  • πŸ“ˆ Observability: Structured logging, metrics, and tracing
  • πŸ§ͺ Comprehensive Testing: Unit, integration, and e2e tests
  • 🐳 Containerization: Docker and Docker Compose setup
  • πŸ” Security: Rate limiting, API authentication, secrets management

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        API Gateway Layer                         β”‚
β”‚                     (FastAPI REST API)                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Agent Orchestration Layer                     β”‚
β”‚         (Orchestrator + Specialized Agents)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Business Logic Layer                        β”‚
β”‚        (Services, Repositories, Domain Models)                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       Data Access Layer                          β”‚
β”‚              (SQLAlchemy ORM + Alembic)                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

For detailed architecture documentation, see docs/architecture/system-design.md.

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • uv (recommended) or pip
  • Redis (optional, for caching)
  • PostgreSQL (optional, SQLite works for development)

Installation

# Clone the repository
git clone https://github.com/yourusername/multi-agent-system.git
cd multi-agent-system

# Install dependencies
make setup

# Configure environment
cp .env.example .env
# Edit .env with your settings (especially OPENAI_API_KEY)

# Initialize database
make init-db

# Seed with sample data
make seed

Running the Application

# Start the API server
make run

# In another terminal, start the worker (optional)
make run-worker

# API will be available at http://localhost:8000
# API docs at http://localhost:8000/docs

Using Docker

# Build and start all services
make docker-up

# View logs
make docker-logs

# Stop services
make docker-down

πŸ“š Documentation

πŸ§ͺ Testing

# Run all tests
make test

# Run with coverage
make test-cov

# Run specific test types
make test-unit
make test-integration
make test-e2e

# Run type checks
make typecheck

# Run linting
make lint

πŸ“Š Project Structure

multi-agent-system/
β”œβ”€β”€ src/multi_agent_system/     # Main application code
β”‚   β”œβ”€β”€ api/                    # FastAPI application
β”‚   β”œβ”€β”€ agents/                 # Agent implementations
β”‚   β”œβ”€β”€ core/                   # Core utilities
β”‚   β”œβ”€β”€ database/               # Database layer
β”‚   β”œβ”€β”€ domain/                 # Domain models
β”‚   β”œβ”€β”€ services/               # Business logic
β”‚   └── utils/                  # Utility functions
β”œβ”€β”€ tests/                      # Test suite
β”‚   β”œβ”€β”€ unit/                   # Unit tests
β”‚   β”œβ”€β”€ integration/            # Integration tests
β”‚   └── e2e/                    # End-to-end tests
β”œβ”€β”€ docs/                       # Documentation
β”œβ”€β”€ docker/                     # Docker configuration
β”œβ”€β”€ scripts/                    # Utility scripts
└── pyproject.toml             # Project configuration

πŸŽ“ Learning Outcomes

This project demonstrates:

Software Engineering

  • Architecture Patterns: Layered architecture, repository pattern, dependency injection
  • API Design: RESTful principles, request/response modeling, error handling
  • Database Design: ORM patterns, migrations, query optimization
  • Testing Strategies: Unit, integration, and e2e testing with high coverage
  • DevOps Practices: Containerization, CI/CD pipelines, monitoring

Agentic AI

  • Agent Design Patterns: Orchestrator pattern, specialized agents, tool use
  • Prompt Engineering: System prompts, few-shot learning, chain-of-thought
  • Agent Communication: Message passing, state management, workflow orchestration
  • LLM Integration: API integration, error handling, cost optimization

πŸ› οΈ Development

Common Commands

make help              # Show all available commands
make dev               # Install dev dependencies
make run               # Start API server
make test              # Run tests
make format            # Format code
make lint              # Run linter
make typecheck         # Run type checks
make docker-up         # Start all services

Adding a New Agent

  1. Create agent class in src/multi_agent_system/agents/
  2. Define agent tools in src/multi_agent_system/agents/tools/
  3. Add prompts in src/multi_agent_system/agents/prompts/
  4. Register agent in orchestrator
  5. Add tests in tests/unit/test_agents/

See Development Guide for details.

πŸ™ Acknowledgments

  • Original concept from Udacity AI Agents course
  • Built with pydantic-ai
  • Powered by FastAPI

πŸ“§ Contact

Your Name - muhammadafaq1999@gmail.com

Project Link: https://github.com/mafaq229/multi-agent-system

About

The system aims for coordination between specialized agents for inventory management, quote generation, and order fulfillment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors