# local-heroes-fontys/backend architecture

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

- Interactive diagram: https://gitdiagram.com/local-heroes-fontys/backend
- Repository: https://github.com/local-heroes-fontys/backend

## Overview

Local Heroes Backend is an Express REST API whose implemented product surface is currently a database-aware health check. Requests enter the server, pass through app middleware and API routing, then the health controller asks a service to query MySQL and returns status. Startup configuration, connection pooling, and centralized 404/error handling support that flow. The README describes future feature layers such as repositories, validators, and migrations, but the tree shows no implemented feature modules beyond health; those are not represented as runtime components.

Main entry points: [`src/app.ts`](https://github.com/local-heroes-fontys/backend/blob/main/src/app.ts) (Express app), [`src/server.ts`](https://github.com/local-heroes-fontys/backend/blob/main/src/server.ts) (HTTP server), [`src/db/pool.ts`](https://github.com/local-heroes-fontys/backend/blob/main/src/db/pool.ts) (MySQL pool), [`src/config/env.ts`](https://github.com/local-heroes-fontys/backend/blob/main/src/config/env.ts) (Validated environment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API runtime"]
  node_server["HTTP server<br/>[server.ts]"]
  node_app["Express app<br/>[app.ts]"]
  node_api_routes["API routes<br/>[index.ts]"]
  node_not_found["Not-found handler<br/>[notFound.ts]"]
  node_error_handler["Error handler<br/>[errorHandler.ts]"]
  node_app_error["Safe app errors<br/>[AppError.ts]"]
end

subgraph group_health["Health check"]
  node_health_routes["Health route<br/>[health.routes.ts]"]
  node_health_controller["Health controller"]
  node_health_service["Database health check<br/>[health.service.ts]"]
end

subgraph group_infra["Configuration and database"]
  node_env["Validated environment<br/>[env.ts]"]
  node_pool["MySQL pool<br/>[pool.ts]"]
  node_mysql[("MySQL database")]
end

node_caller(("API caller"))

node_caller -->|"sends request"| node_server
node_server -->|"serves"| node_app
node_server -->|"reads port"| node_env
node_server -->|"closes on shutdown"| node_pool
node_app -->|"configures CORS"| node_env
node_app -->|"mounts API"| node_api_routes
node_app -->|"falls through to"| node_not_found
node_app -->|"handles errors with"| node_error_handler
node_api_routes -->|"mounts health"| node_health_routes
node_health_routes -->|"dispatches to"| node_health_controller
node_health_controller -->|"checks via"| node_health_service
node_health_service -->|"queries"| node_pool
node_pool -->|"uses credentials"| node_env
node_pool -->|"connects to"| node_mysql
node_error_handler -->|"recognizes"| node_app_error

click node_server "https://github.com/local-heroes-fontys/backend/blob/main/src/server.ts"
click node_app "https://github.com/local-heroes-fontys/backend/blob/main/src/app.ts"
click node_api_routes "https://github.com/local-heroes-fontys/backend/blob/main/src/routes/index.ts"
click node_not_found "https://github.com/local-heroes-fontys/backend/blob/main/src/middleware/notFound.ts"
click node_error_handler "https://github.com/local-heroes-fontys/backend/blob/main/src/middleware/errorHandler.ts"
click node_app_error "https://github.com/local-heroes-fontys/backend/blob/main/src/errors/AppError.ts"
click node_health_routes "https://github.com/local-heroes-fontys/backend/blob/main/src/routes/health.routes.ts"
click node_health_controller "https://github.com/local-heroes-fontys/backend/blob/main/src/controllers/health.controller.ts"
click node_health_service "https://github.com/local-heroes-fontys/backend/blob/main/src/services/health.service.ts"
click node_env "https://github.com/local-heroes-fontys/backend/blob/main/src/config/env.ts"
click node_pool "https://github.com/local-heroes-fontys/backend/blob/main/src/db/pool.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_app,node_api_routes,node_not_found,node_error_handler,node_app_error toneBlue
class node_health_routes,node_health_controller,node_health_service toneAmber
class node_env,node_pool,node_mysql,node_caller toneMint
```

## Components

### API runtime

- [HTTP server](https://github.com/local-heroes-fontys/backend/blob/main/src/server.ts): `src/server.ts`
- [Express app](https://github.com/local-heroes-fontys/backend/blob/main/src/app.ts): `src/app.ts`
- [API routes](https://github.com/local-heroes-fontys/backend/blob/main/src/routes/index.ts): `src/routes/index.ts`
- [Not-found handler](https://github.com/local-heroes-fontys/backend/blob/main/src/middleware/notFound.ts): `src/middleware/notFound.ts`
- [Error handler](https://github.com/local-heroes-fontys/backend/blob/main/src/middleware/errorHandler.ts): `src/middleware/errorHandler.ts`
- [Safe app errors](https://github.com/local-heroes-fontys/backend/blob/main/src/errors/AppError.ts): `src/errors/AppError.ts`

### Health check

- [Health route](https://github.com/local-heroes-fontys/backend/blob/main/src/routes/health.routes.ts): `src/routes/health.routes.ts`
- [Health controller](https://github.com/local-heroes-fontys/backend/blob/main/src/controllers/health.controller.ts): `src/controllers/health.controller.ts`
- [Database health check](https://github.com/local-heroes-fontys/backend/blob/main/src/services/health.service.ts): `src/services/health.service.ts`

### Configuration and database

- [Validated environment](https://github.com/local-heroes-fontys/backend/blob/main/src/config/env.ts): `src/config/env.ts`
- [MySQL pool](https://github.com/local-heroes-fontys/backend/blob/main/src/db/pool.ts): `src/db/pool.ts`
- **MySQL database**

### Other components

- **API caller**

## Connections

- API caller → HTTP server: sends request (evidence: `README.md`)
- HTTP server → Express app: serves (evidence: `src/server.ts`)
- HTTP server → Validated environment: reads port (evidence: `src/server.ts`)
- HTTP server → MySQL pool: closes on shutdown (evidence: `src/server.ts`)
- Express app → Validated environment: configures CORS (evidence: `src/app.ts`)
- Express app → API routes: mounts API (evidence: `src/app.ts`)
- Express app → Not-found handler: falls through to (evidence: `src/app.ts`)
- Express app → Error handler: handles errors with (evidence: `src/app.ts`)
- API routes → Health route: mounts health (evidence: `src/routes/index.ts`)
- Health route → Health controller: dispatches to (evidence: `src/routes/health.routes.ts`)
- Health controller → Database health check: checks via (evidence: `src/controllers/health.controller.ts`)
- Database health check → MySQL pool: queries (evidence: `src/services/health.service.ts`)
- MySQL pool → Validated environment: uses credentials (evidence: `src/db/pool.ts`)
- MySQL pool → MySQL database: connects to (evidence: `README.md`)
- Error handler → Safe app errors: recognizes (evidence: `src/middleware/errorHandler.ts`)
