# akene-uzezi/incident-tracker-backend architecture

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

- Interactive diagram: https://gitdiagram.com/akene-uzezi/incident-tracker-backend
- Repository: https://github.com/akene-uzezi/incident-tracker-backend

## Overview

Incident Tracker is a Go/Gin REST API used by two shared-session frontends. Clients enter through versioned routes, where authentication middleware protects selected operations; handlers validate and apply role/department rules, then invoke domain-specific PostgreSQL models. The principal workflows cover incident reporting and follow-up, death reporting with role-targeted notifications, and user authentication/administration. The tree and README identify additional API capabilities, but most handler-to-model wiring is not sampled, so those connections are limited to documented relationships.

Main entry points: [`cmd/routes.go`](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/routes.go) (API routes), [`cmd/deathreport.go`](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/deathreport.go) (Death report handlers), [`internal/db/users.go`](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/users.go) (User model), [`internal/db/notifications.go`](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/notifications.go) (Notification model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API runtime"]
  node_server["HTTP server<br/>[server.go]"]
  node_routes["API routes<br/>[routes.go]"]
  node_middleware["Auth middleware<br/>[middleware.go]"]
end

subgraph group_identity["Identity and access"]
  node_authhandlers["Auth handlers<br/>[auth.go]"]
  node_userhandlers["User handlers<br/>[users.go]"]
  node_userstore["User model<br/>[users.go]"]
end

subgraph group_incident["Incident workflows"]
  node_incidenthandlers["Incident handlers<br/>[incidents.go]"]
  node_commenthandlers["Comment handlers<br/>[comments.go]"]
  node_managementhandlers["Management handlers"]
  node_incidentstore["Incident model<br/>[incidents.go]"]
  node_commentstore["Comment model<br/>[comments.go]"]
  node_managementstore["Management model"]
end

subgraph group_safety["Death reports and alerts"]
  node_deathhandlers["Death report handlers<br/>[deathreport.go]"]
  node_deathstore["Death report model<br/>[deathreporting.go]"]
  node_notificationhandlers["Notification handlers<br/>[notifications.go]"]
  node_notificationstore["Notification model<br/>[notifications.go]"]
end

node_frontends(("Next.js frontends"))
node_postgres[("PostgreSQL")]

node_frontends -->|"send requests"| node_server
node_server -->|"uses handler"| node_routes
node_routes -->|"guards routes"| node_middleware
node_routes -->|"dispatches auth"| node_authhandlers
node_routes -->|"dispatches users"| node_userhandlers
node_routes -->|"dispatches incidents"| node_incidenthandlers
node_routes -->|"dispatches comments"| node_commenthandlers
node_routes -->|"dispatches management"| node_managementhandlers
node_routes -->|"dispatches reports"| node_deathhandlers
node_routes -->|"dispatches alerts"| node_notificationhandlers
node_authhandlers -->|"reads and writes"| node_userstore
node_userhandlers -->|"reads and writes"| node_userstore
node_incidenthandlers -->|"reads and writes"| node_incidentstore
node_commenthandlers -->|"reads and writes"| node_commentstore
node_managementhandlers -->|"reads and writes"| node_managementstore
node_deathhandlers -->|"reads and writes"| node_deathstore
node_deathhandlers -->|"creates alerts"| node_notificationstore
node_notificationhandlers -->|"reads and updates"| node_notificationstore
node_userstore -->|"queries"| node_postgres
node_incidentstore -->|"queries"| node_postgres
node_commentstore -->|"queries"| node_postgres
node_managementstore -->|"queries"| node_postgres
node_deathstore -->|"queries"| node_postgres
node_notificationstore -->|"queries"| node_postgres

click node_server "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/server.go"
click node_routes "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/routes.go"
click node_middleware "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/middleware.go"
click node_authhandlers "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/auth.go"
click node_userhandlers "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/users.go"
click node_userstore "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/users.go"
click node_incidenthandlers "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/incidents.go"
click node_commenthandlers "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/comments.go"
click node_managementhandlers "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/incidentmanagement.go"
click node_incidentstore "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/incidents.go"
click node_commentstore "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/comments.go"
click node_managementstore "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/incidentmanagement.go"
click node_deathhandlers "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/deathreport.go"
click node_deathstore "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/deathreporting.go"
click node_notificationhandlers "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/notifications.go"
click node_notificationstore "https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/notifications.go"

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_routes,node_middleware,node_frontends toneBlue
class node_authhandlers,node_userhandlers,node_userstore,node_postgres toneAmber
class node_incidenthandlers,node_commenthandlers,node_managementhandlers,node_incidentstore,node_commentstore,node_managementstore toneMint
class node_deathhandlers,node_deathstore,node_notificationhandlers,node_notificationstore toneRose
```

## Components

### API runtime

- [HTTP server](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/server.go): `cmd/server.go`
- [API routes](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/routes.go): `cmd/routes.go`
- [Auth middleware](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/middleware.go): `cmd/middleware.go`

### Identity and access

- [Auth handlers](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/auth.go): `cmd/auth.go`
- [User handlers](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/users.go): `cmd/users.go`
- [User model](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/users.go): `internal/db/users.go`

### Incident workflows

- [Incident handlers](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/incidents.go): `cmd/incidents.go`
- [Comment handlers](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/comments.go): `cmd/comments.go`
- [Management handlers](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/incidentmanagement.go): `cmd/incidentmanagement.go`
- [Incident model](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/incidents.go): `internal/db/incidents.go`
- [Comment model](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/comments.go): `internal/db/comments.go`
- [Management model](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/incidentmanagement.go): `internal/db/incidentmanagement.go`

### Death reports and alerts

- [Death report handlers](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/deathreport.go): `cmd/deathreport.go`
- [Death report model](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/deathreporting.go): `internal/db/deathreporting.go`
- [Notification handlers](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/cmd/notifications.go): `cmd/notifications.go`
- [Notification model](https://github.com/akene-uzezi/incident-tracker-backend/blob/main/internal/db/notifications.go): `internal/db/notifications.go`

### Other components

- **Next.js frontends**
- **PostgreSQL**

## Connections

- Next.js frontends → HTTP server: send requests
- HTTP server → API routes: uses handler
- API routes → Auth middleware: guards routes
- API routes → Auth handlers: dispatches auth
- API routes → User handlers: dispatches users
- API routes → Incident handlers: dispatches incidents
- API routes → Comment handlers: dispatches comments
- API routes → Management handlers: dispatches management
- API routes → Death report handlers: dispatches reports
- API routes → Notification handlers: dispatches alerts
- Auth handlers → User model: reads and writes
- User handlers → User model: reads and writes
- Incident handlers → Incident model: reads and writes
- Comment handlers → Comment model: reads and writes
- Management handlers → Management model: reads and writes
- Death report handlers → Death report model: reads and writes
- Death report handlers → Notification model: creates alerts
- Notification handlers → Notification model: reads and updates
- User model → PostgreSQL: queries
- Incident model → PostgreSQL: queries
- Comment model → PostgreSQL: queries
- Management model → PostgreSQL: queries
- Death report model → PostgreSQL: queries
- Notification model → PostgreSQL: queries
