|
|
--- |
|
|
title: FleetMind AI Dispatch Coordinator |
|
|
emoji: π |
|
|
colorFrom: blue |
|
|
colorTo: purple |
|
|
sdk: gradio |
|
|
sdk_version: 5.9.0 |
|
|
app_file: app.py |
|
|
pinned: false |
|
|
tags: |
|
|
- mcp |
|
|
- mcp-in-action-track-01 |
|
|
- model-context-protocol |
|
|
- multi-agent |
|
|
- autonomous-ai |
|
|
- gemini-2.0-flash |
|
|
- delivery-management |
|
|
- postgresql |
|
|
--- |
|
|
|
|
|
# FleetMind MCP - Autonomous Dispatch Coordinator |
|
|
|
|
|
**π MCP 1st Birthday Hackathon Submission - Track: MCP in Action** |
|
|
|
|
|
An autonomous AI coordinator that handles delivery exceptions using multi-agent orchestration powered by Google Gemini 2.0 Flash and the Model Context Protocol (MCP). |
|
|
|
|
|
**π Links:** |
|
|
- **GitHub Repository:** https://github.com/mashrur-rahman-fahim/fleetmind-mcp |
|
|
- **Hugging Face Space:** https://huggingface.co/spaces/MCP-1st-Birthday/fleetmind-dispatch-ai |
|
|
- **Auto-Sync:** Every push to GitHub automatically updates HF Space via GitHub Actions β¨ |
|
|
|
|
|
--- |
|
|
|
|
|
## π₯ Team |
|
|
|
|
|
**Team Name:** [Your Team Name] |
|
|
|
|
|
**Team Members:** |
|
|
- **[Your Name]** - [@your-hf-username](https://huggingface.co/your-hf-username) - Lead Developer & Repository Manager |
|
|
- **[Partner 2 Name]** - [@partner2-username](https://huggingface.co/partner2-username) - [Role - e.g., Backend Developer, Testing] |
|
|
|
|
|
|
|
|
**Collaboration:** Team collaborates via GitHub repository (https://github.com/mashrur-rahman-fahim/fleetmind-mcp) with automatic sync to HF Space via GitHub Actions. |
|
|
|
|
|
*(Note: Replace placeholders with actual team member information. All members must have Hugging Face accounts and be listed here for valid hackathon submission.)* |
|
|
|
|
|
--- |
|
|
|
|
|
## π Quick Start |
|
|
|
|
|
### 1. Install PostgreSQL |
|
|
|
|
|
**Windows:** |
|
|
- Download from https://www.postgresql.org/download/windows/ |
|
|
- Install with default settings |
|
|
- Remember your postgres password |
|
|
|
|
|
**macOS:** |
|
|
```bash |
|
|
brew install postgresql |
|
|
brew services start postgresql |
|
|
``` |
|
|
|
|
|
**Linux:** |
|
|
```bash |
|
|
sudo apt-get install postgresql postgresql-contrib |
|
|
sudo systemctl start postgresql |
|
|
``` |
|
|
|
|
|
### 2. Create Database |
|
|
|
|
|
```bash |
|
|
# Login to PostgreSQL |
|
|
psql -U postgres |
|
|
|
|
|
# Create the database |
|
|
CREATE DATABASE fleetmind; |
|
|
|
|
|
# Exit |
|
|
\q |
|
|
``` |
|
|
|
|
|
### 3. Set Up Environment |
|
|
|
|
|
```bash |
|
|
# Install Python dependencies |
|
|
pip install -r requirements.txt |
|
|
|
|
|
# Copy environment template |
|
|
cp .env.example .env |
|
|
|
|
|
# Edit .env with your database credentials |
|
|
# DB_HOST=localhost |
|
|
# DB_PORT=5432 |
|
|
# DB_NAME=fleetmind |
|
|
# DB_USER=postgres |
|
|
# DB_PASSWORD=your_password_here |
|
|
``` |
|
|
|
|
|
### 4. Initialize Database Schema |
|
|
|
|
|
```bash |
|
|
# Run database initialization script |
|
|
python scripts/init_db.py |
|
|
``` |
|
|
|
|
|
This will create all necessary tables in the PostgreSQL database. |
|
|
|
|
|
### 3. Run Application |
|
|
|
|
|
```bash |
|
|
# Start the Gradio UI (coming soon) |
|
|
python ui/app.py |
|
|
``` |
|
|
|
|
|
## π Project Structure |
|
|
|
|
|
``` |
|
|
fleetmind-mcp/ |
|
|
βββ database/ # Database connection and schema |
|
|
β βββ __init__.py |
|
|
β βββ connection.py # Database connection utilities |
|
|
β βββ schema.py # Database schema definitions |
|
|
βββ data/ # Database and data files |
|
|
β βββ fleetmind.db # SQLite database (auto-generated) |
|
|
βββ mcp_server/ # MCP server implementation |
|
|
βββ agents/ # Multi-agent system |
|
|
βββ workflows/ # Orchestration workflows |
|
|
βββ ui/ # Gradio interface |
|
|
βββ tests/ # Test suite |
|
|
βββ scripts/ # Utility scripts |
|
|
β βββ init_db.py # Database initialization |
|
|
βββ requirements.txt # Python dependencies |
|
|
βββ .env.example # Environment variables template |
|
|
βββ README.md # This file |
|
|
``` |
|
|
|
|
|
## π Database Schema (PostgreSQL) |
|
|
|
|
|
The system uses PostgreSQL with the following tables: |
|
|
|
|
|
### Orders Table |
|
|
|
|
|
The `orders` table stores all delivery order information: |
|
|
|
|
|
| Column | Type | Description | |
|
|
|--------|------|-------------| |
|
|
| order_id | VARCHAR(50) | Primary key | |
|
|
| customer_name | VARCHAR(255) | Customer name | |
|
|
| customer_phone | VARCHAR(20) | Contact phone | |
|
|
| customer_email | VARCHAR(255) | Contact email | |
|
|
| delivery_address | TEXT | Delivery address | |
|
|
| delivery_lat/lng | DECIMAL(10,8) | GPS coordinates | |
|
|
| time_window_start/end | TIMESTAMP | Delivery time window | |
|
|
| priority | VARCHAR(20) | standard/express/urgent | |
|
|
| weight_kg | DECIMAL(10,2) | Package weight | |
|
|
| status | VARCHAR(20) | pending/assigned/in_transit/delivered/failed/cancelled | |
|
|
| assigned_driver_id | VARCHAR(50) | Assigned driver | |
|
|
| created_at | TIMESTAMP | Creation timestamp | |
|
|
| updated_at | TIMESTAMP | Auto-updated timestamp | |
|
|
|
|
|
### Additional Tables |
|
|
|
|
|
- **drivers** - Driver information and status |
|
|
- **assignments** - Order-driver assignments with routing |
|
|
- **exceptions** - Exception tracking and resolution |
|
|
- **agent_decisions** - AI agent decision logging |
|
|
- **metrics** - Performance metrics and analytics |
|
|
|
|
|
## π§ Development |
|
|
|
|
|
### Database Operations |
|
|
|
|
|
```python |
|
|
from database.connection import get_db_connection, execute_query, execute_write |
|
|
|
|
|
# Get all pending orders (note: PostgreSQL uses %s for parameters) |
|
|
orders = execute_query("SELECT * FROM orders WHERE status = %s", ("pending",)) |
|
|
|
|
|
# Create new order |
|
|
order_id = execute_write( |
|
|
"INSERT INTO orders (order_id, customer_name, delivery_address, status) VALUES (%s, %s, %s, %s)", |
|
|
("ORD-001", "John Doe", "123 Main St", "pending") |
|
|
) |
|
|
|
|
|
# Test connection |
|
|
from database.connection import test_connection |
|
|
if test_connection(): |
|
|
print("Database connected successfully!") |
|
|
``` |
|
|
|
|
|
## π License |
|
|
|
|
|
MIT License |
|
|
|
|
|
## π€ Contributing |
|
|
|
|
|
Contributions welcome! Please read the contributing guidelines first. |
|
|
|