Skip to main content

Type safety layers

Backend type safety

Prisma-generated types

Prisma generates TypeScript types from the schema:

DTO validation

Request DTOs use class-validator decorators with TypeScript classes:
The global ValidationPipe enforces these DTOs on every request (see Validation).

Request types

The request object is extended with auth context:

Environment validation

Startup environment variables are validated with a Zod schema in backend/src/config/env.validation.ts. An invalid environment fails the boot.

Frontend type safety

API response types

src/lib/domain-types.ts is the canonical frontend source of truth for REST response shapes (Client, Store, Employee, RuleSet, report types), with order-lifecycle types in src/lib/types.ts:

Zod schemas

Forms validate with Zod schemas through React Hook Form resolvers:

Enum sharing

Enums exist as Prisma enums on the backend and mirrored string-literal unions on the frontend:
The frontend’s status registry (src/lib/order-status.ts, src/lib/status.ts) derives labels and treatments from these unions so the UI can never display an unmapped status.

Strict TypeScript settings

Backend tsconfig.json enables strict plus noUncheckedIndexedAccess, noImplicitReturns, and noFallthroughCasesInSwitch. The frontend enables strict with the @/* path alias mapped to ./src/*. Production code carries zero avoidable any and zero @ts-ignore directives; test mocks are the only relaxed area.

Known gaps