Backend for recipe app based on typescript, typeorm and postgres
  • TypeScript 96.5%
  • Bru 2.3%
  • Ruby 1.2%
Find a file
2026-10-24 05:24:51 +00:00
.claude fix(claude) Use the scp-style URL for the recipe-platform plugin marketplace 2026-09-27 06:59:12 +02:00
.forgejo/workflows chore(ci) Check the contract pin in the PR pipeline 2026-10-03 19:39:51 +02:00
bruno/recipe-backend chore(bruno) Add shopping list and list-shareable requests 2026-10-02 23:22:17 +02:00
docs docs(mappers) Describe embedded users as CompactUserDto in comments and architecture.md 2026-10-04 08:49:55 +02:00
scripts Ruby for converting the LaTeX recipe book to the new format and filling the backend with recipes and tags using the API 2026-03-02 21:09:20 +01:00
src test(mappers) Realign the mapper declarations in MealPlanDtoEntityMapper.test 2026-10-04 09:06:18 +02:00
.gitignore test(shoppingList) Fix review findings in the tests and ignore the coverage report 2026-10-04 07:01:58 +02:00
CLAUDE.md docs(workflow) Import the platform team list in CLAUDE.md 2026-10-18 07:52:12 +02:00
contract.ref feat(mappers) Expose embedded users of comments, ratings, tags and meal plan shares as CompactUserDto 2026-10-04 08:48:05 +02:00
package-lock.json fix(ci) Install api-contract's own deps in CI; declare them as direct deps here 2026-09-19 18:56:52 +02:00
package.json test(integration) Add database-backed integration test setup 2026-10-03 20:12:14 +02:00
README.md docs(readme) Add tech stack, cheat sheet, and architecture link 2026-09-19 07:36:27 +02:00
tsconfig.json test(integration) Add database-backed integration test setup 2026-10-03 20:12:14 +02:00
vitest.config.ts test(integration) Add database-backed integration test setup 2026-10-03 20:12:14 +02:00
vitest.integration.config.ts test(integration) Add database-backed integration test setup 2026-10-03 20:12:14 +02:00

Recipe Backend

Backend for a personal recipe management application. Users can create and browse recipes, organize them into weekly meal plans, share plans with other users, and import recipes from photos via AI. Authentication supports both password login and passkeys (WebAuthn).

Tech stack: Node.js · Express · TypeScript · TypeORM · PostgreSQL · Vitest
For architecture details, layer model, data model, and design decisions see docs/architecture.md.

Quick start

# Install dependencies
npm install

# Create and fill in the environment file (see Environment setup below)
cp .env.development.example .env.development

# Apply database migrations
npm run migration

# Start in watch mode (TypeScript compiler + nodemon in parallel)
npm run start:dev

The server starts on the host and port configured in .env.development (default localhost:4000).

Environment setup

Create .env.development in the project root. Required variables:

Variable Example Notes
DB_HOST localhost
DB_PORT 5432
DB_USERNAME recipe-backend
DB_PASSWORD …
DB_DATABASE recipe-backend-dev
JWT_SECRET long random string Generate with openssl rand -base64 64
ALLOWED_ORIGINS http://localhost:5173 Comma-separated frontend origins
PORT 4000
HOST localhost Use 0.0.0.0 to bind on all interfaces
IMAGES_DIR /srv/recipe-backend/images Absolute path; must exist and be writable
ANTHROPIC_API_KEY sk-ant-… Required for AI recipe import; feature disabled if absent
ANTHROPIC_MODEL claude-sonnet-4-6
WEBAUTHN_RP_ID localhost Frontend hostname — no protocol or port
WEBAUTHN_RP_NAME Recipe App Shown in browser passkey prompts
WEBAUTHN_ORIGIN http://localhost:5173 Full frontend origin as the browser sees it

.env.development is gitignored and must never be committed. For stage and production values see docs/deployment.md.

Cheat sheet

Dev server

npm run start:dev      # Compile TypeScript (watch) + nodemon in parallel — the main dev command
npm run watch          # TypeScript watch only (no server)
npm run build          # Compile once
npm run start:prod     # Run compiled output (production)

Tests

npm test               # Run once
npm run test:watch     # Watch mode — re-runs on file changes
npm run test:coverage  # Coverage report (output in coverage/)

Database migrations

# Apply all pending migrations
npm run migration

# Generate a new migration from entity changes (replace MyMigrationName)
npm run typeorm -- migration:generate src/migrations/MyMigrationName -d ./src/data-source.ts

# Create a blank migration file to fill in manually
npm run typeorm -- migration:create src/migrations/MyMigrationName

Migrations are TypeScript source files in src/migrations/ compiled to build/migrations/. Never use synchronize: true.

Environment file

# Restore .env.development if accidentally deleted
git show c200dc1^:.env.development > .env.development

API testing (Bruno)

Bruno request files live in bruno/recipe-backend/. Open that folder in Bruno, select an environment from environments/ (gitignored), and fire requests against the running dev server.

Documentation