Facility Service — Local Dev Setup
Status: populated Owner: TBD Last updated: 2026-04-17 Companion: SERVICE_TEMPLATE §14
1. Prerequisites
| Tool | Version |
|---|---|
| Node | 22.x |
| pnpm | 9.x |
| Docker Desktop / compose v2 | — |
PostgreSQL client (psql) | 16+ |
| NATS CLI | 0.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...withAFG_MOPHprofile. - Root node
hnd_moph_af, regionhnd_region_kabul, hospitalhnd_ibn_sina, 2 wards, 30 beds.
5. Common commands
| Task | Command |
|---|---|
| Run | pnpm --filter @ghasi/service-facility dev |
| Test (unit) | pnpm --filter @ghasi/service-facility test |
| Test (integration) | pnpm --filter @ghasi/service-facility test:int |
| Lint + typecheck | pnpm --filter @ghasi/service-facility check |
| Drizzle generate | pnpm --filter @ghasi/service-facility db:gen |
| Drizzle migrate | pnpm --filter @ghasi/service-facility db:migrate |
| Drizzle studio | pnpm --filter @ghasi/service-facility db:studio |
| OpenAPI export | pnpm --filter @ghasi/service-facility openapi |
6. .env.example
See services/facility-service/.env.example in the application monorepo.
7. Troubleshooting
| Symptom | Fix |
|---|---|
503 on /v1/hierarchy/nodes | Ensure access-policy + licensing stubs running (pnpm dev:stubs) |
| Cycle check slow | SET enable_seqscan = off; in local; add ix_hierarchy_edges_parent |
| Cache stale | redis-cli FLUSHDB then retry |