Autonomous fleet management with 18+ specialized AI agents
BARQ is evolving! We're integrating the production-proven ALOS (Advanced Logistics Optimization System) to deliver 15-20% efficiency improvements and enterprise-grade route optimization.
New Architecture (Q2 2025):
- AI-Route-Optimization-API: Orchestration layer with 18+ AI agents (LLM reasoning, operations management)
- ALOS Core Engine: 11 advanced VRP algorithms (Genetic, Ant Colony, Particle Swarm, Quantum-Inspired, etc.)
- Unified Platform: Best of both systems working together seamlessly
| Metric | Current | After ALOS | Improvement |
|---|---|---|---|
| Route Optimization Algorithms | 2-3 basic | 11 advanced | +8 algorithms |
| Execution Speed | ~150ms | <50ms | 67% faster |
| Route Quality | Baseline | +15-20% optimized | 15-20% better |
| ETA Accuracy | ~80% | >90% | +10% accuracy |
| Throughput | ~500 orders/min | 1,000+ orders/min | 2x capacity |
| Financial Impact | Baseline | SAR 10.95M/year savings | At 10K orders/day |
9-Week Integration Plan (Q2 2025):
- Week 1-2: Foundation (database migration, infrastructure)
- Week 3-4: Core Integration (11 algorithms, 6 engines)
- Week 5-6: Autonomous Systems (6 ALOS drivers)
- Week 7: Frontend & API updates
- Week 8: Testing & validation
- Week 9: Staged production rollout (10% β 50% β 100%)
π View Complete Integration Plan - Comprehensive 3,500+ line technical roadmap
β Production-Proven: Managing 800 couriers, 99.9% uptime β 15-20% Efficiency Gains: Documented in production β Advanced VRP Algorithms: 11 algorithms vs our current 2-3 β ML-Enhanced Predictions: TensorFlow/PyTorch models for >90% ETA accuracy β Enterprise Scale: 1,000+ orders/minute capacity
This integration preserves all our AI agents and LLM capabilities while adding world-class optimization.
BARQ Fleet Management is a next-generation logistics platform that uses artificial intelligence to autonomously manage instant delivery operations. Built with a multi-agent architecture, BARQ handles everything from route optimization and driver assignment to SLA monitoring and emergency escalation - all in real-time.
- Autonomous Operations: 18+ AI agents working together to optimize fleet operations
- Intelligent Route Optimization: Multi-stop route planning with real-time traffic consideration
- Predictive Analytics: Demand forecasting, traffic prediction, and capacity planning
- Auto-Reassignment: Automatic detection and resolution of SLA-risk orders
- Real-time Monitoring: Live fleet tracking, SLA compliance, and performance analytics
- Smart Decision Making: Context-aware routing considering weather, traffic, and special events
- BARQ: Express 1-hour delivery within 5km radius
- BULLET: Standard 2-4 hour city-wide delivery
Get up and running in 5 minutes:
# 1. Clone repository
git clone https://github.com/your-organization/AI-Route-Optimization-API.git
cd AI-Route-Optimization-API
# 2. Install dependencies
npm run install:all
# 3. Configure environment
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env.local
# Add your GROQ_API_KEY and NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN
# 4. Start services
npm run dev
# 5. Open in browser
# Frontend: http://localhost:3001
# API Docs: http://localhost:3003/api-docsSee QUICK_START.md for detailed setup instructions.
- Quick Start Guide - Get started in 5 minutes
- FAQ - Frequently asked questions
- π Full Documentation Index - Browse all technical docs
| Category | Guides |
|---|---|
| API | API Documentation β’ API Versioning |
| Development | Developer Guide β’ Code Quality β’ Commands Reference |
| Operations | Deployment Guide β’ Infrastructure β’ Maintenance Guide |
| Support | Troubleshooting β’ Production Checklist |
- Multi-stop route planning with OSRM integration
- Real-time traffic consideration
- Time window and constraint management
- Multi-vehicle fleet optimization
- Batch optimization for high-volume operations
Core Agents:
- Master Orchestrator - Coordinates all agent operations
- Order Assignment - Intelligent driver assignment
- Fleet Status - Real-time fleet monitoring
- SLA Monitor - Compliance tracking and alerts
Intelligence Agents:
- Demand Forecasting - Predictive demand analysis
- Traffic Pattern - Traffic prediction and routing
- Geo Intelligence - Location-based insights
- Performance Analytics - KPI tracking and reporting
Monitoring Agents:
- Fleet Rebalancer - Dynamic fleet distribution
- Emergency Escalation - Automated incident handling
- Order Recovery - Failed order resolution
- Penalty Calculator - Late delivery penalties
See DEVELOPER_GUIDE.md for complete agent documentation.
- Real-time performance dashboards
- Fleet utilization analytics
- Cost optimization recommendations
- Driver performance metrics
- SLA compliance reporting
- Predictive demand forecasting
- Live fleet tracking with Mapbox
- WebSocket-based real-time updates
- Order status tracking
- Driver state monitoring
- Alert and notification system
The GPT Fleet Optimizer provides AI-powered historical data analysis:
- Route Efficiency Analysis: Identify optimization opportunities with 0-100 scoring
- Fleet Performance Analytics: Driver Performance Index (DPI) and Vehicle Performance Index (VPI)
- Demand Forecasting: Hourly, daily, and weekly demand predictions with resource planning
- SLA Monitoring: Compliance tracking and breach analysis
- API Integration: Real-time integration with BARQ backend
The analytics module is a standalone Python application that can be deployed on Google Cloud Run or used via Custom GPT. See gpt-fleet-optimizer/README.md for complete documentation.
- Runtime: Node.js 20+ with TypeScript
- Framework: Express.js + Apollo GraphQL
- AI/ML: LangChain.js with GROQ API (llama-3.1-70b-versatile)
- Database: AWS RDS PostgreSQL 14+ (unified with ALOS)
- Cache: Redis 7+ (ElastiCache in production)
- Event Bus: RabbitMQ / AWS EventBridge
- API Docs: Swagger/OpenAPI + GraphQL Playground
- Routing: OSRM (Open Source Routing Machine)
- VRP Algorithms: 11 advanced algorithms
- Sweep Algorithm (3ms) - Ultra-fast for small batches
- Clarke-Wright Savings (6ms) - Cost-effective medium batches
- Genetic Algorithm (66ms) - High quality global optimization
- Ant Colony Optimization (67ms) - Complex constraint handling
- Particle Swarm Optimization (34ms) - Fast + quality balance
- Quantum-Inspired (74ms) - Global optimum search
- Simulated Annealing (45ms) - Large-scale problems
- Tabu Search (52ms) - Local search with memory
- Hybrid Metaheuristic (80ms) - Maximum quality
- ML-Enhanced Routing (60ms) - Pattern learning
- Game Theory Multi-Agent (55ms) - Multi-depot coordination
- ML Framework: TensorFlow / PyTorch for ETA predictions
- Core Engines: Route Optimization, ML Prediction, Dynamic Routing, Zone Clustering, Traffic Integration, Performance Analytics
- Autonomous Drivers: SERVICE_CLASSIFIER, SLA_GUARDIAN, ROUTE_OPTIMIZER, AUTO_DISPATCHER, PERFORMANCE_MONITOR, ANOMALY_DETECTOR
- Framework: Next.js 14
- Language: TypeScript
- UI Library: shadcn/ui
- State Management: Redux Toolkit
- Styling: Tailwind CSS
- Maps: Mapbox GL JS 3.0
- Real-time: WebSocket (Socket.IO) + GraphQL Subscriptions
- Containerization: Docker & Docker Compose
- Cloud Platform: AWS (Production)
- ECS Fargate (container orchestration)
- RDS PostgreSQL (Multi-AZ, unified database)
- ElastiCache Redis (caching layer)
- EventBridge / RabbitMQ (event bus)
- CloudFront (CDN)
- S3 (static assets)
- Monitoring: AWS CloudWatch + Prometheus + Grafana
- CI/CD: GitHub Actions / AWS CodePipeline
- Deployment: Blue-Green with auto-rollback
AI-Route-Optimization-API/
βββ backend/ # Node.js Express backend
β βββ src/
β β βββ agents/ # 18+ AI agents
β β βββ controllers/ # API controllers
β β βββ services/ # Business logic
β β βββ models/ # Data models
β β βββ routes/ # API routes
β β βββ middleware/ # Express middleware
β β βββ database/ # Database migrations
β βββ tests/ # Backend tests
β βββ Dockerfile
βββ frontend/ # Next.js frontend
β βββ src/
β β βββ app/ # Next.js App Router
β β βββ components/ # React components
β β βββ store/ # Redux store
β β βββ hooks/ # Custom React hooks
β βββ Dockerfile
βββ gpt-fleet-optimizer/ # Python analytics module
β βββ route_analyzer.py # Route efficiency analysis
β βββ fleet_performance.py # Driver/vehicle performance
β βββ demand_forecaster.py # Demand forecasting
β βββ api_connector.py # BARQ API integration
β βββ sla_analytics.py # SLA monitoring
β βββ README.md # Analytics documentation
βββ monitoring/ # Monitoring configuration
β βββ prometheus/
β βββ grafana/
βββ docs/ # Additional documentation
βββ scripts/ # Utility scripts
βββ docker-compose.yml # Docker orchestration
This API uses semantic versioning with URL-based version prefixes.
Current Version: v1 (Stable)
All API endpoints are available under the /api/v1/ prefix:
# Versioned endpoints (recommended)
POST /api/v1/optimize
GET /api/v1/agents/status
POST /api/v1/auth/loginLegacy unversioned endpoints are still supported but deprecated:
# Unversioned (deprecated, will show warnings)
POST /api/optimize # Still works, but use /api/v1/optimize
GET /api/agents/status # Still works, but use /api/v1/agents/statusNote: All endpoints below use the /api/v1 prefix. Legacy unversioned routes are supported but deprecated.
POST /api/v1/optimize- Submit a route optimization requestGET /api/v1/optimize/:requestId- Get optimization resultsGET /api/v1/optimize/status/:requestId- Check optimization statusGET /api/v1/optimize/history- Get optimization historyDELETE /api/v1/optimize/db/clear- Clear all optimization data
GET /api/v1/agents/status- Get system statusGET /api/v1/agents/health- Get agent health statusGET /api/v1/agents/fleet/status- Get fleet statusGET /api/v1/agents/sla/monitor- Get SLA monitoring statusPOST /api/v1/agents/order/assign- Assign order to driverPOST /api/v1/agents/batch/optimize- Optimize batch ordersGET /api/v1/agents/demand/forecast- Get demand forecastGET /api/v1/agents/geo/intelligence- Get geo intelligenceGET /api/v1/agents/traffic/patterns- Get traffic patternsGET /api/v1/agents/performance/analytics- Get performance analyticsPOST /api/v1/agents/emergency/escalate- Trigger emergency escalationPOST /api/v1/agents/recovery/initiate- Initiate order recoveryPOST /api/v1/agents/fleet/rebalance- Rebalance fleetPOST /api/v1/agents/orchestrate- Orchestrate multi-agent operation
POST /api/v1/auth/register- Register a new userPOST /api/v1/auth/login- Login userPOST /api/v1/auth/refresh- Refresh access tokenPOST /api/v1/auth/logout- Logout userGET /api/v1/auth/me- Get current user profile
GET /health- Basic health check (not versioned)GET /api- API information and version detailsGET /api/versions- Detailed version informationPOST /api/v1/agents/initialize- Initialize agent systemPOST /api/v1/agents/shutdown- Shutdown agent system
For detailed API documentation, visit http://localhost:3003/api-docs or see API_DOCUMENTATION.md
- Node.js: v20.17.0 or higher
- npm: v10.8.2 or higher
- GROQ API Key: Free tier available at https://console.groq.com/
- Mapbox Token: Free tier available at https://account.mapbox.com/
- Docker: v20.10+ and Docker Compose v2.0+
- PostgreSQL: v14+ (if not using Docker)
- Redis: v7+ (if not using Docker)
- GCP Account: For cloud deployment
# 1. Clone repository
git clone https://github.com/your-organization/AI-Route-Optimization-API.git
cd AI-Route-Optimization-API
# 2. Install all dependencies
npm run install:all
# 3. Configure backend
cp backend/.env.example backend/.env
# Edit backend/.env and add:
# - GROQ_API_KEY=your_groq_api_key
# 4. Configure frontend
cp frontend/.env.example frontend/.env.local
# Edit frontend/.env.local and add:
# - NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=your_mapbox_token
# - NEXT_PUBLIC_API_URL=http://localhost:3003
# 5. Start development servers
npm run dev# 1. Clone repository
git clone https://github.com/your-organization/AI-Route-Optimization-API.git
cd AI-Route-Optimization-API
# 2. Configure environment files (same as above)
# 3. Start with Docker Compose
docker-compose up -d
# 4. View logs
docker-compose logs -f
# 5. Access application
# Frontend: http://localhost:3001
# Backend: http://localhost:3003curl -X POST http://localhost:3003/api/v1/optimize \
-H "Content-Type: application/json" \
-d '{
"pickups": [{
"id": "pickup1",
"name": "Restaurant A",
"address": "123 Main St, Riyadh",
"coordinates": {"lat": 24.7136, "lng": 46.6753}
}],
"deliveries": [{
"id": "delivery1",
"name": "Customer 1",
"address": "456 King Fahd Rd, Riyadh",
"coordinates": {"lat": 24.7236, "lng": 46.6853}
}],
"constraints": {
"maxDistance": 50,
"maxTime": 120
}
}'curl http://localhost:3003/api/v1/agents/health | jq '.'curl http://localhost:3003/api/v1/agents/fleet/status | jq '.'See API_DOCUMENTATION.md for more examples.
# Run all tests
npm test
# Run backend tests only
cd backend && npm test
# Run frontend tests only
cd frontend && npm test
# Run with coverage
npm run test:coverage
# Run E2E tests
npm run test:e2e# Build production images
docker-compose -f docker-compose.prod.yml build
# Start production
docker-compose -f docker-compose.prod.yml up -d# Deploy backend
gcloud run deploy barq-backend \
--source ./backend \
--region us-central1
# Deploy frontend
gcloud run deploy barq-frontend \
--source ./frontend \
--region us-central1See DEPLOYMENT_GUIDE.md for complete deployment instructions.
BARQ includes built-in monitoring with Prometheus and Grafana:
# Start monitoring stack
docker-compose up -d prometheus grafana
# Access dashboards
# Prometheus: http://localhost:9090
# Grafana: http://localhost:3000 (admin/admin)Pre-configured Dashboards:
- System Overview
- Agent Performance
- API Metrics
- Database Performance
- Fleet Analytics
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CONTRIBUTING.md for detailed guidelines.
Backend won't start:
# Check logs
docker-compose logs backend
# Reinstall dependencies
cd backend && rm -rf node_modules && npm installMap not loading:
# Verify Mapbox token
cat frontend/.env.local | grep MAPBOX
# Rebuild frontend
cd frontend && rm -rf .next && npm run buildSee TROUBLESHOOTING.md for complete troubleshooting guide with 20+ common issues and solutions.
- Documentation: Comprehensive guides for all topics
- GitHub Issues: Bug reports and feature requests
- FAQ: FAQ.md with 30+ questions answered
- Priority email support
- Video call support
- Custom development
- Training sessions
- SLA guarantees
Contact: support@barq.com
- Multi-agent AI architecture (18+ agents)
- Real-time route optimization
- SLA monitoring and auto-reassignment
- WebSocket real-time updates
- Comprehensive documentation
- PostgreSQL migration (from lowdb)
Week 1-2: Foundation (Apr 2025)
- AWS RDS PostgreSQL setup (Multi-AZ)
- RabbitMQ event bus deployment
- Database migration (AI-Route β AWS RDS)
- Dual-write pattern implementation
Week 3-4: Core Integration (Apr-May 2025)
- ALOS npm package creation (@barq/alos-engine)
- ALOS Adapter implementation
- 11 VRP algorithms integration
- 6 Core Engines integration (Route Optimization, ML Prediction, etc.)
Week 5-6: Autonomous Systems (May 2025)
- 6 ALOS Drivers integration (SERVICE_CLASSIFIER, SLA_GUARDIAN, etc.)
- Event-driven architecture implementation
- Agent-to-driver coordination
Week 7: Frontend & API (May 2025)
- GraphQL API extensions (ALOS types and operations)
- REST API updates (/api/alos/v1/*)
- Next.js dashboard updates (algorithm selection UI, metrics visualization)
Week 8: Testing & Validation (May 2025)
- Unit testing (>80% coverage)
- Integration testing (end-to-end flows)
- Performance testing (1,000+ orders/min)
- A/B testing (10% ALOS vs 90% legacy)
Week 9: Production Deployment (Jun 2025)
- Staged rollout: 10% β 50% β 100%
- Blue-green deployment
- Monitoring and observability setup
- Go-live celebration π
Other Q2 Initiatives:
- Mobile app (iOS/Android)
- Advanced analytics dashboard
- Multi-language support
- WhatsApp integration
- ML model retraining with production data (ETA accuracy: 91% β 94%)
- Multi-depot optimization (Game Theory algorithm)
- Real-time rerouting enhancements
- Carbon footprint tracking
- Custom agent builder
- Multi-region expansion (Egypt, UAE, Jordan)
- White-label ALOS solution
- API marketplace for third-party developers
- Blockchain-based proof of delivery
- Drone delivery integration
- Autonomous zone creation (ML-powered)
- Seasonal demand adaptation
- Route optimization: < 2s for 5 stops, < 15s for 25 stops
- Algorithm execution: ~150ms average
- API response time: < 200ms (p95)
- Order throughput: 100-200 orders/sec (~500 orders/min)
- Concurrent users: 1000+ with horizontal scaling
- Agent response time: < 500ms average
Algorithm Performance:
- Sweep Algorithm: 3ms (ultra-fast for β€10 orders)
- Clarke-Wright: 6ms (fast for β€20 orders)
- Particle Swarm: 34ms (balanced for β€50 orders)
- Genetic Algorithm: 66ms (high quality for β€100 orders)
- Ant Colony: 67ms (complex constraints for β€150 orders)
- Hybrid Metaheuristic: 80ms (maximum quality for 200+ orders)
System Performance:
- Route optimization: 67% faster (<50ms p95 vs ~150ms)
- API response time: <200ms (p95) maintained
- Order throughput: 1,000+ orders/min (2x increase)
- ETA accuracy: >90% (vs ~80% current)
- Route quality: 15-20% better (distance/time reduction)
Financial Impact (at 10,000 orders/day):
- Fuel savings: SAR 2.25M/year
- Labor savings: SAR 8.51M/year
- Total savings: SAR 10.95M/year
- At 50,000 orders/day (Year 3): SAR 53.84M/year
- Vertical: Up to 8 CPU cores, 32GB RAM per instance
- Horizontal: Auto-scaling up to 100+ instances
- Database: AWS RDS Multi-AZ with read replicas (10K+ queries/sec)
- Cache: ElastiCache Redis cluster (100K+ ops/sec)
- Event Bus: RabbitMQ cluster (1,000+ messages/sec)
BARQ implements enterprise-grade security:
- JWT authentication with secure tokens
- Password hashing with bcrypt (10+ rounds)
- SQL injection prevention (parameterized queries)
- XSS protection with Content Security Policy
- CSRF protection
- Rate limiting (100 req/15min)
- Input validation on all endpoints
- HTTPS enforcement in production
- Regular security audits
See PRODUCTION_READINESS_CHECKLIST.md for complete security checklist.
MIT License - see LICENSE file for details.
Copyright (c) 2025 BARQ Fleet Management
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
- OSRM Team - Open Source Routing Machine
- GROQ - Fast LLM inference
- Mapbox - Beautiful mapping solutions
- LangChain - AI framework
- Next.js Team - React framework
- All Contributors - Thank you!
π Complete Integration Plan - 3,500+ line technical roadmap
- 9-week implementation timeline
- Database migration strategy
- API integration specifications
- Event-driven architecture
- Testing and deployment plan
- Risk mitigation strategies
- Success metrics and KPIs
π ALOS AI Platform PRD - Section 15
- Integration architecture diagrams
- Algorithm selection logic
- Component mapping
- Data flow integration
- Expected outcomes
Getting Started with ALOS Integration:
- Review the Integration Plan (Section 1-2: Current State Analysis)
- Understand the Target Architecture (Section 3)
- Check the Integration Mapping (Section 4) for your component
- Follow the 9-Week Implementation Plan (Section 8)
Key Integration Points:
- ALOS Adapter:
src/adapters/ALOSAdapter.ts- Smart algorithm selection - Event Bus:
src/infrastructure/EventBus.ts- RabbitMQ integration - GraphQL Extensions:
schema/alos.graphql- New ALOS types and operations - Database Migration:
scripts/migrate_to_aws_rds.sql- Data consolidation
Testing Your Integration:
# Run ALOS integration tests
npm run test:alos
# Run performance benchmarks
npm run benchmark:alos
# Run A/B test comparison
npm run test:ab -- --alos-percentage=10Current Phase: Planning & Foundation Setup (Week 0) Next Milestone: Week 1-2 Foundation (Apr 2025) Target Go-Live: Week 9 Production Rollout (Jun 2025)
- Integration Support: alos-integration@barq.com
- Technical Questions: Create an issue with label
alos-integration - Slack Channel: #alos-integration (internal team)
- Weekly Sync: Thursdays 2pm (AI/ML + Backend teams)
- Website: https://barq-logistics.com
- Email: support@barq.com
- GitHub: https://github.com/your-organization/AI-Route-Optimization-API
- Documentation: https://docs.barq-logistics.com
- Status Page: https://status.barq-logistics.com
- OSRM Team - Open Source Routing Machine
- GROQ - Fast LLM inference
- Mapbox - Beautiful mapping solutions
- LangChain - AI framework
- Next.js Team - React framework
- ALOS Team - Production-proven VRP optimization engine
- All Contributors - Thank you!
Built with β€οΈ for the logistics industry
Ready to get started? Follow the Quick Start Guide