Installation
Prerequisites
| Dependency | Version | Notes |
|---|---|---|
| Node.js | 24+ | Required for manual install |
| pnpm | 9+ | Package manager |
| MongoDB | 7+ | Must run as a replica set |
| Redis | 7+ | Used for caching, queues, and sessions |
| Docker | 24+ | Required for Docker install only |
Option 1: Docker Compose (Recommended)
Docker Compose starts all services including MongoDB and Redis.
# Clone the repositorygit clone <repo-url> ai-gatewaycd ai-gateway
# Copy environment filecp .env.example .env
# Start all servicesdocker compose -f docker/docker-compose.yml up -dThis starts five containers:
| Container | Port | Description |
|---|---|---|
aigw-mongo-primary | 27017 | MongoDB with replica set auto-init |
aigw-redis | 6379 | Redis with AOF persistence |
aigw-server | 3000 | Gateway API server |
aigw-worker | — | BullMQ background worker |
aigw-admin | 3001 | Admin dashboard |
Option 2: Manual Install
1. Start Infrastructure
You need MongoDB running as a replica set and Redis. If you have them installed locally:
# Start MongoDB as a replica setmongod --replSet rs0 --bind_ip_all
# In another terminal, initialize the replica setmongosh --eval "rs.initiate({_id:'rs0', members:[{_id:0, host:'localhost:27017'}]})"
# Start Redisredis-server --appendonly yesOr start only the infrastructure via Docker:
docker compose -f docker/docker-compose.yml up -d mongodb-primary redis2. Install Dependencies
git clone <repo-url> ai-gatewaycd ai-gatewaypnpm install3. Configure Environment
cp .env.example .envEdit .env and set at minimum:
JWT_SECRET— at least 16 characters, random stringJWT_REFRESH_SECRET— at least 16 characters, random stringENCRYPTION_KEY— exactly 64 hex characters (256-bit key)
Generate secure values:
# Generate JWT secretsnode -e "console.log(require('crypto').randomBytes(48).toString('base64url'))"
# Generate encryption keynode -e "console.log(require('crypto').randomBytes(32).toString('hex'))"4. Build and Seed
# Build shared types (must be built first)pnpm build:shared
# Build the serverpnpm build:server
# Seed the database with default roles and super adminpnpm seed5. Start Services
# Start all services (server + worker + admin)pnpm dev
# Or start individuallypnpm dev:server # Gateway API on port 3000pnpm dev:worker # Background workerpnpm dev:admin # Admin dashboard on port 3001Verify Installation
Check the health endpoint:
curl http://localhost:3000/healthYou should receive a JSON response with "status": "ok".
Check the Swagger docs:
http://localhost:3000/docsCheck the admin dashboard:
http://localhost:3001Troubleshooting
MongoDB replica set errors: MongoDB must run as a replica set for transaction support. If you see connection errors, verify the replica set is initialized with mongosh --eval "rs.status()".
Permission denied on Docker volumes: On Linux, ensure your user is in the docker group or run with sudo.
Port conflicts: If ports 3000, 3001, 27017, or 6379 are in use, update the port mappings in docker-compose.yml or your .env file.