- Add migration 013_city_map_coordinates.sql with map coordinates, zones, and agents table - Add /city/map API endpoint in city-service - Add /city/agents and /city/agents/online endpoints - Extend presence aggregator to include agents[] in snapshot - Add AgentsSource for fetching agent data from DB - Create CityMap component with interactive room tiles - Add useCityMap hook for fetching map data - Update useGlobalPresence to include agents - Add map/list view toggle on /city page - Add agent badges to room cards and map tiles
DAGI Stack
Decentralized Agentic Gateway Infrastructure
Production-ready AI router with multi-agent orchestration, microDAO governance, and bot gateway integration.
🏗️ Architecture
┌─────────────────────────────────────────────────────────────┐
│ Bot Gateway │
│ (Telegram/Discord) │
│ Port: 9300 │
└──────────────────────┬──────────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────────────────┐
│ DAGI Router │
│ (Dynamic Rule-Based Routing) │
│ Port: 9102 │
└───┬──────────────────┬──────────────────┬──────────────────┘
│ │ │
↓ ↓ ↓
┌─────────┐ ┌──────────────┐ ┌──────────────┐
│ LLM │ │ DevTools │ │ CrewAI │
│Provider │ │ Backend │ │ Orchestrator │
│ │ │ Port: 8008 │ │ Port: 9010 │
└─────────┘ └──────────────┘ └──────────────┘
↑
│ RBAC Context Injection
│
┌─────────────────────────────────────────────────────────────┐
│ RBAC Service │
│ (Role-Based Access Control) │
│ Port: 9200 │
└─────────────────────────────────────────────────────────────┘
Core Components
| Component | Port | Description |
|---|---|---|
| DAGI Router | 9102 | Main routing engine with rule-based dispatch |
| Bot Gateway | 9300 | Telegram/Discord webhook receiver |
| DevTools Backend | 8008 | File operations, test execution, notebooks |
| CrewAI Orchestrator | 9010 | Multi-agent workflow execution |
| RBAC Service | 9200 | Role resolution and access control |
| Ollama | 11434 | Local LLM (optional) |
🚀 Quick Start
Prerequisites
- Docker 20.10+
- Docker Compose 2.0+
- 4GB+ RAM
- 10GB+ disk space
1. Clone Repository
git clone https://github.com/daarion/dagi-stack.git
cd dagi-stack
2. Configure Environment
cp .env.example .env
# Edit .env with your tokens and settings
nano .env
Required variables:
TELEGRAM_BOT_TOKEN- Get from @BotFatherOLLAMA_BASE_URL- Local Ollama URL (or use remote LLM)
3. Start Services
docker-compose up -d
4. Verify Health
./smoke.sh
Or manually:
curl http://localhost:9102/health # Router
curl http://localhost:8008/health # DevTools
curl http://localhost:9010/health # CrewAI
curl http://localhost:9200/health # RBAC
curl http://localhost:9300/health # Gateway
5. Test Basic Routing
curl -X POST http://localhost:9102/route \
-H "Content-Type: application/json" \
-d '{
"prompt": "Hello from DAGI!",
"mode": "chat",
"metadata": {}
}'
📦 Services Overview
DAGI Router
Central routing engine that dispatches requests based on configurable rules:
- Rule-based routing: Priority-ordered rules match requests to providers
- Multi-provider support: Ollama, DeepSeek, OpenAI, custom agents
- Metadata enrichment: Injects context (dao_id, user_id, RBAC roles)
- Timeout handling: Configurable timeouts with fallback strategies
Key files:
main_v2.py- Entry pointrouting_engine.py- Core routing logicrouter-config.yml- Routing rules configuration
Bot Gateway
HTTP server for bot platforms:
- Telegram webhooks:
/telegram/webhook - Discord webhooks:
/discord/webhook - Chat normalization: Converts platform-specific messages to unified format
- RBAC integration: Enriches requests with user roles before routing
Key files:
gateway-bot/main.pygateway-bot/http_api.pygateway-bot/router_client.py
DevTools Backend
Tool execution service for development tasks:
- File operations: Read/write files in workspace
- Test execution: Run pytest/jest/etc
- Notebook execution: Jupyter notebook support
- Security: Path validation, size limits
Endpoints:
POST /fs/read- Read filePOST /fs/write- Write filePOST /ci/run-tests- Execute testsPOST /notebook/execute- Run notebook
CrewAI Orchestrator
Multi-agent workflow execution:
- 4 workflows:
microdao_onboarding- Welcome new memberscode_review- Code quality analysisproposal_review- Governance proposal assessmenttask_decomposition- Break down complex tasks
Endpoints:
POST /workflow/run- Execute workflowGET /workflow/list- List available workflows
RBAC Service
Role-based access control:
- Roles: admin, member, contributor, guest
- Entitlements: Granular permissions per role
- DAO isolation: Multi-tenancy support
Endpoints:
POST /rbac/resolve- Resolve user role and permissionsGET /roles- List all roles
🔧 Configuration
Routing Rules
Edit router-config.yml to customize routing behavior:
routing_rules:
- name: "microdao_orchestrator"
priority: 5
conditions:
mode: "crew"
use_provider: "microdao_orchestrator"
timeout_ms: 60000
Rule fields:
priority- Lower = higher priorityconditions- Match criteria (mode, prompt patterns, metadata)use_provider- Target provider nametimeout_ms- Request timeout
Environment Variables
See .env.example for full list. Key variables:
# LLM Configuration
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=qwen3:8b
# Service Ports
ROUTER_PORT=9102
GATEWAY_PORT=9300
# Security
RBAC_SECRET_KEY=your-secret-here
# Logging
LOG_LEVEL=INFO
LOG_FORMAT=json
🧪 Testing
Smoke Tests
Run basic health checks:
./smoke.sh
E2E Tests
Test individual components:
./test-devtools.sh # DevTools integration
./test-crewai.sh # CrewAI workflows
./test-gateway.sh # Gateway + RBAC
Manual Testing
# Test LLM routing
curl -X POST http://localhost:9102/route \
-H "Content-Type: application/json" \
-d '{"prompt": "Test", "mode": "chat", "metadata": {}}'
# Test DevTools
curl -X POST http://localhost:8008/fs/read \
-H "Content-Type: application/json" \
-d '{"path": "README.md"}'
# Test CrewAI
curl -X POST http://localhost:9010/workflow/run \
-H "Content-Type: application/json" \
-d '{"workflow_name": "code_review", "inputs": {}}'
# Test RBAC
curl -X POST http://localhost:9200/rbac/resolve \
-H "Content-Type: application/json" \
-d '{"dao_id": "greenfood-dao", "user_id": "tg:12345"}'
📊 Monitoring & Logs
View Logs
# All services
docker-compose logs -f
# Specific service
docker-compose logs -f router
docker-compose logs -f gateway
Structured JSON Logs
All services use structured logging:
{
"timestamp": "2024-11-15T12:00:00Z",
"level": "INFO",
"service": "router",
"message": "Request routed successfully",
"request_id": "123e4567-e89b-12d3-a456-426614174000",
"user_id": "tg:12345",
"dao_id": "greenfood-dao",
"duration_ms": 125.5
}
Health Checks
All services expose /health endpoint:
curl http://localhost:9102/health
🚢 Deployment
Docker Compose (Recommended)
docker-compose up -d
Kubernetes
See docs/DEPLOYMENT.md for Kubernetes manifests and Helm charts.
Systemd
For production servers without containers:
sudo cp deploy/systemd/dagi-router.service /etc/systemd/system/
sudo systemctl enable dagi-router
sudo systemctl start dagi-router
Full deployment guide: docs/DEPLOYMENT.md
🛣️ Roadmap
Phase 1: Core Router ✅
- Multi-provider LLM support
- Rule-based routing engine
- YAML configuration
- Basic health checks
Phase 2: Orchestration ✅
- DevTools integration
- CrewAI workflows
- Bot gateway (Telegram/Discord)
- RBAC service
Phase 3: Production (Current)
- Docker deployment
- Structured logging
- Smoke test suite
- Prometheus metrics
- CI/CD pipelines
Phase 4: Governance (Planned)
- On-chain voting integration
- Token-weighted decisions
- Proposal lifecycle management
- Treasury operations
Phase 5: Scale (Future)
- Horizontal scaling
- Load balancing
- Distributed tracing
- Performance optimization
📚 Documentation
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
📄 License
This project is licensed under the MIT License - see LICENSE file for details.
🔗 Links
- Website: https://daarion.city
- Documentation: https://docs.daarion.city
- GitHub: https://github.com/daarion/dagi-stack
- Discord: https://discord.gg/daarion
💬 Support
- Issues: https://github.com/daarion/dagi-stack/issues
- Discussions: https://github.com/daarion/dagi-stack/discussions
- Email: dev@daarion.city
Built with ❤️ by the DAARION Community
🎯 First Deployment
Ready to deploy? Follow our step-by-step guide:
📖 First Deployment Guide - Complete walkthrough for first live deployment
5-step process (15 minutes):
- Initial Setup - Configure
.env, generate secrets - Pre-flight Checks - Verify Docker, disk, memory
- Service Startup -
docker-compose up -d - Health Verification - Run
./smoke.sh - First Real Dialog - Test Telegram bot or curl
Includes:
- Pre-deployment checklist
- Troubleshooting guide
- Post-deployment verification
- Success confirmation criteria
🧪 Golden Scenarios
After deployment, validate your stack with production scenarios:
📖 Golden Scenarios Guide - 5 end-to-end test scenarios
Scenarios:
- Basic Chat - Telegram → Gateway → Router → LLM (5s)
- microDAO Onboarding - CrewAI 3-agent workflow (60s)
- DevTools File Operation - Read/write files (1s)
- Code Review - Multi-agent code analysis (90s)
- RBAC Permission Check - Access control validation (100ms)
Each scenario includes:
- Setup requirements
- Expected flow diagram
- Verification commands
- Success criteria
- Troubleshooting tips