How ablestack/nestjs-bff works
NestJS-BFF is a full-stack TypeScript starter: an Angular client calls a NestJS backend that exposes authentication and domain/application services, with shared infrastructure for persistence, authorization, configuration, caching, and logging. The main user workflow is local or Facebook sign-in/sign-up, followed by JWT issuance and access to protected routes; organization membership and the reminder archive example show additional domain workflows. The README documents migrations and the CLI. Some subsystem links are omitted because their source was not sampled; dashed links mark documented or otherwise unverified integration.
Main entry points: organization-orchestration.service.ts Member provisioning · user-auth.service.ts User authentication · auth.controller.ts Auth endpoints · facebook-authentication.service.ts Facebook OAuth
Components 33
Angular client
- Angular app
frontend/src/app/app.module.ts - Route guard
frontend/src/app/app.routing.ts - Auth client
frontend/src/app/services/authentication.service.ts - Reminder client
frontend/src/app/views/reminders/reminder-data.service.ts
HTTP hosting
- Nest HTTP host
pkg-bff/backend/src/host/http/web-app-base.module.ts - Auth endpoints
pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts - Organization endpoint
pkg-bff/backend/src/host/http/application-service-host/organization-orchestration/organization-orchestration.controller.ts - Reminder endpoints
backend/src/app/host/http/domain-service-host/reminder/reminder.controller.ts - Archive endpoint
backend/src/app/host/http/domain-service-host/reminder-archive/reminder-archive.controller.ts - Archive workflow endpoint
backend/src/app/host/http/application-service-host/reminder-orchestration/reminder-orchestration.controller.ts
Application workflows
- User authentication
pkg-bff/backend/src/application/user-auth/user-auth.service.ts - Member provisioning
pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts - Reminder archival
backend/src/app/application/reminder-orchestration/reminder-orchestration.service.ts
Domain services
- Authentication records
pkg-bff/backend/src/domain/authentication/repo/authentication.repo.ts - Facebook OAuth
pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts - User records
pkg-bff/backend/src/domain/user/repo/user.repo.ts - Organization records
pkg-bff/backend/src/domain/organization/repo/organization.repo.ts - Access permissions
pkg-bff/backend/src/domain/access-permissions/repo/access-permissions.repo.ts - Permission model
pkg-bff/backend/src/domain/access-permissions/model/access-permissions.entity.ts - Reminder records
backend/src/app/domain/reminder/repo/reminder.repo.ts - Archive records
backend/src/app/domain/reminder-archive/repo/reminder-archive.repo.ts
Shared infrastructure
- Repository base
pkg-bff/backend/src/domain/core/repo/base.repo.ts - Entity validation
pkg-bff/backend/src/domain/core/validators/class-validator.ts - Authorization checks
pkg-bff/backend/src/shared/authchecks/org-roles.authcheck.ts - Authorization decorator
pkg-bff/backend/src/host/http/core/decorators/authorization.decorator.ts - Request contract
pkg-bff/backend/src/host/http/core/types/bff-request.contract.ts - Backend configuration
pkg-bff/backend/src/config/nestjs-bff.config.ts - Logging service
pkg-bff/backend/src/shared/logging/logger.shared.service.ts - Application errors
pkg-bff/backend/src/shared/exceptions/app.exception.ts
Other components
- End user
- Facebook OAuth service
- MongoDB
- Migration CLI
cli/src/commands/MigrationsUp.ts
Connections 37
- End user → Angular app: uses
README.md - Angular app → Route guard: loads routes
frontend/src/app/app.module.ts - Route guard → Auth client: guards routes
frontend/src/app/app.routing.ts - Auth client → Nest HTTP host: requests backend
README.md - Reminder client → Nest HTTP host: requests backend
README.md - Nest HTTP host → Auth endpoints: hosts
- Auth endpoints → User authentication: calls
pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts - Auth endpoints → Facebook OAuth: requests OAuth URL
pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts - Auth endpoints → Authorization checks: declares checks
pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts - User authentication → Authentication records: reads and writes
pkg-bff/backend/src/application/user-auth/user-auth.service.ts - User authentication → User records: creates users
pkg-bff/backend/src/application/user-auth/user-auth.service.ts - User authentication → Organization records: creates organizations
pkg-bff/backend/src/application/user-auth/user-auth.service.ts - User authentication → Access permissions: reads and writes
pkg-bff/backend/src/application/user-auth/user-auth.service.ts - User authentication → Facebook OAuth: gets OAuth token
pkg-bff/backend/src/application/user-auth/user-auth.service.ts - Facebook OAuth → Facebook OAuth service: exchanges code
pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts - Facebook OAuth → Backend configuration: reads settings
pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts - Organization endpoint → Member provisioning: calls
pkg-bff/backend/src/host/http/application-service-host/organization-orchestration/organization-orchestration.controller.ts - Organization endpoint → Authorization checks: declares checks
pkg-bff/backend/src/host/http/application-service-host/organization-orchestration/organization-orchestration.controller.ts - Member provisioning → Authentication records: creates record
pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts - Member provisioning → User records: creates user
pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts - Member provisioning → Organization records: checks organization
pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts - Member provisioning → Access permissions: creates permissions
pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts - Member provisioning → Entity validation: validates entity
pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts - Member provisioning → Authorization checks: checks access
pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts - Permission model → Access permissions: persisted by
pkg-bff/backend/src/domain/access-permissions/repo/access-permissions.repo.ts - Reminder endpoints → Reminder records: uses repository
backend/src/app/host/http/domain-service-host/reminder/reminder.controller.ts - Archive endpoint → Archive records: uses repository
backend/src/app/host/http/domain-service-host/reminder-archive/reminder-archive.controller.ts - Archive workflow endpoint → Reminder archival: calls
backend/src/app/host/http/application-service-host/reminder-orchestration/reminder-orchestration.controller.ts - Reminder archival → Reminder records: reads and deletes
backend/src/app/application/reminder-orchestration/reminder-orchestration.service.ts - Reminder archival → Archive records: creates archive
backend/src/app/application/reminder-orchestration/reminder-orchestration.service.ts - Authentication records → MongoDB: persists
- User records → MongoDB: persists
- Organization records → MongoDB: persists
- Access permissions → MongoDB: persists
- Reminder records → MongoDB: persists
- Archive records → MongoDB: persists
- Migration CLI → MongoDB: manages migrations
README.md