# megakranuk/cybersecurity_incidents_tracker architecture

> Architecture diagram of the GitHub repository megakranuk/cybersecurity_incidents_tracker, 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/megakranuk/cybersecurity_incidents_tracker
- Repository: https://github.com/megakranuk/cybersecurity_incidents_tracker

## Overview

Cybersecurity Incident Tracker is a web application for registering, managing, and analyzing cybersecurity incidents. A user works through the browser UI, whose state layer loads and filters incident lists, submits changes, and requests statistics through the API client; the backend authenticates and routes requests through controllers and services to SQLite-backed repositories. Separate flows support account registration and login. The README documents the frontend/backend layers and REST/SQLite design; sampled source confirms key wiring and analytics, while some frontend features and database initialization details are represented only where documented or indexed.

Main entry points: [`backend/src/app.ts`](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/app.ts) (Express application), [`frontend/src/main.ts`](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/main.ts) (UI state), [`backend/src/routes/incidents.routes.ts`](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/routes/incidents.routes.ts) (Incident routes), [`backend/src/services/incidents.service.ts`](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/services/incidents.service.ts) (Incident service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser application"]
  node_frontend_state["UI state<br/>[main.ts]"]
  node_frontend_ui["Interface rendering<br/>[ui.ts]"]
  node_frontend_api["API client<br/>[apiClient.ts]"]
  node_frontend_cache["List cache<br/>[cache.ts]"]
  node_frontend_dtos["Client DTOs<br/>[dtos.ts]"]
end

subgraph group_backend["REST backend"]
  node_server["Express application<br/>[app.ts]"]
  node_auth_routes["Auth routes<br/>[auth.routes.ts]"]
  node_incident_routes["Incident routes"]
  node_jwt_middleware["JWT authentication"]
  node_request_middleware["Request middleware"]
  node_error_middleware["Error handling"]
  node_auth_controller["Auth controller<br/>[auth.controller.ts]"]
  node_incident_controller["Incident controller"]
  node_config["Runtime configuration<br/>[config.ts]"]
end

subgraph group_domain["Incident domain"]
  node_auth_service["Auth service<br/>[auth.service.ts]"]
  node_incident_service["Incident service"]
  node_incident_dtos["Incident DTOs<br/>[incidents.dto.ts]"]
end

subgraph group_persistence["Persistence"]
  node_incident_repository["Incident repository"]
  node_db_client["SQLite query client<br/>[dbClient.ts]"]
  node_database[("SQLite database<br/>[app.db]")]
  node_db_setup["Database setup<br/>[migrate.ts]"]
end

node_user(("User"))
node_api_service{{"Incident API"}}

node_user -->|"uses"| node_frontend_state
node_frontend_state -->|"requests data"| node_frontend_api
node_frontend_state -->|"renders results"| node_frontend_ui
node_frontend_state -->|"caches lists"| node_frontend_cache
node_frontend_state -->|"maps data"| node_frontend_dtos
node_frontend_ui -->|"uses view models"| node_frontend_dtos
node_frontend_api -->|"types responses"| node_frontend_dtos
node_frontend_api -->|"calls endpoints"| node_api_service
node_api_service -->|"serves REST"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_incident_routes
node_server -->|"protects incidents"| node_jwt_middleware
node_server -->|"registers middleware"| node_request_middleware
node_server -->|"registers handler"| node_error_middleware
node_server -->|"runs migrations"| node_db_setup
node_auth_routes -->|"dispatches handlers"| node_auth_controller
node_auth_routes -->|"guards users"| node_jwt_middleware
node_incident_routes -->|"dispatches handlers"| node_incident_controller
node_incident_routes -->|"constructs service"| node_incident_service
node_incident_routes -->|"constructs repository"| node_incident_repository
node_auth_controller -->|"delegates auth"| node_auth_service
node_incident_controller -->|"delegates operations"| node_incident_service
node_incident_service -->|"queries incidents"| node_incident_repository
node_incident_service -->|"validates data"| node_incident_dtos
node_incident_repository -->|"executes queries"| node_db_client
node_auth_service -->|"reads and writes users"| node_db_client
node_db_client -.->|"accesses SQLite"| node_database
node_db_setup -->|"runs database queries"| node_db_client
node_db_setup -.->|"uses settings"| node_config

click node_frontend_state "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/main.ts"
click node_frontend_ui "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/ui.ts"
click node_frontend_api "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/apiClient.ts"
click node_frontend_cache "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/cache.ts"
click node_frontend_dtos "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/dtos.ts"
click node_server "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/app.ts"
click node_auth_routes "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/routes/auth.routes.ts"
click node_incident_routes "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/routes/incidents.routes.ts"
click node_jwt_middleware "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/middleware/jwt-auth.middleware.ts"
click node_request_middleware "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/middleware/logging.middleware.ts"
click node_error_middleware "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/middleware/error-handler.middleware.ts"
click node_auth_controller "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/controllers/auth.controller.ts"
click node_incident_controller "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/controllers/incidents.controller.ts"
click node_auth_service "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/services/auth.service.ts"
click node_incident_service "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/services/incidents.service.ts"
click node_incident_dtos "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/dtos/incidents.dto.ts"
click node_incident_repository "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/repositories/incidents.repository.ts"
click node_db_client "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/db/dbClient.ts"
click node_database "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/data/app.db"
click node_db_setup "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/db/migrate.ts"
click node_config "https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/config.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_frontend_state,node_frontend_ui,node_frontend_api,node_frontend_cache,node_frontend_dtos,node_user toneBlue
class node_server,node_auth_routes,node_incident_routes,node_jwt_middleware,node_request_middleware,node_error_middleware,node_auth_controller,node_incident_controller,node_config toneAmber
class node_auth_service,node_incident_service,node_incident_dtos,node_api_service toneMint
class node_incident_repository,node_db_client,node_database,node_db_setup toneRose
```

## Components

### Browser application

- [UI state](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/main.ts): `frontend/src/main.ts`
- [Interface rendering](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/ui.ts): `frontend/src/ui.ts`
- [API client](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/apiClient.ts): `frontend/src/apiClient.ts`
- [List cache](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/cache.ts): `frontend/src/cache.ts`
- [Client DTOs](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/frontend/src/dtos.ts): `frontend/src/dtos.ts`

### REST backend

- [Express application](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/app.ts): `backend/src/app.ts`
- [Auth routes](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/routes/auth.routes.ts): `backend/src/routes/auth.routes.ts`
- [Incident routes](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/routes/incidents.routes.ts): `backend/src/routes/incidents.routes.ts`
- [JWT authentication](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/middleware/jwt-auth.middleware.ts): `backend/src/middleware/jwt-auth.middleware.ts`
- [Request middleware](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/middleware/logging.middleware.ts): `backend/src/middleware/logging.middleware.ts`
- [Error handling](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/middleware/error-handler.middleware.ts): `backend/src/middleware/error-handler.middleware.ts`
- [Auth controller](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/controllers/auth.controller.ts): `backend/src/controllers/auth.controller.ts`
- [Incident controller](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/controllers/incidents.controller.ts): `backend/src/controllers/incidents.controller.ts`
- [Runtime configuration](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/config.ts): `backend/src/config.ts`

### Incident domain

- [Auth service](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/services/auth.service.ts): `backend/src/services/auth.service.ts`
- [Incident service](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/services/incidents.service.ts): `backend/src/services/incidents.service.ts`
- [Incident DTOs](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/dtos/incidents.dto.ts): `backend/src/dtos/incidents.dto.ts`

### Persistence

- [Incident repository](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/repositories/incidents.repository.ts): `backend/src/repositories/incidents.repository.ts`
- [SQLite query client](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/db/dbClient.ts): `backend/src/db/dbClient.ts`
- [SQLite database](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/data/app.db): `backend/data/app.db`
- [Database setup](https://github.com/megakranuk/cybersecurity_incidents_tracker/blob/master/backend/src/db/migrate.ts): `backend/src/db/migrate.ts`

### Other components

- **User**
- **Incident API**

## Connections

- User → UI state: uses (evidence: `README.md`)
- UI state → API client: requests data (evidence: `frontend/src/main.ts`)
- UI state → Interface rendering: renders results (evidence: `frontend/src/main.ts`)
- UI state → List cache: caches lists (evidence: `frontend/src/main.ts`)
- UI state → Client DTOs: maps data (evidence: `frontend/src/main.ts`)
- Interface rendering → Client DTOs: uses view models (evidence: `frontend/src/ui.ts`)
- API client → Client DTOs: types responses (evidence: `frontend/src/apiClient.ts`)
- API client → Incident API: calls endpoints (evidence: `frontend/src/apiClient.ts`)
- Incident API → Express application: serves REST (evidence: `README.md`)
- Express application → Auth routes: mounts routes (evidence: `backend/src/app.ts`)
- Express application → Incident routes: mounts routes (evidence: `backend/src/app.ts`)
- Express application → JWT authentication: protects incidents (evidence: `backend/src/app.ts`)
- Express application → Request middleware: registers middleware (evidence: `backend/src/app.ts`)
- Express application → Error handling: registers handler (evidence: `backend/src/app.ts`)
- Express application → Database setup: runs migrations (evidence: `backend/src/app.ts`)
- Auth routes → Auth controller: dispatches handlers (evidence: `backend/src/routes/auth.routes.ts`)
- Auth routes → JWT authentication: guards users (evidence: `backend/src/routes/auth.routes.ts`)
- Incident routes → Incident controller: dispatches handlers (evidence: `backend/src/routes/incidents.routes.ts`)
- Incident routes → Incident service: constructs service (evidence: `backend/src/routes/incidents.routes.ts`)
- Incident routes → Incident repository: constructs repository (evidence: `backend/src/routes/incidents.routes.ts`)
- Auth controller → Auth service: delegates auth (evidence: `backend/src/controllers/auth.controller.ts`)
- Incident controller → Incident service: delegates operations (evidence: `backend/src/controllers/incidents.controller.ts`)
- Incident service → Incident repository: queries incidents (evidence: `backend/src/services/incidents.service.ts`)
- Incident service → Incident DTOs: validates data (evidence: `backend/src/services/incidents.service.ts`)
- Incident repository → SQLite query client: executes queries (evidence: `backend/src/repositories/incidents.repository.ts`)
- Auth service → SQLite query client: reads and writes users (evidence: `backend/src/services/auth.service.ts`)
- SQLite query client → SQLite database: accesses SQLite
- Database setup → SQLite query client: runs database queries (evidence: `backend/src/db/migrate.ts`)
- Database setup → Runtime configuration: uses settings
