# ablestack/nestjs-bff architecture

> Architecture diagram of the GitHub repository ablestack/nestjs-bff, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ablestack/nestjs-bff
- Repository: https://github.com/ablestack/nestjs-bff

## Overview

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: [`pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts`](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts) (Member provisioning), [`pkg-bff/backend/src/application/user-auth/user-auth.service.ts`](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/application/user-auth/user-auth.service.ts) (User authentication), [`pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts`](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts) (Auth endpoints), [`pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts`](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts) (Facebook OAuth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Angular client"]
  node_angular["Angular app<br/>[app.module.ts]"]
  node_routing["Route guard<br/>[app.routing.ts]"]
  node_authclient["Auth client"]
  node_reminderclient["Reminder client"]
end

subgraph group_hosting["HTTP hosting"]
  node_api["Nest HTTP host"]
  node_authcontroller["Auth endpoints<br/>[auth.controller.ts]"]
  node_orgcontroller["Organization endpoint"]
  node_remindercontroller["Reminder endpoints"]
  node_archivecontroller["Archive endpoint"]
  node_reminderorchcontroller["Archive workflow endpoint"]
end

subgraph group_application["Application workflows"]
  node_userauth["User authentication"]
  node_orgorch["Member provisioning"]
  node_reminderorch["Reminder archival"]
end

subgraph group_domain["Domain services"]
  node_authentication[("Authentication records")]
  node_social["Facebook OAuth"]
  node_users[("User records<br/>[user.repo.ts]")]
  node_organizations[("Organization records")]
  node_permissions[("Access permissions")]
  node_permissionentity["Permission model"]
  node_reminders[("Reminder records<br/>[reminder.repo.ts]")]
  node_archives[("Archive records")]
end

subgraph group_infrastructure["Shared infrastructure"]
  node_base_repo["Repository base<br/>[base.repo.ts]"]
  node_validator["Entity validation<br/>[class-validator.ts]"]
  node_authorization["Authorization checks"]
  node_authdecorator["Authorization decorator"]
  node_request["Request contract"]
  node_config["Backend configuration"]
  node_logger["Logging service"]
  node_app_error["Application errors<br/>[app.exception.ts]"]
end

node_user(("End user"))
node_facebook["Facebook OAuth service"]
node_mongo[("MongoDB")]
node_cli["Migration CLI<br/>[MigrationsUp.ts]"]

node_user -->|"uses"| node_angular
node_angular -->|"loads routes"| node_routing
node_routing -->|"guards routes"| node_authclient
node_authclient -.->|"requests backend"| node_api
node_reminderclient -.->|"requests backend"| node_api
node_api -.->|"hosts"| node_authcontroller
node_authcontroller -->|"calls"| node_userauth
node_authcontroller -->|"requests OAuth URL"| node_social
node_authcontroller -->|"declares checks"| node_authorization
node_userauth -->|"reads and writes"| node_authentication
node_userauth -->|"creates users"| node_users
node_userauth -->|"creates organizations"| node_organizations
node_userauth -->|"reads and writes"| node_permissions
node_userauth -->|"gets OAuth token"| node_social
node_social -->|"exchanges code"| node_facebook
node_social -->|"reads settings"| node_config
node_orgcontroller -->|"calls"| node_orgorch
node_orgcontroller -->|"declares checks"| node_authorization
node_orgorch -->|"creates record"| node_authentication
node_orgorch -->|"creates user"| node_users
node_orgorch -->|"checks organization"| node_organizations
node_orgorch -->|"creates permissions"| node_permissions
node_orgorch -->|"validates entity"| node_validator
node_orgorch -->|"checks access"| node_authorization
node_permissionentity -.->|"persisted by"| node_permissions
node_remindercontroller -->|"uses repository"| node_reminders
node_archivecontroller -->|"uses repository"| node_archives
node_reminderorchcontroller -->|"calls"| node_reminderorch
node_reminderorch -->|"reads and deletes"| node_reminders
node_reminderorch -->|"creates archive"| node_archives
node_authentication -.->|"persists"| node_mongo
node_users -.->|"persists"| node_mongo
node_organizations -.->|"persists"| node_mongo
node_permissions -.->|"persists"| node_mongo
node_reminders -.->|"persists"| node_mongo
node_archives -.->|"persists"| node_mongo
node_cli -.->|"manages migrations"| node_mongo

click node_angular "https://github.com/ablestack/nestjs-bff/blob/master/frontend/src/app/app.module.ts"
click node_routing "https://github.com/ablestack/nestjs-bff/blob/master/frontend/src/app/app.routing.ts"
click node_authclient "https://github.com/ablestack/nestjs-bff/blob/master/frontend/src/app/services/authentication.service.ts"
click node_reminderclient "https://github.com/ablestack/nestjs-bff/blob/master/frontend/src/app/views/reminders/reminder-data.service.ts"
click node_api "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/web-app-base.module.ts"
click node_authcontroller "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts"
click node_orgcontroller "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/application-service-host/organization-orchestration/organization-orchestration.controller.ts"
click node_remindercontroller "https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/host/http/domain-service-host/reminder/reminder.controller.ts"
click node_archivecontroller "https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/host/http/domain-service-host/reminder-archive/reminder-archive.controller.ts"
click node_reminderorchcontroller "https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/host/http/application-service-host/reminder-orchestration/reminder-orchestration.controller.ts"
click node_userauth "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/application/user-auth/user-auth.service.ts"
click node_orgorch "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts"
click node_reminderorch "https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/application/reminder-orchestration/reminder-orchestration.service.ts"
click node_authentication "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/authentication/repo/authentication.repo.ts"
click node_social "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts"
click node_users "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/user/repo/user.repo.ts"
click node_organizations "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/organization/repo/organization.repo.ts"
click node_permissions "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/access-permissions/repo/access-permissions.repo.ts"
click node_permissionentity "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/access-permissions/model/access-permissions.entity.ts"
click node_reminders "https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/domain/reminder/repo/reminder.repo.ts"
click node_archives "https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/domain/reminder-archive/repo/reminder-archive.repo.ts"
click node_base_repo "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/core/repo/base.repo.ts"
click node_validator "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/core/validators/class-validator.ts"
click node_authorization "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/shared/authchecks/org-roles.authcheck.ts"
click node_authdecorator "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/core/decorators/authorization.decorator.ts"
click node_request "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/core/types/bff-request.contract.ts"
click node_config "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/config/nestjs-bff.config.ts"
click node_logger "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/shared/logging/logger.shared.service.ts"
click node_app_error "https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/shared/exceptions/app.exception.ts"
click node_cli "https://github.com/ablestack/nestjs-bff/blob/master/cli/src/commands/MigrationsUp.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_angular,node_routing,node_authclient,node_reminderclient,node_user toneBlue
class node_api,node_authcontroller,node_orgcontroller,node_remindercontroller,node_archivecontroller,node_reminderorchcontroller,node_mongo toneAmber
class node_userauth,node_orgorch,node_reminderorch toneMint
class node_authentication,node_social,node_users,node_organizations,node_permissions,node_permissionentity,node_reminders,node_archives toneRose
class node_base_repo,node_validator,node_authorization,node_authdecorator,node_request,node_config,node_logger,node_app_error,node_facebook toneIndigo
class node_cli toneTeal
```

## Components

### Angular client

- [Angular app](https://github.com/ablestack/nestjs-bff/blob/master/frontend/src/app/app.module.ts): `frontend/src/app/app.module.ts`
- [Route guard](https://github.com/ablestack/nestjs-bff/blob/master/frontend/src/app/app.routing.ts): `frontend/src/app/app.routing.ts`
- [Auth client](https://github.com/ablestack/nestjs-bff/blob/master/frontend/src/app/services/authentication.service.ts): `frontend/src/app/services/authentication.service.ts`
- [Reminder client](https://github.com/ablestack/nestjs-bff/blob/master/frontend/src/app/views/reminders/reminder-data.service.ts): `frontend/src/app/views/reminders/reminder-data.service.ts`

### HTTP hosting

- [Nest HTTP host](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/web-app-base.module.ts): `pkg-bff/backend/src/host/http/web-app-base.module.ts`
- [Auth endpoints](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts): `pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts`
- [Organization endpoint](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/application-service-host/organization-orchestration/organization-orchestration.controller.ts): `pkg-bff/backend/src/host/http/application-service-host/organization-orchestration/organization-orchestration.controller.ts`
- [Reminder endpoints](https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/host/http/domain-service-host/reminder/reminder.controller.ts): `backend/src/app/host/http/domain-service-host/reminder/reminder.controller.ts`
- [Archive endpoint](https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/host/http/domain-service-host/reminder-archive/reminder-archive.controller.ts): `backend/src/app/host/http/domain-service-host/reminder-archive/reminder-archive.controller.ts`
- [Archive workflow endpoint](https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/host/http/application-service-host/reminder-orchestration/reminder-orchestration.controller.ts): `backend/src/app/host/http/application-service-host/reminder-orchestration/reminder-orchestration.controller.ts`

### Application workflows

- [User authentication](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/application/user-auth/user-auth.service.ts): `pkg-bff/backend/src/application/user-auth/user-auth.service.ts`
- [Member provisioning](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts): `pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts`
- [Reminder archival](https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/application/reminder-orchestration/reminder-orchestration.service.ts): `backend/src/app/application/reminder-orchestration/reminder-orchestration.service.ts`

### Domain services

- [Authentication records](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/authentication/repo/authentication.repo.ts): `pkg-bff/backend/src/domain/authentication/repo/authentication.repo.ts`
- [Facebook OAuth](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts): `pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts`
- [User records](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/user/repo/user.repo.ts): `pkg-bff/backend/src/domain/user/repo/user.repo.ts`
- [Organization records](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/organization/repo/organization.repo.ts): `pkg-bff/backend/src/domain/organization/repo/organization.repo.ts`
- [Access permissions](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/access-permissions/repo/access-permissions.repo.ts): `pkg-bff/backend/src/domain/access-permissions/repo/access-permissions.repo.ts`
- [Permission model](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/access-permissions/model/access-permissions.entity.ts): `pkg-bff/backend/src/domain/access-permissions/model/access-permissions.entity.ts`
- [Reminder records](https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/domain/reminder/repo/reminder.repo.ts): `backend/src/app/domain/reminder/repo/reminder.repo.ts`
- [Archive records](https://github.com/ablestack/nestjs-bff/blob/master/backend/src/app/domain/reminder-archive/repo/reminder-archive.repo.ts): `backend/src/app/domain/reminder-archive/repo/reminder-archive.repo.ts`

### Shared infrastructure

- [Repository base](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/core/repo/base.repo.ts): `pkg-bff/backend/src/domain/core/repo/base.repo.ts`
- [Entity validation](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/domain/core/validators/class-validator.ts): `pkg-bff/backend/src/domain/core/validators/class-validator.ts`
- [Authorization checks](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/shared/authchecks/org-roles.authcheck.ts): `pkg-bff/backend/src/shared/authchecks/org-roles.authcheck.ts`
- [Authorization decorator](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/core/decorators/authorization.decorator.ts): `pkg-bff/backend/src/host/http/core/decorators/authorization.decorator.ts`
- [Request contract](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/host/http/core/types/bff-request.contract.ts): `pkg-bff/backend/src/host/http/core/types/bff-request.contract.ts`
- [Backend configuration](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/config/nestjs-bff.config.ts): `pkg-bff/backend/src/config/nestjs-bff.config.ts`
- [Logging service](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/shared/logging/logger.shared.service.ts): `pkg-bff/backend/src/shared/logging/logger.shared.service.ts`
- [Application errors](https://github.com/ablestack/nestjs-bff/blob/master/pkg-bff/backend/src/shared/exceptions/app.exception.ts): `pkg-bff/backend/src/shared/exceptions/app.exception.ts`

### Other components

- **End user**
- **Facebook OAuth service**
- **MongoDB**
- [Migration CLI](https://github.com/ablestack/nestjs-bff/blob/master/cli/src/commands/MigrationsUp.ts): `cli/src/commands/MigrationsUp.ts`

## Connections

- End user → Angular app: uses (evidence: `README.md`)
- Angular app → Route guard: loads routes (evidence: `frontend/src/app/app.module.ts`)
- Route guard → Auth client: guards routes (evidence: `frontend/src/app/app.routing.ts`)
- Auth client → Nest HTTP host: requests backend (evidence: `README.md`)
- Reminder client → Nest HTTP host: requests backend (evidence: `README.md`)
- Nest HTTP host → Auth endpoints: hosts
- Auth endpoints → User authentication: calls (evidence: `pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts`)
- Auth endpoints → Facebook OAuth: requests OAuth URL (evidence: `pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts`)
- Auth endpoints → Authorization checks: declares checks (evidence: `pkg-bff/backend/src/host/http/application-service-host/auth/auth.controller.ts`)
- User authentication → Authentication records: reads and writes (evidence: `pkg-bff/backend/src/application/user-auth/user-auth.service.ts`)
- User authentication → User records: creates users (evidence: `pkg-bff/backend/src/application/user-auth/user-auth.service.ts`)
- User authentication → Organization records: creates organizations (evidence: `pkg-bff/backend/src/application/user-auth/user-auth.service.ts`)
- User authentication → Access permissions: reads and writes (evidence: `pkg-bff/backend/src/application/user-auth/user-auth.service.ts`)
- User authentication → Facebook OAuth: gets OAuth token (evidence: `pkg-bff/backend/src/application/user-auth/user-auth.service.ts`)
- Facebook OAuth → Facebook OAuth service: exchanges code (evidence: `pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts`)
- Facebook OAuth → Backend configuration: reads settings (evidence: `pkg-bff/backend/src/domain/authentication/social/facebook-authentication.service.ts`)
- Organization endpoint → Member provisioning: calls (evidence: `pkg-bff/backend/src/host/http/application-service-host/organization-orchestration/organization-orchestration.controller.ts`)
- Organization endpoint → Authorization checks: declares checks (evidence: `pkg-bff/backend/src/host/http/application-service-host/organization-orchestration/organization-orchestration.controller.ts`)
- Member provisioning → Authentication records: creates record (evidence: `pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts`)
- Member provisioning → User records: creates user (evidence: `pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts`)
- Member provisioning → Organization records: checks organization (evidence: `pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts`)
- Member provisioning → Access permissions: creates permissions (evidence: `pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts`)
- Member provisioning → Entity validation: validates entity (evidence: `pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts`)
- Member provisioning → Authorization checks: checks access (evidence: `pkg-bff/backend/src/application/organization-orchestration/organization-orchestration.service.ts`)
- Permission model → Access permissions: persisted by (evidence: `pkg-bff/backend/src/domain/access-permissions/repo/access-permissions.repo.ts`)
- Reminder endpoints → Reminder records: uses repository (evidence: `backend/src/app/host/http/domain-service-host/reminder/reminder.controller.ts`)
- Archive endpoint → Archive records: uses repository (evidence: `backend/src/app/host/http/domain-service-host/reminder-archive/reminder-archive.controller.ts`)
- Archive workflow endpoint → Reminder archival: calls (evidence: `backend/src/app/host/http/application-service-host/reminder-orchestration/reminder-orchestration.controller.ts`)
- Reminder archival → Reminder records: reads and deletes (evidence: `backend/src/app/application/reminder-orchestration/reminder-orchestration.service.ts`)
- Reminder archival → Archive records: creates archive (evidence: `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 (evidence: `README.md`)
