OS Trading Engine
Getting Started
Quickstart (Local Dev)

Quickstart (Local Dev)

Get Nexgent running locally in under 15 minutes.

This guide covers local development setup. For cloud hosting deployment, see Quickstart (Cloud Hosting).


Prerequisites

Before starting, ensure you have:


Setup

Clone the Repository

git clone https://github.com/Nexgent-ai/nexgent-open-source-trading-engine.git
cd nexgent

Start Infrastructure

Start PostgreSQL and Redis using Docker Compose:

docker-compose up -d

Verify services are running:

docker-compose ps
# Both nexgent-postgres and nexgent-redis should show "Up"

Install Dependencies

pnpm install

Configure Environment Variables

cd packages/backend
cp env.example .env

The defaults work with Docker Compose. Key settings:

# Database (Docker Compose defaults)
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/nexgent?schema=public"
 
# Redis (Docker Compose defaults)
REDIS_HOST=localhost
REDIS_PORT=6379
 
# Server
PORT=4000
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000
 
# JWT Secret (generate below)
JWT_SECRET="your-secret-here"

Generate Secrets

From the project root:

# Generate frontend secret (NextAuth)
pnpm generate-secret
 
# Generate backend secret (JWT)
pnpm generate-secret:backend

Copy the generated secrets into your .env files.

Run Database Migrations

pnpm --filter backend db:migrate

This creates all necessary database tables.

Start the Application

# Start both frontend and backend
pnpm dev

Or start them separately:

pnpm dev:backend   # Backend on http://localhost:4000
pnpm dev:frontend  # Frontend on http://localhost:3000

Verify Installation

Check Backend Health

curl http://localhost:4000/api/v1/health
# Should return: {"status":"ok"}

Access the Dashboard

Open http://localhost:3000 (opens in a new tab) in your browser.

You should see the login page:

Login Page

Create an Account

  1. Click Register
  2. Enter your email and password
  3. You'll be redirected to the dashboard

What's Running

After setup, you have:

ServiceURLPurpose
Frontendhttp://localhost:3000 (opens in a new tab)Next.js dashboard
Backendhttp://localhost:4000 (opens in a new tab)Express API + WebSocket
PostgreSQLlocalhost:5432Database
Redislocalhost:6379Cache + job queues

Troubleshooting

Port Already in Use

netstat -ano | findstr :4000
taskkill /PID <pid> /F

Docker Services Not Starting

# Check logs
docker-compose logs postgres
docker-compose logs redis
 
# Restart services
docker-compose down
docker-compose up -d

Database Connection Error

  1. Verify Docker is running: docker-compose ps
  2. Check DATABASE_URL in .env matches Docker Compose credentials
  3. Run migrations again: pnpm --filter backend db:migrate

Frontend Can't Connect to Backend

  1. Verify backend is running: curl http://localhost:4000/api/v1/health
  2. Check NEXT_PUBLIC_API_URL in frontend .env.local
  3. Check CORS_ORIGIN in backend .env includes http://localhost:3000

Useful Commands

# Start everything
pnpm dev
 
# Stop Docker services
docker-compose stop
 
# View database with Prisma Studio
pnpm --filter backend db:studio
 
# Run tests
pnpm test
 
# Build for production
pnpm build