Logo

Sharing Excess

Food Rescue Platform
For Developers

Code Style & Patterns

Language & runtime

  • TypeScript everywhere; Bun runtime and package manager

Formatting & linting (Biome)

  • Config in biome.json
  • 2-space tabs, LF, width 80
  • Key rules:
    • No unused imports (auto-fix safe)
    • No undeclared variables
    • Prefer self-closing elements, single var declarator
    • Allow any where necessary (nursery rules off)

Project structure patterns

  • Client
    • Pages under src/pages/**, components under src/components/**
    • Prefer small, focused components; keep pages < ~200 LOC when possible
    • State: favor stores for browser-only state; forms for server POST submissions
  • Server
    • Route files organized per domain under src/routes/**
    • Service-layer per domain under src/services/**
    • Shared utils under src/utils/**
    • OpenAPI helpers for consistent responses
  • Shared packages
    • DB schema centralizes enums/types via @sharingexcess/types
    • Types package centralizes request/response schemas

Testing posture

  • Server: Bun test runner configured (apps/server/package.json)
  • Tests live under apps/server/src/tests/** with setup file
  • Test DB URLs should not point at production; in prod TEST_DATABASE_URL points to staging

Auth & security

  • Validate all requests on server via Clerk; map to DB users; enforce permissions per route
  • CORS per environment, credentials enabled
  • Production runs as non-root inside containers

Performance & reliability

  • Server auto-caches all-time impact in non-dev environments
  • Railway healthchecks for server (/ with 180s timeout)
  • Multi-region and replica counts configured per env

Tooling notes

  • Use Turbo to orchestrate dev with dependency ordering (client depends on server)
  • Use Bun workspace filtering in Docker for smaller images
  • Scripts for DB pushes handle env switching automatically