# socheatathai/express-api architecture

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

- Interactive diagram: https://gitdiagram.com/socheatathai/express-api
- Repository: https://github.com/socheatathai/express-api

## Overview

This is a domain-neutral Express API foundation, currently implementing a health-check endpoint rather than business workflows. A request reaches the versioned router, is dispatched to the health handler, and returns a status and timestamp; unmatched requests and errors pass through app-level middleware. The starter also exposes Swagger documentation and includes a Prisma/PostgreSQL foundation plus an Nginx deployment proxy. Database use by an application feature is not shown, so the graph does not connect persistence to the health workflow.

Main entry points: [`src/app.ts`](https://github.com/socheatathai/express-api/blob/main/src/app.ts) (Express app), [`src/routes/v1/index.ts`](https://github.com/socheatathai/express-api/blob/main/src/routes/v1/index.ts) (API v1 router), [`src/routes/v1/health.routes.ts`](https://github.com/socheatathai/express-api/blob/main/src/routes/v1/health.routes.ts) (Health route), [`src/server.ts`](https://github.com/socheatathai/express-api/blob/main/src/server.ts) (Server startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Server startup<br/>[server.ts]"]
  node_app["Express app<br/>[app.ts]"]
  node_router["API v1 router<br/>[index.ts]"]
  node_health_routes["Health route<br/>[health.routes.ts]"]
  node_health_controller["Health handler"]
  node_not_found["Not-found middleware<br/>[not-found.ts]"]
  node_error_handler["Error handler<br/>[error-handler.ts]"]
  node_openapi["Swagger documentation<br/>[openapi.ts]"]
end

subgraph group_data["Data Foundation"]
  node_prisma_client["Prisma client<br/>[prisma.ts]"]
  node_schema["Database schema<br/>[schema.prisma]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_deployment["Deployment"]
  node_nginx["Nginx proxy<br/>[default.conf]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_server -->|"starts"| node_app
node_app -->|"mounts"| node_router
node_router -->|"mounts"| node_health_routes
node_health_routes -->|"dispatches"| node_health_controller
node_app -->|"installs"| node_not_found
node_app -->|"installs"| node_error_handler
node_app -->|"serves docs"| node_openapi
node_prisma_client -->|"connects to"| node_postgres
node_nginx -->|"forwards traffic"| node_app

click node_server "https://github.com/socheatathai/express-api/blob/main/src/server.ts"
click node_app "https://github.com/socheatathai/express-api/blob/main/src/app.ts"
click node_router "https://github.com/socheatathai/express-api/blob/main/src/routes/v1/index.ts"
click node_health_routes "https://github.com/socheatathai/express-api/blob/main/src/routes/v1/health.routes.ts"
click node_health_controller "https://github.com/socheatathai/express-api/blob/main/src/controllers/health.controller.ts"
click node_not_found "https://github.com/socheatathai/express-api/blob/main/src/middleware/not-found.ts"
click node_error_handler "https://github.com/socheatathai/express-api/blob/main/src/middleware/error-handler.ts"
click node_openapi "https://github.com/socheatathai/express-api/blob/main/src/docs/openapi.ts"
click node_prisma_client "https://github.com/socheatathai/express-api/blob/main/src/lib/prisma.ts"
click node_schema "https://github.com/socheatathai/express-api/blob/main/prisma/schema.prisma"
click node_nginx "https://github.com/socheatathai/express-api/blob/main/nginx/default.conf"

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_app,node_router,node_health_routes,node_health_controller,node_not_found,node_error_handler,node_openapi,node_client toneBlue
class node_prisma_client,node_schema,node_postgres toneAmber
class node_nginx toneMint
```

## Components

### HTTP API

- [Server startup](https://github.com/socheatathai/express-api/blob/main/src/server.ts): `src/server.ts`
- [Express app](https://github.com/socheatathai/express-api/blob/main/src/app.ts): `src/app.ts`
- [API v1 router](https://github.com/socheatathai/express-api/blob/main/src/routes/v1/index.ts): `src/routes/v1/index.ts`
- [Health route](https://github.com/socheatathai/express-api/blob/main/src/routes/v1/health.routes.ts): `src/routes/v1/health.routes.ts`
- [Health handler](https://github.com/socheatathai/express-api/blob/main/src/controllers/health.controller.ts): `src/controllers/health.controller.ts`
- [Not-found middleware](https://github.com/socheatathai/express-api/blob/main/src/middleware/not-found.ts): `src/middleware/not-found.ts`
- [Error handler](https://github.com/socheatathai/express-api/blob/main/src/middleware/error-handler.ts): `src/middleware/error-handler.ts`
- [Swagger documentation](https://github.com/socheatathai/express-api/blob/main/src/docs/openapi.ts): `src/docs/openapi.ts`

### Data Foundation

- [Prisma client](https://github.com/socheatathai/express-api/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`
- [Database schema](https://github.com/socheatathai/express-api/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- **PostgreSQL**

### Deployment

- [Nginx proxy](https://github.com/socheatathai/express-api/blob/main/nginx/default.conf): `nginx/default.conf`

### Other components

- **API client**

## Connections

- API client → Express app: sends requests (evidence: `README.md`)
- Server startup → Express app: starts (evidence: `src/server.ts`)
- Express app → API v1 router: mounts (evidence: `src/app.ts`)
- API v1 router → Health route: mounts (evidence: `src/routes/v1/index.ts`)
- Health route → Health handler: dispatches (evidence: `src/routes/v1/health.routes.ts`)
- Express app → Not-found middleware: installs (evidence: `src/app.ts`)
- Express app → Error handler: installs (evidence: `src/app.ts`)
- Express app → Swagger documentation: serves docs (evidence: `src/app.ts`)
- Prisma client → PostgreSQL: connects to (evidence: `src/lib/prisma.ts`)
- Nginx proxy → Express app: forwards traffic (evidence: `README.md`)
