# pradhumnaadhikari/incidenthub-backend architecture

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

- Interactive diagram: https://gitdiagram.com/pradhumnaadhikari/incidenthub-backend
- Repository: https://github.com/pradhumnaadhikari/incidenthub-backend

## Overview

IncidentHub Backend is a small Express API for checking service health and creating, listing, retrieving, updating, and deleting incidents. The principal workflow is an HTTP request routed through the incident routes to a controller, which queries PostgreSQL and returns JSON. The database pool is configured from environment variables. The tree includes a SQL schema, but the available excerpts do not show its contents or how it is applied, so no schema-to-database relationship is asserted.

Main entry points: [`src/server.js`](https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/server.js) (Express server), [`src/routes/incidents.js`](https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/routes/incidents.js) (Incident routes), [`src/controllers/incidentsController.js`](https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/controllers/incidentsController.js) (Incident controller), [`src/db.js`](https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/db.js) (PostgreSQL pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_server["Express server<br/>[server.js]"]
  node_incident_routes["Incident routes<br/>[incidents.js]"]
end

subgraph group_incident["Incident handling"]
  node_incident_controller["Incident controller"]
end

subgraph group_persistence["Persistence"]
  node_db_pool["PostgreSQL pool<br/>[db.js]"]
  node_postgres[("PostgreSQL")]
  node_incident_schema["Incident schema<br/>[schema.sql]"]
end

node_client(("API client"))

node_client -->|"sends HTTP"| node_server
node_server -->|"mounts routes"| node_incident_routes
node_incident_routes -->|"dispatches requests"| node_incident_controller
node_incident_controller -->|"queries"| node_db_pool
node_db_pool -->|"connects via pool"| node_postgres

click node_server "https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/server.js"
click node_incident_routes "https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/routes/incidents.js"
click node_incident_controller "https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/controllers/incidentsController.js"
click node_db_pool "https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/db.js"
click node_incident_schema "https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/database/schema.sql"

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_incident_routes,node_client toneBlue
class node_incident_controller toneAmber
class node_db_pool,node_postgres,node_incident_schema toneMint
```

## Components

### HTTP API

- [Express server](https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/server.js): `src/server.js`
- [Incident routes](https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/routes/incidents.js): `src/routes/incidents.js`

### Incident handling

- [Incident controller](https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/controllers/incidentsController.js): `src/controllers/incidentsController.js`

### Persistence

- [PostgreSQL pool](https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/src/db.js): `src/db.js`
- **PostgreSQL**
- [Incident schema](https://github.com/pradhumnaadhikari/incidenthub-backend/blob/main/database/schema.sql): `database/schema.sql`

### Other components

- **API client**

## Connections

- API client → Express server: sends HTTP (evidence: `src/server.js`)
- Express server → Incident routes: mounts routes (evidence: `src/server.js`)
- Incident routes → Incident controller: dispatches requests (evidence: `src/routes/incidents.js`)
- Incident controller → PostgreSQL pool: queries (evidence: `src/controllers/incidentsController.js`)
- PostgreSQL pool → PostgreSQL: connects via pool (evidence: `src/db.js`)
