Edit

Development Environment Setup

The LearnHouse CLI sets up and runs the entire development environment with a single command.

Prerequisites

Make sure you have the following installed before proceeding:

  • Docker (with Docker Compose v2)
  • Node.js 22+ (to run the CLI with npx)
  • Bun: used to install and run the web and collab workspaces
  • uv: used to manage and run the Python API

npx learnhouse dev runs bun install and uv sync to install project dependencies, but it does not install bun or uv themselves. It checks for both and stops with an install link if either is missing.

Setup Steps

1. Clone the Repository and Start Development

git clone https://github.com/learnhouse/learnhouse && cd learnhouse && npx learnhouse dev

That single command handles everything:

  • Checks env files: if apps/api/.env, apps/web/.env.local or apps/collab/.env lack a required variable, it offers to write development defaults (including matching secrets for the API and the collaboration server).
  • Starts backing services: PostgreSQL and Redis are launched via Docker Compose. On the first run it asks for the admin email and password.
  • Installs dependencies: Python dependencies via uv and JavaScript dependencies via bun, when they are not installed yet.
  • Starts the API: The FastAPI backend starts on port 1338 with hot reload.
  • Starts the frontend: The Next.js development server starts with --turbopack and hot reload.
  • Starts the collaboration server: The Hocuspocus collaboration server starts via tsx watch on port 4000.

See Dev Mode for the full startup flow, the keyboard controls, and how to run with Enterprise code (--ee).

All services are coordinated automatically so you do not need to manage them individually.

Accessing the Application

Once npx learnhouse dev is running, you can access:

ServiceURL
Frontendhttp://localhost:3000
APIhttp://localhost:1338
API Documentation (Swagger)http://localhost:1338/docs

The Swagger UI at /docs is only available in development mode. Production instances do not expose the interactive API documentation.

Stopping the Environment

Press q or Ctrl+C in the terminal where npx learnhouse dev is running to stop the API, web and collab servers. The PostgreSQL and Redis containers keep running for the next session. To stop them:

docker compose -f .learnhouse/docker-compose.dev.yml -p learnhouse-dev down

Troubleshooting

  • Port conflicts: Make sure ports 3000 (web), 1338 (API), 4000 (collab), 5432 (Postgres), and 6379 (Redis) are not in use by other applications.
  • Docker not running: Ensure the Docker daemon is started before running npx learnhouse dev.
  • Dependency issues: The CLI only installs dependencies when node_modules (web, collab) or .venv (API) is missing. After pulling changes that touch dependencies, run bun install or uv sync yourself, or delete those directories and re-run npx learnhouse dev.
  • Lockfile errors in CI: after changing a package.json or apps/api/pyproject.toml, run scripts/lockfiles.sh to regenerate every lockfile. CI runs scripts/lockfiles.sh --check.