Imported from Nata1889/medical-appointments-backend (
AGENTS.md). Install upstream withnpx skills add Nata1889/medical-appointments-backend. Copyright stays with the author.
Medical Appointments API
Commands
- Dev server:
npm run dev(tsx watch src/server.ts). - Production build:
npm run build(tsc, outputs todist/). - Type-only check:
npm run typecheck(tsc --noEmit). - Start built app:
npm start(node dist/server.js).
Architecture
src/app.tsbuilds and exports the Express app; keep listener/process shutdown logic insrc/server.ts.- Register HTTP paths in
src/routes/*; route handlers live insrc/controllers/*. - Put business logic in
src/services/*when it exists; do not put future database access in controllers. - Health route is mounted as
app.use("/api/health", healthRouter), and the router handlesGET /.
TypeScript And Imports
- The project is ESM (
"type": "module") withmodule/moduleResolutionset toNodeNext. - Local TypeScript imports must include
.jsextensions, even when importing.tssource files. - Strict flags include
strict,noUncheckedIndexedAccess, andexactOptionalPropertyTypes; avoidany.
Environment
- Runtime env is loaded by
src/config/env.tsviaimport "dotenv/config"and validated with Zod. - Current env keys are
NODE_ENV,PORT, andFRONTEND_URL; update.env.examplewhen adding keys. - Never modify
.envor commit secrets.
Verification
- After code changes, run
npm run typecheckandnpm run build. - If adding a configured test runner later, add the focused test command here and run it for relevant changes.
Medical AI Safety
- Future AI components must not diagnose, prescribe medication, recommend dosages, replace professional care, or invent doctors/specialties/appointment slots.
- An appointment agent must never create or cancel appointments without explicit user confirmation.
Current database setup
- PostgreSQL runs locally through Docker Compose.
- Prisma ORM is configured with the
prisma-clientgenerator. - Prisma Client is generated into
src/generated/prisma. - PostgreSQL access uses
@prisma/adapter-pg. - The Prisma instance lives in
src/config/prisma.ts. - The schema includes the initial medical appointments domain models.
- Migrations include manual SQL objects that Prisma cannot fully represent, including partial unique indexes and
CHECKconstraints. - Consult
docs/database-constraints.mdbefore editing migrations or appointment/availability constraints. - Do not use
prisma db pushin this project. - Do not create models or migrations unless explicitly requested.
Database commands
npm run db:up: starts PostgreSQL.npm run db:down: stops PostgreSQL.npm run db:logs: follows PostgreSQL logs.npm run db:reset: removes PostgreSQL and its local volume.npm run prisma:validate: validates the Prisma schema.npm run prisma:generate: generates Prisma Client.npm run prisma:studio: opens Prisma Studio.