Skip to main content

Prerequisites

ToolVersionPurpose
Python3.12+Backend + agent worker
Node.js18+UI + widget
PostgreSQL16Primary database
Redis7+Cache + Celery broker
RabbitMQ3.12+AMQP broker (Vaani Dialer)
Docker24+Containerized deployment
Docker Compose3.9+Multi-container orchestration
GitLatestVersion control

Running Locally

1

Clone and setup

cd agent-studio-backend
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install -r requirements.txt
2

Configure environment

cp app/env/.env.example app/env/.env
# Edit .env with your credentials (see Environment Variables below)
3

Start infrastructure

docker-compose up db redis -d
4

Run migrations

alembic upgrade head
5

Start the server

uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

Environment Variables

Backend (app/core/config/settings.py)

VariableRequiredExampleDescription
ENVlocalEnvironment: local/dev/stage/prod
LOAD_DOTENV1Enable .env file loading
FRONTEND_URLhttp://localhost:3000CORS origin
OPENAI_API_KEYsk-...OpenAI API key
S3_BUCKET_NAMEvaani-recordingsS3 bucket name
S3_REGIONus-east-1S3 region
S3_ACCESS_KEYAKIA...S3 access key
S3_SECRET_KEYSECRETS3 secret key
TWILIO_ACCOUNT_SIDAC...Twilio account SID
TWILIO_AUTH_TOKENTOKENTwilio auth token
LIVEKIT_API_KEYAPI...LiveKit API key
LIVEKIT_API_SECRETSECRETLiveKit API secret
LIVEKIT_URLwss://lk.example.comLiveKit server URL
LIVEKIT_SIP_URIsip.livekit.ioLiveKit SIP endpoint
JWT_API_SECRETSECRETJWT signing key (shared with UI)
PG_USERvaaniPostgreSQL username
PG_PASSWORDpasswordPostgreSQL password
PG_HOSTlocalhostPostgreSQL host
PG_PORT5432PostgreSQL port
PG_DBagent_studio_dbPostgreSQL database
REDIS_URLredis://localhost:6379/1Redis URL
MAX_AGENT_SESSIONS10Max concurrent calls
LOG_DIR/var/log/vaaniLog directory
LOG_LEVELINFOLogging level

UI (agent-studio-ui/.env.local)

VariableRequiredExampleDescription
NEXT_PUBLIC_ML_BACKEND_URLhttp://localhost:8000Backend API URL
JWT_API_SECRETSame as backendJWT secret (shared)
ALLOWED_BOT_ORIGINShttp://localhost:5173Widget CORS origins

Docker Deployment

Docker Compose Services

ServiceImagePortPurpose
dbpostgres:165432PostgreSQL database
backendagent-studio-backend:dev8000FastAPI app
redisredis:76379Cache + Celery broker
celery-workerSame as backendCelery task worker
celery-beatSame as backendCelery scheduler

Quick Start

cd agent-studio-backend
docker-compose up -d

# View logs
docker-compose logs -f backend

# Rebuild after code changes
docker-compose build backend
docker-compose up -d backend

Dockerfile Overview

  1. Builder stage — Python 3.12, install deps from requirements.txt, install LiveKit CLI (v2.4.14)
  2. Runtime stage — Slim image, copy site-packages, run as non-root appuser
  3. Entrypoint: tinigunicorn -k uvicorn.workers.UvicornWorker

Logging & Monitoring

Backend Logging

  • Implementation: app/core/logging.pyAppLogger
  • Config: LOG_DIR, LOG_LEVEL, LOG_RETENTION_DAYS
  • Format: JSON-file Docker driver with max 10MB × 5 files rotation

Prometheus Metrics

Exposed by agent worker (accessed by GET /reports/workload):
  • Active agent sessions count
  • CPU/memory utilization
  • STT/TTS/LLM latency histograms
  • Request rates

Common Deployment Issues

IssueCauseFix
alembic upgrade failsDB migrations out of syncRun alembic stamp head then alembic upgrade head
LiveKit SIP trunk errorsLiveKit CLI version mismatchEnsure LK_VERSION=2.4.14 in Dockerfile
Agent worker won’t connectWrong LIVEKIT_URL or API keysVerify LiveKit credentials and URL (wss://)
Redis connection refusedRedis not startedCheck REDIS_URL matches Docker service
S3 presigned URL errorsS3_REGION has stray quotesBackend strips quotes as workaround
JWT verification failsDifferent JWT_API_SECRETMust be identical across backend and UI
Celery tasks not executingBeat not runningStart celery-beat service; check REDIS_URL
Even trailing whitespace or newlines in JWT_API_SECRET can cause a mismatch between backend and UI. Copy-paste the value directly.