# amart302/nest-template architecture

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

- Interactive diagram: https://gitdiagram.com/amart302/nest-template
- Repository: https://github.com/amart302/nest-template

## Overview

This NestJS template provides a small HTTP API foundation. Its demonstrated request path is a client calling the health endpoint, whose controller delegates to a service; global HTTP handling formats successful and exceptional responses. Startup configures validation, CORS, Swagger, and environment checks, while a global Prisma service connects to PostgreSQL. The README documents the database and template capabilities; unsampled modules are represented only where the tree or documentation supports them.

Main entry points: [`src/app.module.ts`](https://github.com/amart302/nest-template/blob/main/src/app.module.ts) (Root module), [`src/main.ts`](https://github.com/amart302/nest-template/blob/main/src/main.ts) (HTTP bootstrap), [`src/app.controller.ts`](https://github.com/amart302/nest-template/blob/main/src/app.controller.ts) (Health endpoint), [`src/app.service.ts`](https://github.com/amart302/nest-template/blob/main/src/app.service.ts) (Health service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_bootstrap["HTTP bootstrap<br/>[main.ts]"]
  node_appmodule["Root module<br/>[app.module.ts]"]
  node_env["Environment checks<br/>[env.validation.ts]"]
end

subgraph group_http["HTTP capabilities"]
  node_health["Health endpoint<br/>[app.controller.ts]"]
  node_healthservice["Health service<br/>[app.service.ts]"]
  node_responsetypes["Response types"]
  node_response["Success formatting"]
  node_errors["Error formatting"]
  node_swagger["Swagger setup<br/>[swagger.config.ts]"]
end

subgraph group_integrations["Platform integrations"]
  node_static["Static uploads<br/>[app.module.ts]"]
  node_prismamodule["Prisma module<br/>[prisma.module.ts]"]
  node_prismaservice["Prisma service<br/>[prisma.service.ts]"]
  node_postgres[("PostgreSQL")]
end

node_client(("API client"))

node_client -->|"requests health"| node_health
node_bootstrap -->|"creates app"| node_appmodule
node_appmodule -->|"validates settings"| node_env
node_appmodule -->|"registers controller"| node_health
node_health -->|"delegates health"| node_healthservice
node_health -->|"returns typed response"| node_responsetypes
node_healthservice -->|"returns typed response"| node_responsetypes
node_bootstrap -->|"installs globally"| node_response
node_bootstrap -->|"installs globally"| node_errors
node_bootstrap -->|"configures docs"| node_swagger
node_appmodule -->|"serves uploads"| node_static
node_appmodule -->|"imports module"| node_prismamodule
node_prismamodule -->|"provides service"| node_prismaservice
node_prismaservice -->|"connects to"| node_postgres

click node_bootstrap "https://github.com/amart302/nest-template/blob/main/src/main.ts"
click node_appmodule "https://github.com/amart302/nest-template/blob/main/src/app.module.ts"
click node_env "https://github.com/amart302/nest-template/blob/main/src/common/config/env.validation.ts"
click node_health "https://github.com/amart302/nest-template/blob/main/src/app.controller.ts"
click node_healthservice "https://github.com/amart302/nest-template/blob/main/src/app.service.ts"
click node_responsetypes "https://github.com/amart302/nest-template/blob/main/src/common/types/service-response.types.ts"
click node_response "https://github.com/amart302/nest-template/blob/main/src/common/interceptors/response.interceptor.ts"
click node_errors "https://github.com/amart302/nest-template/blob/main/src/common/filters/all-exceptions.filter.ts"
click node_swagger "https://github.com/amart302/nest-template/blob/main/src/common/config/swagger.config.ts"
click node_static "https://github.com/amart302/nest-template/blob/main/src/app.module.ts"
click node_prismamodule "https://github.com/amart302/nest-template/blob/main/src/prisma/prisma.module.ts"
click node_prismaservice "https://github.com/amart302/nest-template/blob/main/src/prisma/prisma.service.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_bootstrap,node_appmodule,node_env,node_client toneBlue
class node_health,node_healthservice,node_responsetypes,node_response,node_errors,node_swagger toneAmber
class node_static,node_prismamodule,node_prismaservice,node_postgres toneMint
```

## Components

### Application runtime

- [HTTP bootstrap](https://github.com/amart302/nest-template/blob/main/src/main.ts): `src/main.ts`
- [Root module](https://github.com/amart302/nest-template/blob/main/src/app.module.ts): `src/app.module.ts`
- [Environment checks](https://github.com/amart302/nest-template/blob/main/src/common/config/env.validation.ts): `src/common/config/env.validation.ts`

### HTTP capabilities

- [Health endpoint](https://github.com/amart302/nest-template/blob/main/src/app.controller.ts): `src/app.controller.ts`
- [Health service](https://github.com/amart302/nest-template/blob/main/src/app.service.ts): `src/app.service.ts`
- [Response types](https://github.com/amart302/nest-template/blob/main/src/common/types/service-response.types.ts): `src/common/types/service-response.types.ts`
- [Success formatting](https://github.com/amart302/nest-template/blob/main/src/common/interceptors/response.interceptor.ts): `src/common/interceptors/response.interceptor.ts`
- [Error formatting](https://github.com/amart302/nest-template/blob/main/src/common/filters/all-exceptions.filter.ts): `src/common/filters/all-exceptions.filter.ts`
- [Swagger setup](https://github.com/amart302/nest-template/blob/main/src/common/config/swagger.config.ts): `src/common/config/swagger.config.ts`

### Platform integrations

- [Static uploads](https://github.com/amart302/nest-template/blob/main/src/app.module.ts): `src/app.module.ts`
- [Prisma module](https://github.com/amart302/nest-template/blob/main/src/prisma/prisma.module.ts): `src/prisma/prisma.module.ts`
- [Prisma service](https://github.com/amart302/nest-template/blob/main/src/prisma/prisma.service.ts): `src/prisma/prisma.service.ts`
- **PostgreSQL**

### Other components

- **API client**

## Connections

- API client → Health endpoint: requests health (evidence: `src/app.controller.ts`)
- HTTP bootstrap → Root module: creates app (evidence: `src/main.ts`)
- Root module → Environment checks: validates settings (evidence: `src/app.module.ts`)
- Root module → Health endpoint: registers controller (evidence: `src/app.module.ts`)
- Health endpoint → Health service: delegates health (evidence: `src/app.controller.ts`)
- Health endpoint → Response types: returns typed response (evidence: `src/app.controller.ts`)
- Health service → Response types: returns typed response (evidence: `src/app.service.ts`)
- HTTP bootstrap → Success formatting: installs globally (evidence: `src/main.ts`)
- HTTP bootstrap → Error formatting: installs globally (evidence: `src/main.ts`)
- HTTP bootstrap → Swagger setup: configures docs (evidence: `src/main.ts`)
- Root module → Static uploads: serves uploads (evidence: `src/app.module.ts`)
- Root module → Prisma module: imports module (evidence: `src/app.module.ts`)
- Prisma module → Prisma service: provides service (evidence: `src/prisma/prisma.module.ts`)
- Prisma service → PostgreSQL: connects to (evidence: `src/prisma/prisma.service.ts`)
