ADR 0001: TeeTime adopted (NestJS modular architecture)
- Status: accepted
- Date: 2025-10-03
Context
TeeTime spans multiple apps (backend APIs, admin portal, public UI, workers) and needs a consistent way to:
- enforce auth and access control,
- share domain services (tee-sheet, booking, weather, messaging),
- emit real-time events (WebSocket/SSE) and durable events (outbox),
- keep “core” logic reusable across apps without duplicating controllers/services.
Decision
Adopt a modular NestJS architecture where:
- cross-cutting auth/guards live in
libs/auth, - shared tee-time domain services + façade controllers live in
libs/tee-time-services, - the backend app (
apps/teetime/teetime-backend) composes those libs and owns:- app bootstrap and global middleware,
- admin-only controllers that are tightly coupled to the deployed backend,
- Swagger configuration and operational endpoints.
This docs site (apps/teetime/docs) is the canonical reference for implementers and operators.
Consequences
Positive:
- Shared logic is implemented once and reused across apps.
- Controllers stay thin and delegate to services with explicit contracts.
- Real-time and messaging integrations can be feature-flagged and no-op safely when optional dependencies are absent.
Trade-offs:
- Requires discipline around module boundaries and dependency wiring.
- Some endpoints are defined in libraries but are only “real” when the backend app includes the relevant module/providers.
References
libs/authlibs/tee-time-servicesapps/teetime/teetime-backend/src/main.tsapps/teetime/docs