Local Setup¶
Run TBD Agents on your development machine — Docker or bare metal.
Prerequisites¶
| Requirement | Why |
|---|---|
| Docker & Docker Compose | Fastest path — runs everything in one command |
GitHub PAT (copilot scope) |
Authenticates agent sessions against the Copilot SDK |
| Copilot subscription | Individual, Business, or Enterprise — premium request quota |
| Node.js 22+ | Required by npx-based MCP servers (included in Docker image) |
| Python 3.12+ | Only needed for bare-metal development |
| Flutter 3.32+ with web support | Needed only when you are changing frontend/ locally |
Option 1 — Docker Compose (recommended)¶
git clone https://github.com/naaico-tech/tbd-agents.git && cd tbd-agents
cp .env.example .env
# Edit .env and fill in at least GITHUB_TOKEN
docker compose up --build
| Service | Port | Description |
|---|---|---|
app |
8000 | FastAPI API + Flutter dashboard |
worker |
— | Celery worker (4 concurrent slots) |
redis |
6379 | Task broker + event bus |
mongodb |
27017 | Document store |
qdrant |
6333 | Vector store |
Add the following to your .env, then start:
COMPOSE_PROFILES=pgvector
DB_BACKEND=postgres
VECTOR_STORE_BACKEND=pgvector
POSTGRES_URI=postgresql+asyncpg://postgres:postgres@pgvector:5432/tbd_agents
| Service | Port | Description |
|---|---|---|
app |
8000 | FastAPI API + Flutter dashboard |
worker |
— | Celery worker (4 concurrent slots) |
redis |
6379 | Task broker + event bus |
pgvector |
5432 | PostgreSQL 16 with pgvector (replaces MongoDB + Qdrant) |
Note
The pgvector profile starts a single PostgreSQL container that handles both document storage and vector search. MongoDB and Qdrant are not started.
Scaling workers¶
Each worker defaults to --concurrency=4, so 3 containers = 12 concurrent agent executions.
The application image builds the Flutter web bundle during docker compose up --build, serves it from FastAPI at /dashboard, and keeps the legacy dashboard available at /dashboard-legacy.
Option 2 — Bare Metal¶
Step 1 — Install dependencies¶
Step 2 — Start infrastructure¶
# MongoDB
docker run -d --name mongo -p 27017:27017 mongo:7
# Qdrant
docker run -d --name qdrant -p 6333:6333 qdrant/qdrant
# Redis
docker run -d --name redis -p 6379:6379 redis:7-alpine
Or install natively via brew install mongodb-community redis (macOS).
Step 3 — Set environment variables¶
export DB_BACKEND=postgres
export POSTGRES_URI=postgresql+asyncpg://postgres:postgres@localhost:5432/tbd_agents
export VECTOR_STORE_BACKEND=pgvector
export PGVECTOR_DSN=postgresql+asyncpg://postgres:postgres@localhost:5432/tbd_agents
export REDIS_URL=redis://localhost:6379/0
export GITHUB_TOKEN="ghp_your_token_here"
Or create a .env file from the template — Pydantic Settings loads it automatically:
Step 4 — Apply schema migrations (PostgreSQL only)¶
This is a no-op when DB_BACKEND=mongo.
Step 5 — Start the API server¶
Optional — rebuild the Flutter dashboard locally¶
If you are changing files under frontend/, build the web bundle that FastAPI serves:
cd frontend
flutter config --enable-web
flutter pub get
flutter analyze
flutter test
flutter build web --release --base-href /dashboard/
cd ..
Step 6 — Start a Celery worker¶
In a separate terminal (same virtualenv):
Verifying the setup¶
# Health check
curl http://localhost:8000/health
# Create a simple agent
curl -X POST http://localhost:8000/api/agents \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "test", "system_prompt": "You are a helpful assistant."}'
# Check the Flutter dashboard
open http://localhost:8000/dashboard
# Check the legacy dashboard
open http://localhost:8000/dashboard
Running Tests¶
# Unit tests (MongoDB-agnostic, no external services needed)
python -m pytest tests/ --ignore=tests/integration --ignore=tests/integration_postgres -v
# MongoDB integration tests (requires running MongoDB + Redis)
python -m pytest tests/integration/ -v
# PostgreSQL integration tests (requires running PostgreSQL)
DB_BACKEND=postgres \
POSTGRES_URI=postgresql+asyncpg://postgres:postgres@localhost:5432/tbd_agents_integration_test \
python -m pytest tests/integration_postgres/ -v
# Lint check
ruff check app/ tests/
# Auto-format
ruff format app/ tests/
# Frontend checks (when touching frontend/)
cd frontend
flutter analyze
flutter test
flutter build web --release --base-href /dashboard/
Note
Tests use pytest-asyncio with asyncio_mode = "auto" — all async test functions are picked up automatically.
Troubleshooting¶
| Problem | Solution |
|---|---|
| Connection refused on port 8000 | Ensure uvicorn or the app container is running |
| Connection refused on Redis/Mongo | Start infrastructure containers or native services |
| Workers not picking up tasks | Verify REDIS_URL matches between API and worker |
| MCP server fails to start | Ensure Node.js 22+ is installed (npx needs it) |
copilot scope errors |
Regenerate your GitHub PAT with copilot scope enabled |
| Token encryption errors | Set TOKEN_ENCRYPTION_KEY in .env (see .env.example) |
relation "agents" does not exist |
Run alembic upgrade head after setting DB_BACKEND=postgres |
App still reads MongoDB when using DB_BACKEND=postgres |
Restart the app and worker after changing .env |