Dev Mode
The dev command starts a full local development environment with hot reload for all services.
npx learnhouse dev
How It Works
The command splits infrastructure and application services:
- Infrastructure (Docker): PostgreSQL with pgvector and Redis run in containers, defined in
.learnhouse/docker-compose.dev.yml(the CLI writes this file on each run) - Application (local): the API, web, and collab servers run directly on your machine with hot reload
Requirements
- Docker with Docker Compose v2
- bun (for web and collab dependencies)
- uv (for Python API dependencies)
bun and uv must be installed beforehand. The CLI checks for both and stops with an install link if either is missing. It runs bun install and uv sync for the project, but does not install the tools themselves.
Startup Flow
- Detect project root: walks up from the current directory until it finds
apps/apiandapps/web - Check env files: looks for the variables each app needs (see below). If any are missing, it lists them and offers to write development defaults or stop.
- Link Enterprise code (only with
--ee) - Check tools:
bun,uv, Docker, and a running Docker daemon - Admin setup and infrastructure: when the
learnhouse-db-devandlearnhouse-redis-devcontainers are not already running, prompts for an admin email (default[email protected]) and password, then starts them. When they are running, they are reused and the prompt is skipped. Pass--admin-emailand--admin-passwordto skip the prompt. - Health checks: waits for PostgreSQL and Redis to be ready
- Install dependencies: runs
bun installinapps/webandapps/collabwhennode_modulesis missing, anduv syncinapps/apiwhen.venvis missing - Start services: launches the API, web, and collab servers with color-coded output
Env files
The CLI checks these variables and, if you accept, appends development defaults for the missing ones only:
| File | Variable | Default written |
|---|---|---|
apps/api/.env | LEARNHOUSE_AUTH_JWT_SECRET_KEY | Random secret |
apps/api/.env | COLLAB_INTERNAL_KEY | Random secret |
apps/web/.env.local | NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL | http://localhost:1338/ |
apps/collab/.env | COLLAB_PORT | 4000 |
apps/collab/.env | LEARNHOUSE_API_URL | http://localhost:1338 |
apps/collab/.env | LEARNHOUSE_AUTH_JWT_SECRET_KEY | Same value as the API |
apps/collab/.env | COLLAB_INTERNAL_KEY | Same value as the API |
Other API settings fall back to apps/api/config/config.yaml, which ships localhost defaults (database postgresql://learnhouse:learnhouse@localhost:5432/learnhouse, Redis redis://localhost:6379/learnhouse).
The CLI also sets these for the processes it starts:
| Variable | Value |
|---|---|
LEARNHOUSE_DEVELOPMENT_MODE | true |
LEARNHOUSE_INITIAL_ADMIN_EMAILLEARNHOUSE_INITIAL_ADMIN_PASSWORD | The admin credentials, when given |
LEARNHOUSE_DISABLE_EE | 1--ee |
LEARNHOUSE_FORCE_EE | 1--ee |
Services
| Service | Command | Port |
|---|---|---|
| API | uv run python app.py | 1338 |
| Web | next dev --turbopack | 3000 |
| Collab | tsx watch src/index.ts | 4000 |
| PostgreSQL | Docker (pgvector/pgvector:pg16 | 5432, bound to 127.0.0.1 |
| Redis | Docker (redis:8.6.1-alpine | 6379, bound to 127.0.0.1 |
The development database uses user, password and database name learnhouse.
Interactive Controls
While running, you can type these keys to manage services:
| Key | Action |
|---|---|
ra | Restart API |
rw | Restart Web |
rc | Restart Collab |
rb | Restart all services |
q | Quit (graceful shutdown) |
Enterprise Edition
Use the --ee flag to enable Enterprise Edition features:
npx learnhouse dev --ee
With the flag, the CLI links apps/api/ee and apps/web/ee to a sibling EE checkout at ../ee/apps/<app>/ee (on Windows it uses directory junctions). If no EE checkout is found, that app runs as the community edition. Without the flag, LEARNHOUSE_DISABLE_EE=1 keeps the app on the community edition even if an ee/ folder exists.
Shutdown
When you quit (q or Ctrl+C):
- Local services (API, Web, Collab) are stopped
- Docker containers (PostgreSQL, Redis) keep running for the next session
- To fully stop infrastructure:
docker compose -f .learnhouse/docker-compose.dev.yml -p learnhouse-dev down
Database and Redis data persist across dev sessions in Docker volumes. Running down keeps them; add -v to delete them.