# πŸ€– LogiFlow AI - Autonomous Logistics Agent System A complete multi-agent AI system for autonomous logistics operations. Built with Python, featuring 8 intelligent agents coordinated by a master orchestrator (JARVIS). ## πŸ—οΈ Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ 🧠 JARVIS (Master Agent) β”‚ β”‚ Central orchestrator & decision maker β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β–Ό β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ ORDER_AGENT β”‚ β”‚ DISPATCH_AGENT β”‚ β”‚ FLEET_AGENT β”‚ β”‚ ─────────────│ β”‚ ────────────────│ β”‚ ────────────────│ β”‚ β€’ Receive β”‚ β”‚ β€’ Analyze zones β”‚ β”‚ β€’ Vehicle statusβ”‚ β”‚ β€’ Validate β”‚ β”‚ β€’ Assign routes β”‚ β”‚ β€’ Capacity mgmt β”‚ β”‚ β€’ Categorize β”‚ β”‚ β€’ Route opt. β”‚ β”‚ β€’ Maintenance β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β–Ό β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ HUB_AGENT β”‚ β”‚ CUSTOMER_AGENT β”‚ β”‚ EXCEPTION_AGENT β”‚ β”‚ ─────────────│ β”‚ ────────────────│ β”‚ ────────────────│ β”‚ β€’ Hub routing β”‚ β”‚ β€’ Notifications β”‚ β”‚ β€’ Delay handlingβ”‚ β”‚ β€’ Transit mgmtβ”‚ β”‚ β€’ Tracking β”‚ β”‚ β€’ Rescheduling β”‚ β”‚ β€’ Capacity β”‚ β”‚ β€’ Feedback β”‚ β”‚ β€’ Cancellations β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ROUTE_OPTIMIZER β”‚ β”‚ ────────────────│ β”‚ β€’ Zone planning β”‚ β”‚ β€’ Pathfinding β”‚ β”‚ β€’ Traffic adapt β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ## ✨ Features ### πŸ€– Intelligent Agents | Agent | Function | Key Capabilities | |-------|----------|-----------------| | **JARVIS** | Master Orchestrator | Task delegation, system monitoring, decision making | | **ORDER_AGENT** | Order Management | Receive, validate, categorize orders by priority/zone | | **DISPATCH_AGENT** | Route Assignment | Zone analysis, hub assignment, route planning | | **FLEET_AGENT** | Vehicle Management | Capacity tracking, vehicle assignment, maintenance | | **HUB_AGENT** | Hub Operations | Transit management, capacity monitoring, overflow handling | | **CUSTOMER_AGENT** | Customer Communication | Notifications, tracking updates, support | | **EXCEPTION_AGENT** | Problem Resolution | Delay handling, cancellations, rescheduling | | **ROUTE_OPTIMIZER** | Route Planning | Zone-based optimization, path calculation | ### πŸ”„ Agent Communication Flow ``` Order Received β†’ ORDER_AGENT validates β†’ DISPATCH_AGENT assigns route ↓ ↓ FLEET_AGENT assigns vehicle β†’ HUB_AGENT prepares receiving ↓ ↓ ROUTE_OPTIMIZER calculates path β†’ CUSTOMER_AGENT sends notification ↓ EXCEPTION_AGENT monitors (handles any issues) ↓ JARVIS monitors all agents, logs decisions, reports to admin ``` ## πŸš€ Quick Start ### 1. Install Dependencies ```bash cd /workspace/project/logistics-ai pip install -r requirements.txt ``` ### 2. Run Demo Mode ```bash python main.py ``` This will: - Initialize all 8 agents - Run system diagnostics - Process a sample order through all agents - Display complete agent coordination ### 3. Launch Admin Dashboard ```bash python main.py --dashboard ``` Opens Streamlit dashboard at `http://localhost:8501` with: - Real-time agent status monitoring - Order management - Fleet tracking - Hub network visualization - Message feed ### 4. Launch Customer Portal ```bash python main.py --portal ``` Opens customer-facing portal at `http://localhost:8502` with: - Order tracking - Live updates - AI assistant chat - Delivery scheduling ## πŸ“ Project Structure ``` logistics-ai/ β”œβ”€β”€ main.py # Main orchestration & demo β”œβ”€β”€ requirements.txt # Python dependencies β”œβ”€β”€ core/ β”‚ β”œβ”€β”€ __init__.py β”‚ β”œβ”€β”€ types.py # Data models & message types β”‚ β”œβ”€β”€ agent.py # Base Agent, MasterAgent classes β”‚ └── message_bus.py # Agent communication bus β”œβ”€β”€ agents/ β”‚ β”œβ”€β”€ __init__.py β”‚ β”œβ”€β”€ order_agent.py # Order validation & categorization β”‚ β”œβ”€β”€ dispatch_agent.py # Route assignment & zone analysis β”‚ β”œβ”€β”€ fleet_agent.py # Vehicle management β”‚ β”œβ”€β”€ hub_agent.py # Hub operations & transit β”‚ β”œβ”€β”€ customer_agent.py # Notifications & tracking β”‚ β”œβ”€β”€ exception_agent.py # Problem resolution β”‚ └── route_optimizer_agent.py # Route optimization β”œβ”€β”€ dashboard/ β”‚ └── admin_dashboard.py # Streamlit admin interface β”œβ”€β”€ customer_portal/ β”‚ └── portal.py # Streamlit customer interface └── config/ └── system_config.py # Configuration & zone definitions ``` ## πŸ”§ Configuration Edit `config/system_config.py` to customize: - **Zones**: Pincode ranges and hub assignments - **Hubs**: Capacity, processing rates, connections - **Vehicles**: Types, capacities, fuel costs - **SLA**: Delivery windows, response times - **Notifications**: Templates for SMS/Email/WhatsApp ## 🎯 Usage Examples ### Create an Order via API ```python from main import LogiFlowAI system = LogiFlowAI() system.initialize_agents() order = { "customer_name": "Rajesh Kumar", "customer_phone": "+919876543210", "pickup_address": {"city": "Delhi", "pincode": "110001"}, "delivery_address": {"city": "Mumbai", "pincode": "400001"}, "items": [{"name": "Laptop", "weight": 2.5}] } await system.create_order(order) ``` ### Monitor System Status ```python status = system.get_system_status() print(f"Active agents: {len(status['agents'])}") print(f"System: {status['system']}") ``` ## πŸ”Œ Integration Points ### REST API (Future) - `POST /orders` - Create new order - `GET /orders/{id}` - Get order status - `PATCH /orders/{id}` - Update order - `GET /agents/status` - Get agent statuses - `POST /agents/{id}/task` - Submit task to agent ### Webhook Support (Future) - Order created - Order status changed - Exception detected - Delivery completed ## πŸ“Š Monitoring The system provides: - Real-time agent status - Message traffic monitoring - Performance metrics - Exception alerts - SLA compliance tracking ## πŸ”’ Security - Agent authentication via tokens - Message signing and verification - Rate limiting on API endpoints - Audit logging for all operations ## πŸš€ Scaling The architecture supports: - Horizontal agent scaling - Multiple message bus instances - Distributed hub networks - Multi-region deployment ## πŸ“ License MIT License - See LICENSE file ## 🀝 Contributing Contributions welcome! Please: 1. Fork the repository 2. Create a feature branch 3. Add tests for new features 4. Submit a pull request --- **Built with ❀️ for autonomous logistics operations** Resume this session with: claude --resume d1f8a432-2298-4ff5-bee4-15e64d04bfa4 PS C:\Users\Admin\Downloads\logiflow-ai-logistics-agent-system\logistics-ai>