Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 2.26 KB

BackendSetup.md

File metadata and controls

68 lines (47 loc) · 2.26 KB

Backend setup

The API lives in apps/api and uses Express, TypeScript, Drizzle ORM and PostgreSQL 17. Install, database and environment steps are in the local development guide, which is the one place they are kept.

Set up

  1. Check the prerequisites and install dependencies.
  2. Start PostgreSQL.
  3. Create apps/api/.env.
  4. Create the tables and load demo data.
  5. Optionally run the worker.

Commands

Run these from the repository root.

Start the API with reload at http://localhost:5050:

pnpm --filter karmacircle-api dev
pnpm --filter karmacircle-api lint
pnpm --filter karmacircle-api type-check
pnpm --filter karmacircle-api build

Run the built API:

pnpm --filter karmacircle-api start

Run the Jest and Supertest suite:

pnpm --filter karmacircle-api test

The suite uses a local database named karmacircle_test, which it creates and empties itself.

Database

Command What it does
pnpm --filter karmacircle-api db:generate Writes a SQL migration from the Drizzle schema
pnpm --filter karmacircle-api db:migrate Applies pending migrations to DATABASE_URL
pnpm --filter karmacircle-api db:seed Loads demo data into a local database

Nothing migrates the database when the API starts. Deploys run the migrations first (database hosting). The performance scripts, perf:seed and perf:explain, are described in Database performance.

Interactive API documentation is at http://localhost:5050/docs while the API is running.

Code conventions

Use the existing route, service, schema and test patterns. Document API changes in the backend specs and the API contract, and update the frontend integration docs when a request or response shape changes. Run the relevant checks before opening a pull request.