# vuthanhthien/nestjs-boilerplate-2025 architecture

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

- Interactive diagram: https://gitdiagram.com/vuthanhthien/nestjs-boilerplate-2025
- Repository: https://github.com/vuthanhthien/nestjs-boilerplate-2025

## Overview

This repository is a NestJS boilerplate for a typical web application. Its principal workflow is an HTTP request entering the server, passing global authentication and validation, reaching an API controller, and being handled by a domain service that returns a response. The main domain areas are email authentication, user management, and posts; supporting capabilities include persistence, pagination, queued email, configuration, and API documentation. Several module-registration details and integrations are not shown in the excerpts, so those links are omitted or marked unverified.

Main entry points: [`src/main.ts`](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/main.ts) (NestJS bootstrap), [`src/api/auth/auth.service.ts`](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/auth/auth.service.ts) (Authentication service), [`src/api/user/user.service.ts`](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/user/user.service.ts) (User service), [`src/guards/auth.guard.ts`](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/guards/auth.guard.ts) (Authentication guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_server["NestJS bootstrap<br/>[main.ts]"]
  node_authguard["Authentication guard<br/>[auth.guard.ts]"]
end

subgraph group_domains["API domains"]
  node_authcontroller["Auth endpoints<br/>[auth.controller.ts]"]
  node_authservice["Authentication service<br/>[auth.service.ts]"]
  node_usercontroller["User endpoints<br/>[user.controller.ts]"]
  node_userservice["User service<br/>[user.service.ts]"]
  node_postcontroller["Post endpoints<br/>[post.controller.ts]"]
  node_postservice["Post service<br/>[post.service.ts]"]
end

subgraph group_services["Persistence and messaging"]
  node_userstore[("User repository<br/>[user.repository.ts]")]
  node_poststore[("Post entity<br/>[post.entity.ts]")]
  node_typeorm["TypeORM configuration"]
  node_emailqueue["Email queue service"]
  node_emailprocessor["Email processor<br/>[email.processor.ts]"]
  node_mail["Mail service<br/>[mail.service.ts]"]
end

subgraph group_shared["Shared API support"]
  node_pagination["Pagination utilities"]
  node_cursorpagination["Cursor pagination"]
  node_fielddecorators["DTO validation decorators"]
  node_exceptions["Global error handling"]
  node_config["Application configuration<br/>[config.type.ts]"]
  node_swagger["Swagger setup<br/>[setup-swagger.ts]"]
end

node_client(("HTTP client"))
node_database[("PostgreSQL database")]
node_redis[("Redis cache")]

node_client -->|"sends requests"| node_server
node_server -->|"installs guard"| node_authguard
node_server -->|"installs filter"| node_exceptions
node_server -->|"sets up docs"| node_swagger
node_server -->|"reads settings"| node_config
node_server -.->|"routes to"| node_authcontroller
node_server -.->|"routes to"| node_usercontroller
node_server -.->|"routes to"| node_postcontroller
node_authguard -->|"checks tokens"| node_authservice
node_authcontroller -->|"calls"| node_authservice
node_authservice -->|"reads users"| node_userstore
node_authservice -->|"enqueues email"| node_emailqueue
node_authservice -->|"uses cache"| node_redis
node_usercontroller -->|"calls"| node_userservice
node_userservice -->|"queries users"| node_userstore
node_userservice -->|"paginates results"| node_pagination
node_userservice -->|"builds cursors"| node_cursorpagination
node_postcontroller -->|"calls"| node_postservice
node_postservice -->|"queries posts"| node_poststore
node_typeorm -.->|"configures access"| node_database
node_emailqueue -->|"delegates email"| node_mail
node_emailprocessor -.->|"handles jobs"| node_mail
node_fielddecorators -.->|"documents DTOs"| node_swagger

click node_server "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/main.ts"
click node_authguard "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/guards/auth.guard.ts"
click node_authcontroller "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/auth/auth.controller.ts"
click node_authservice "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/auth/auth.service.ts"
click node_usercontroller "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/user/user.controller.ts"
click node_userservice "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/user/user.service.ts"
click node_userstore "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/user/user.repository.ts"
click node_postcontroller "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/post/post.controller.ts"
click node_postservice "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/post/post.service.ts"
click node_poststore "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/post/entities/post.entity.ts"
click node_typeorm "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/database/typeorm-config.service.ts"
click node_emailqueue "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/background/queues/email-queue/email-queue.service.ts"
click node_emailprocessor "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/background/queues/email-queue/email.processor.ts"
click node_mail "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/mail/mail.service.ts"
click node_pagination "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/utils/offset-pagination.ts"
click node_cursorpagination "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/utils/cursor-pagination.ts"
click node_fielddecorators "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/decorators/field.decorators.ts"
click node_exceptions "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/filters/global-exception.filter.ts"
click node_config "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/config/config.type.ts"
click node_swagger "https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/utils/setup-swagger.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_server,node_authguard,node_client toneBlue
class node_authcontroller,node_authservice,node_usercontroller,node_userservice,node_postcontroller,node_postservice,node_database,node_redis toneAmber
class node_userstore,node_poststore,node_typeorm,node_emailqueue,node_emailprocessor,node_mail toneMint
class node_pagination,node_cursorpagination,node_fielddecorators,node_exceptions,node_config,node_swagger toneRose
```

## Components

### Application runtime

- [NestJS bootstrap](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/main.ts): `src/main.ts`
- [Authentication guard](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/guards/auth.guard.ts): `src/guards/auth.guard.ts`

### API domains

- [Auth endpoints](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/auth/auth.controller.ts): `src/api/auth/auth.controller.ts`
- [Authentication service](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/auth/auth.service.ts): `src/api/auth/auth.service.ts`
- [User endpoints](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/user/user.controller.ts): `src/api/user/user.controller.ts`
- [User service](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/user/user.service.ts): `src/api/user/user.service.ts`
- [Post endpoints](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/post/post.controller.ts): `src/api/post/post.controller.ts`
- [Post service](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/post/post.service.ts): `src/api/post/post.service.ts`

### Persistence and messaging

- [User repository](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/user/user.repository.ts): `src/api/user/user.repository.ts`
- [Post entity](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/api/post/entities/post.entity.ts): `src/api/post/entities/post.entity.ts`
- [TypeORM configuration](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/database/typeorm-config.service.ts): `src/database/typeorm-config.service.ts`
- [Email queue service](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/background/queues/email-queue/email-queue.service.ts): `src/background/queues/email-queue/email-queue.service.ts`
- [Email processor](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/background/queues/email-queue/email.processor.ts): `src/background/queues/email-queue/email.processor.ts`
- [Mail service](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/mail/mail.service.ts): `src/mail/mail.service.ts`

### Shared API support

- [Pagination utilities](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/utils/offset-pagination.ts): `src/utils/offset-pagination.ts`
- [Cursor pagination](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/utils/cursor-pagination.ts): `src/utils/cursor-pagination.ts`
- [DTO validation decorators](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/decorators/field.decorators.ts): `src/decorators/field.decorators.ts`
- [Global error handling](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/filters/global-exception.filter.ts): `src/filters/global-exception.filter.ts`
- [Application configuration](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/config/config.type.ts): `src/config/config.type.ts`
- [Swagger setup](https://github.com/vuthanhthien/nestjs-boilerplate-2025/blob/master/src/utils/setup-swagger.ts): `src/utils/setup-swagger.ts`

### Other components

- **HTTP client**
- **PostgreSQL database**
- **Redis cache**

## Connections

- HTTP client → NestJS bootstrap: sends requests (evidence: `src/main.ts`)
- NestJS bootstrap → Authentication guard: installs guard (evidence: `src/main.ts`)
- NestJS bootstrap → Global error handling: installs filter (evidence: `src/main.ts`)
- NestJS bootstrap → Swagger setup: sets up docs (evidence: `src/main.ts`)
- NestJS bootstrap → Application configuration: reads settings (evidence: `src/main.ts`)
- NestJS bootstrap → Auth endpoints: routes to
- NestJS bootstrap → User endpoints: routes to
- NestJS bootstrap → Post endpoints: routes to
- Authentication guard → Authentication service: checks tokens (evidence: `src/guards/auth.guard.ts`)
- Auth endpoints → Authentication service: calls (evidence: `src/api/auth/auth.controller.ts`)
- Authentication service → User repository: reads users (evidence: `src/api/auth/auth.service.ts`)
- Authentication service → Email queue service: enqueues email (evidence: `src/api/auth/auth.service.ts`)
- Authentication service → Redis cache: uses cache (evidence: `src/api/auth/auth.service.ts`)
- User endpoints → User service: calls (evidence: `src/api/user/user.controller.ts`)
- User service → User repository: queries users (evidence: `src/api/user/user.service.ts`)
- User service → Pagination utilities: paginates results (evidence: `src/api/user/user.service.ts`)
- User service → Cursor pagination: builds cursors (evidence: `src/api/user/user.service.ts`)
- Post endpoints → Post service: calls (evidence: `src/api/post/post.controller.ts`)
- Post service → Post entity: queries posts (evidence: `src/api/post/post.service.ts`)
- TypeORM configuration → PostgreSQL database: configures access
- Email queue service → Mail service: delegates email (evidence: `src/background/queues/email-queue/email-queue.service.ts`)
- Email processor → Mail service: handles jobs
- DTO validation decorators → Swagger setup: documents DTOs
