| title | Synapse |
|---|---|
| emoji | ๐ |
| colorFrom | green |
| colorTo | pink |
| sdk | docker |
| pinned | false |
๐ COMPLETE SOLUTION: Full-stack AI delivery coordination system with Next.js frontend and MCP integration!
Project Synapse is a sophisticated autonomous AI agent designed to intelligently resolve real-time, last-mile delivery disruptions. This version includes a beautiful Next.js frontend, Model Context Protocol (MCP) integration, and comprehensive tooling for delivery coordination.
- ๐ค MCP Server: Deployed on Hugging Face Spaces
- ๐จ Frontend: Deployed on Vercel
-
Create a new Space on Hugging Face:
- Go to Hugging Face Spaces
- Click "Create new Space"
- Choose "Docker" as the Space SDK
- Set visibility to "Public"
-
Clone and push your repository:
git clone https://github.com/your-username/project-synapse.git cd project-synapse git remote add hf https://huggingface.co/spaces/your-username/project-synapse-mcp git push hf main -
Configure environment variables in your Space settings:
GOOGLE_API_KEY: Your Google Generative AI API keyPORT: 7860 (default for HF Spaces)
-
Install Vercel CLI (optional):
npm install -g vercel
-
Deploy with Vercel:
cd frontend vercel -
Or connect your GitHub repository to Vercel for automatic deployments:
- Go to Vercel Dashboard
- Click "Import Project"
- Connect your GitHub repository
- Set build settings:
- Framework: Next.js
- Root Directory:
frontend - Build Command:
npm run build - Output Directory:
.next
Set these in your Vercel project settings:
NEXT_PUBLIC_MCP_SERVER_URL: URL of your deployed MCP server
# 1. Start MCP Server
python -m src.mcp.server
# 2. Start Frontend (new terminal)
cd frontend
npm install
npm run devpython -m src.main- ๐จ Beautiful Frontend: Modern Next.js dashboard with real-time monitoring
- ๐ค Interactive Agent: Test AI scenarios through web interface
- ๐๏ธ Modular Architecture: Clean separation into focused modules
- ๐ง MCP Integration: FastAPI-based Model Context Protocol server
- ๐ Analytics Dashboard: Tool usage, performance metrics, and activity monitoring
- โก Real-time Updates: Live activity feed and system status
- ๐งช Comprehensive Testing: Built-in scenario testing and validation
- ๏ฟฝ Advanced Debugging: Enhanced logging and error handling
โโโ src/ # Main source code
โ โโโ core/ # Agent, config, prompts
โ โโโ tools/ # Categorized delivery tools
โ โโโ mcp/ # Model Context Protocol server/client
โ โโโ utils/ # Logging and utilities
โ โโโ main.py # CLI application
โโโ docs/ # Documentation
โโโ scripts/ # Utility scripts and tools
โโโ frontend/ # Next.js frontend with dashboard
โ โโโ app/ # Next.js app directory
โ โโโ components/ # React components
โ โโโ lib/ # Utilities
โโโ legacy/ # Original files (preserved)
The Next.js frontend provides a comprehensive interface for monitoring and interacting with the AI agent:
The project features a comprehensive dashboard that provides a real-time overview of the system's performance and key metrics.
- ๐ Performance Metrics: Real-time KPIs and success rates
- ๐ Tool Usage Analytics: Visualization of most-used tools
- ๐ Activity Monitor: Live feed of system events
- โก System Health: Server status and performance indicators
The core of Project Synapse is the AI Agent Interface, where you can describe a delivery disruption scenario and watch the AI agent work through it.
- ๐ค Interactive Testing: Submit custom delivery scenarios
- ๐ Reasoning Display: See the agent's thought process
- ๐ง Tool Execution: Watch tools being used in real-time
- ๐ Pre-built Scenarios: Test common disruption cases
The system keeps a detailed log of each case, including the AI's reasoning and the specific actions it took to resolve the issue. This helps in understanding and auditing the agent's behavior.
In the example above, a customer's delivery was marked as 'failed'. The AI agent's plan was to:
- Verify the delivery attempt: Check the driver's location and other data to confirm what happened.
- Notify the customer: Proactively reach out to the customer to reschedule the delivery, providing a clear and helpful message.
- Restaurant overload with long prep times
- Damaged packaging disputes at delivery
- Recipient unavailability for valuable packages
- Traffic obstructions blocking delivery routes
Access the frontend at: http://localhost:3000
get_merchant_status- Check restaurant operational status and preparation timescheck_traffic- Analyze route conditions and traffic patterns for optimal routingreroute_driver- Optimize driver assignments and routes for maximum efficiencyget_nearby_merchants- Find alternative vendors of similar cuisine when primary merchant is unavailable
notify_customer- Send notifications and real-time updates to customerscontact_recipient_via_chat- Initiate real-time chat communication with delivery recipientssuggest_safe_drop_off- Recommend secure delivery locations when recipient is unavailablefind_nearby_locker- Locate parcel lockers near delivery address for secure package storagerequest_address_clarification- Request clearer address details from customers when location is ambiguous
initiate_mediation_flow- Start real-time dispute resolution between customers and driverscollect_evidence- Gather photos, statements, and documentation for dispute casesanalyze_evidence- Determine fault and recommend resolution based on collected evidenceissue_instant_refund- Process immediate refunds for customers in justified casesexonerate_driver- Clear driver of fault in dispute cases with supporting evidencelog_merchant_packaging_feedback- Record packaging quality feedback and issues for merchants
verify_delivery_attempt- Validate delivery attempts using GPS data and location verificationinitiate_qr_code_verification- Generate secure QR codes for contactless delivery confirmation
The project includes a full Model Context Protocol server:
# Start MCP server
python src/mcp/server.py
# Available at: http://localhost:8000
# API Documentation
# http://localhost:8000/docsfrom src.mcp.client import SynapseMCPClient
import asyncio
async def example():
async with SynapseMCPClient() as client:
result = await client.call_tool(
"get_merchant_status",
merchant_name="Pizza Palace"
)
print(result)
asyncio.run(example())python scripts/test.py # Comprehensive test suite
python scripts/setup.py --test # Setup validation
python scripts/demo.py # Feature demonstrations
python scripts/start.py check # Quick health checkTry these in the CLI:
- Merchant Overload: "Driver reports Pizza Palace is overloaded with 45-minute wait"
- Delivery Dispute: "Customer complains food arrived spilled, customer ID CUST123"
- Address Issues: "Driver cannot find address: Room 301, near big temple"
- Failed Delivery: "Customer says driver never arrived but marked as failed"
cd frontend
npm run setup
npm run devPlanned Features:
- ๐ Real-time delivery dashboard
- ๐ฌ Interactive dispute resolution
- ๐ Agent analytics and monitoring
- ๐ง Tool usage visualization
docs/QUICKSTART.md- 3-step setup guidedocs/REFACTORING_SUMMARY.md- What changed and whydocs/PROJECT_STRUCTURE.md- Clean project organizationfrontend/README.md- Frontend development guide
The agent autonomously handles:
- Merchant Issues: Overloaded restaurants, delays, alternatives
- Customer Communication: Notifications, chat, instructions
- Dispute Resolution: Evidence collection, fault analysis, refunds
- Delivery Verification: GPS validation, secure confirmations
- Address Resolution: Landmark-based navigation assistance
- Python 3.9+
- Google API Key (Generative AI)
- Node.js 18+ (for frontend)
MIT License - See LICENSE file for details.
๐ Ready to revolutionize delivery coordination with modular AI architecture!
Migration Note: Original files preserved in
legacy/directory. New modular structure provides the same functionality with better organization and extensibility.


