Guides

Local Development Setup

Run the full Codmir platform locally as a cluster of interconnected services. This guide walks you through setting up every service and understanding how they connect.

Service Architecture

Codmir runs as a cluster of services that communicate via HTTP and WebSocket. Here's how they connect:


  ┌──────────────┐
  │   Desktop    │  Tauri + React
  │   :1420      │
  └──────┬───────┘
         │
    REST │   WebSocket
    ┌────┴──────────────┐
    │                   │
    ▼                   ▼
┌────────────┐   ┌─────────────┐
│  Web       │   │  Connect    │
│  Next.js   │   │  NestJS     │
│  :3000     │   │  :3300      │
└─────┬──────┘   └─────────────┘
      │
      ▼
┌────────────┐   ┌─────────────┐
│  API       │   │ Workstation │
│  Hono      │   │  NestJS     │
│  :9000     │   │  :3400      │
└─────┬──────┘   └──────┬──────┘
      │                 │
      ▼                 ▼
┌──────────────────────────────┐
│  PostgreSQL  +  Redis        │
└──────────────────────────────┘

Web :3000

Next.js dashboard, auth, REST API, and admin panel. The main entry point for browser users.

API :9000

Hono API server handling CRUD operations, AI endpoints, and session management via Redis.

Connect :3300

NestJS WebSocket server for presence, chat, notifications, and real-time collaboration.

Workstation :3400

NestJS AI workstation: agent runtime, AI proxy, overseer, and IDE bridge.

1Prerequisites

Make sure you have the following installed before proceeding:

Check prerequisites
# Node.js 22+ (via nvm or fnm)
node --version    # v22.x.x

# pnpm 9+
pnpm --version    # 9.x.x

# Redis (for API sessions)
redis-cli ping    # PONG

# PostgreSQL (local or Neon remote)
psql --version    # 16+

2Clone and Install

Terminal
git clone git@github.com:codmir/codmir.git
cd codmir
pnpm install

Memory limit: The .npmrc caps Node heap at 7GB. Do not remove this — uncapped builds can crash on 16GB machines.

3Environment Variables

Terminal
cp .env.example .env

Edit .env and fill in the required values:

.env
# Database (Neon or local PostgreSQL)
DATABASE_URL="postgresql://user:pass@localhost:5432/codmir"

# Auth (GitHub OAuth)
AUTH_GITHUB_ID="your-github-oauth-app-id"
AUTH_GITHUB_SECRET="your-github-oauth-app-secret"
AUTH_SECRET="$(openssl rand -base64 32)"

# Redis
REDIS_URL="redis://localhost:6379"

# AI keys (optional — for workstation features)
ANTHROPIC_API_KEY="sk-ant-..."
OPENAI_API_KEY="sk-..."
GEMINI_API_KEY="..."

4Database Setup

Terminal
# Generate Prisma client
pnpm --filter @codmir/web exec prisma generate

# Push schema to database (creates tables)
pnpm --filter @codmir/web exec prisma db push

# Optional: seed with sample data
pnpm --filter @codmir/web exec prisma db seed

5Start the Dev Cluster

Start all core services with a single command:

Terminal
pnpm dev

This starts Web (:3000), API (:9000), and Workstation (:3400) via Turbo, with logs multiplexed into .dev.log.

Or start services individually:

Terminal
# Web only
pnpm dev:web

# API server
pnpm --filter @codmir/api dev

# Connect (WebSocket server)
pnpm --filter @codmir/connect dev

# Server (AI workstation)
pnpm --filter @codmir/server dev

# Desktop (Tauri app)
pnpm --filter @codmir/desktop dev

6Verify Services

Terminal
# API health check
curl http://localhost:9000/health
# => {"status":"ok","service":"api"}

# Workstation health check
curl http://localhost:3400/health
# => {"status":"ok","service":"server"}

# Open the dashboard
open http://localhost:3000

Service Connection Map

How services discover each other via environment variables:

FromToEnv VariableDefault
WebAPIAPI_BASE_URLhttp://localhost:9000
DesktopWebNEXT_PUBLIC_APP_URLhttp://localhost:3000
DesktopConnect(client config)ws://localhost:3300
DesktopWorkstation(client config)http://localhost:3400
APIPostgreSQLDATABASE_URL(required)
APIRedisREDIS_URLredis://localhost:6379

Common Tasks

Type-check before pushing

Terminal
# Always scope — never run bare tsc on apps/web (OOMs)
npx turbo run typecheck --filter=@codmir/web...
npx turbo run typecheck --filter=@codmir/api...

Build for production

Terminal
npx turbo run build --filter=@codmir/web...
npx turbo run build --filter=@codmir/api...

Reset database

Terminal
pnpm --filter @codmir/web exec prisma db push --force-reset
pnpm --filter @codmir/web exec prisma db seed

View live logs

Terminal
# Tail the unified dev log
tail -f .dev.log

# Filter by service
tail -f .dev.log | command grep --line-buffered "\[api\]"
tail -f .dev.log | command grep --line-buffered "\[workstation\]"

Docker (Kernel Service)

Terminal
docker compose up -d
# Starts kernel on :7700

Troubleshooting

Port already in use

Kill the occupying process: lsof -ti :3000 | xargs kill -9

MODULE_NOT_FOUND on startup

Run pnpm install then rebuild: npx turbo run build --filter=@codmir/api...

OOM during build

Ensure .npmrc has node-options="--max-old-space-size=7168"

Prisma client not generated

Run pnpm --filter @codmir/web exec prisma generate

Redis connection refused

Start Redis: sudo systemctl start redis or redis-server