Skip to main content

Facility Service — Local Dev Setup

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: SERVICE_TEMPLATE §14

1. Prerequisites

ToolVersion
Node22.x
pnpm9.x
Docker Desktop / compose v2
PostgreSQL client (psql)16+
NATS CLI0.1+

2. docker compose

docker-compose.yml (in repo root of services mono):

services:
postgres:
image: postgres:16
environment:
POSTGRES_USER: ghasi
POSTGRES_PASSWORD: ghasi
POSTGRES_DB: facility
ports: ["5432:5432"]
redis:
image: redis:7
ports: ["6379:6379"]
nats:
image: nats:2.10-alpine
command: ["-js", "-m", "8222"]
ports: ["4222:4222", "8222:8222"]
kong:
image: kong:3.6
environment:
KONG_DATABASE: "off"
KONG_DECLARATIVE_CONFIG: /kong.yml
ports: ["8000:8000", "8001:8001"]

3. Bootstrap

pnpm install
docker compose up -d postgres redis nats
pnpm --filter @ghasi/service-facility migrate:dev
pnpm --filter @ghasi/service-facility seed
pnpm --filter @ghasi/service-facility dev

4. Seed data

The seed script inserts:

  • 5 platform profiles (AFG_MOPH, UAE_DOH, PRIVATE_HOSPITAL, CLINIC_SIMPLE, TELEMEDICINE).
  • One demo tenant ten_demo_01H... with AFG_MOPH profile.
  • Root node hnd_moph_af, region hnd_region_kabul, hospital hnd_ibn_sina, 2 wards, 30 beds.

5. Common commands

TaskCommand
Runpnpm --filter @ghasi/service-facility dev
Test (unit)pnpm --filter @ghasi/service-facility test
Test (integration)pnpm --filter @ghasi/service-facility test:int
Lint + typecheckpnpm --filter @ghasi/service-facility check
Drizzle generatepnpm --filter @ghasi/service-facility db:gen
Drizzle migratepnpm --filter @ghasi/service-facility db:migrate
Drizzle studiopnpm --filter @ghasi/service-facility db:studio
OpenAPI exportpnpm --filter @ghasi/service-facility openapi

6. .env.example

See services/facility-service/.env.example in the application monorepo.

7. Troubleshooting

SymptomFix
503 on /v1/hierarchy/nodesEnsure access-policy + licensing stubs running (pnpm dev:stubs)
Cycle check slowSET enable_seqscan = off; in local; add ix_hierarchy_edges_parent
Cache staleredis-cli FLUSHDB then retry