functional-ts
Functional Domain Modeling in TypeScript
Principles for writing domain models in server-side TypeScript. Instead of class-based OOP, this approach maximizes the TypeScript type system through a functional style.
1. Type-Driven Domain Modeling
Represent states with discriminated unions using kind as the unified discriminant. Use type (not interface), companion objects, branded types, Readonly<>, function property notation, and one-concept-per-file structure.
Validation library detection: Check dependencies / devDependencies in the project's package.json for branded type syntax:
zod→ validation-libraries/zod.mdvalibot→ validation-libraries/valibot.mdarktype→ validation-libraries/arktype.md
Details: domain-modeling.md
2. State Transitions via Functions
Express state transitions with pure functions. The argument type constrains valid source states, and the return type makes the target state explicit. Invalid transitions become compile errors. Use assertNever for exhaustiveness checking.