Backend Architecture
This backend is a Node.js + TypeScript service with GraphQL, HTTP endpoints, background workflows, and Prisma persistence.
Stack
- Runtime: Node.js (CommonJS), TypeScript
- API Layer: GraphQL + Express routes
- Persistence: Prisma (
@prisma/client) - Workflows: state-machine style engines under
src/core/workflow - Integrations: Stripe, Paymob, Twilio, push notifications, email templates
High-Level Layers
src/server*
- Bootstraps Express/GraphQL server and middleware.
- Wires route registration and app startup concerns.
src/data
- GraphQL schema composition and resolvers.
- Permission checks, query/mutation handlers, and GraphQL object types.
src/application
- Service layer and repository interfaces.
- Encapsulates use-case logic, independent from ORM-specific details.
src/infrastructure/prisma
- Concrete repository implementations and unit-of-work wiring.
- Translates domain/application calls into Prisma operations.
src/core
- Domain-heavy modules:
- reservation/document workflows
- payment orchestration
- email rendering/sending
- cron tasks
- sockets and notifications
src/libs and src/helpers
- Shared runtime utilities, middleware, external service wrappers, and helpers.
Request Lifecycle (GraphQL)
- Request enters GraphQL server in
src/server. - Resolver in
src/data/queriesorsrc/data/mutationsvalidates input and permissions. - Resolver calls application services/repositories through unit-of-work context.
- Prisma repositories execute DB access.
- Side effects (notifications, emails, workflow transitions) are triggered from services/core modules.
- Resolver returns typed response shape.
Workflow Architecture
- Workflow definitions live in:
src/core/workflow/ReservationWorkflow.tssrc/core/workflow/DocumentApprovalWorkflow.ts
- Shared abstractions:
BaseWorkflowWorkflowDispatcherWorkflowHandlertypes.ts
- Generated docs:
Documentation Source of Truth
- Human-authored architecture/operations docs in
apps/backend/docs. - Auto-generated workflow/notification docs from scripts in
apps/backend/scripts. - Auto-generated TypeScript API docs from
TypeDocinapps/backend/docs/api.