# takio1981/korat-health-kpi architecture

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

- Interactive diagram: https://gitdiagram.com/takio1981/korat-health-kpi
- Repository: https://github.com/takio1981/korat-health-kpi

## Overview

KpiWeb is a KPI management and reporting application with an Angular frontend and an Express API backed by MySQL. Users authenticate, enter and manage KPI results, and view dashboards and reports; the API also supports reviews, exports, backups, and scheduled audit work. The graph preserves these major product areas, but some route and frontend-to-API connections are inferred from module names rather than shown in excerpts, so they are omitted. API route registration and several service relationships are evidenced by the source index or excerpts.

Main entry points: [`api/server.js`](https://github.com/takio1981/korat-health-kpi/blob/main/api/server.js) (API server), [`api/db.js`](https://github.com/takio1981/korat-health-kpi/blob/main/api/db.js) (Database pool), [`frontend/src/app/app.routes.ts`](https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/app.routes.ts) (Application routes), [`api/routes/indicators.js`](https://github.com/takio1981/korat-health-kpi/blob/main/api/routes/indicators.js) (Indicator routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_portal["Application routes<br/>[app.routes.ts]"]
  node_authui["Authentication UI<br/>[auth.ts]"]
  node_dashboard["KPI dashboard<br/>[dashboard.ts]"]
  node_kpimanage["KPI management<br/>[kpi-manage.ts]"]
  node_reportui["Reports and charts<br/>[report.ts]"]
end

subgraph group_api["API and access"]
  node_server["API server<br/>[server.js]"]
  node_router["API router<br/>[router.js]"]
  node_authroutes["Authentication routes<br/>[auth.js]"]
  node_indicators["Indicator routes<br/>[indicators.js]"]
  node_results["KPI result routes<br/>[kpi-results.js]"]
  node_review["Review and notifications<br/>[review.js]"]
  node_access["Access control<br/>[access.js]"]
end

subgraph group_kpi["KPI processing"]
  node_summary["KPI summaries<br/>[summary.js]"]
  node_hierarchy["KPI hierarchy<br/>[hierarchy.js]"]
  node_formula["Formula engine<br/>[kpi-formula.js]"]
end

subgraph group_operations["Operations"]
  node_export["KPI export<br/>[export.js]"]
  node_backup["Backup service<br/>[backup.js]"]
  node_jobs["Scheduled jobs"]
  node_notify["Notifications<br/>[notify.js]"]
  node_dbpool[("Database pool<br/>[db.js]")]
end

node_user(("User"))
node_database[("MySQL database")]

node_user -->|"uses"| node_portal
node_portal -->|"routes to"| node_authui
node_portal -->|"routes to"| node_dashboard
node_portal -->|"routes to"| node_kpimanage
node_portal -->|"routes to"| node_reportui
node_dashboard -->|"uses"| node_authui
node_server -->|"mounts"| node_router
node_server -->|"loads"| node_authroutes
node_server -->|"loads"| node_indicators
node_server -->|"loads"| node_results
node_server -.->|"loads"| node_review
node_authroutes -->|"registers routes"| node_router
node_indicators -->|"registers routes"| node_router
node_results -->|"registers routes"| node_router
node_review -->|"registers routes"| node_router
node_authroutes -->|"checks access"| node_access
node_results -->|"checks access"| node_access
node_indicators -->|"uses"| node_hierarchy
node_indicators -->|"uses"| node_summary
node_results -->|"uses"| node_summary
node_summary -->|"evaluates formulas"| node_formula
node_summary -->|"loads aggregates"| node_hierarchy
node_hierarchy -.->|"rolls up KPI"| node_formula
node_export -->|"evaluates formulas"| node_formula
node_export -->|"loads aggregates"| node_hierarchy
node_jobs -->|"runs exports"| node_export
node_jobs -->|"sends alerts"| node_notify
node_server -->|"starts jobs"| node_jobs
node_server -->|"loads service"| node_backup
node_authroutes -->|"queries"| node_dbpool
node_indicators -->|"queries"| node_dbpool
node_results -->|"queries"| node_dbpool
node_review -->|"queries"| node_dbpool
node_summary -->|"queries"| node_dbpool
node_hierarchy -->|"queries"| node_dbpool
node_export -->|"queries"| node_dbpool
node_dbpool -->|"connects"| node_database

click node_portal "https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/app.routes.ts"
click node_authui "https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/services/auth.ts"
click node_dashboard "https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/dashboard/dashboard.ts"
click node_kpimanage "https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/kpi-manage/kpi-manage.ts"
click node_reportui "https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/report/report.ts"
click node_server "https://github.com/takio1981/korat-health-kpi/blob/main/api/server.js"
click node_router "https://github.com/takio1981/korat-health-kpi/blob/main/api/core/router.js"
click node_authroutes "https://github.com/takio1981/korat-health-kpi/blob/main/api/routes/auth.js"
click node_indicators "https://github.com/takio1981/korat-health-kpi/blob/main/api/routes/indicators.js"
click node_results "https://github.com/takio1981/korat-health-kpi/blob/main/api/routes/kpi-results.js"
click node_review "https://github.com/takio1981/korat-health-kpi/blob/main/api/routes/review.js"
click node_access "https://github.com/takio1981/korat-health-kpi/blob/main/api/core/access.js"
click node_summary "https://github.com/takio1981/korat-health-kpi/blob/main/api/services/summary.js"
click node_hierarchy "https://github.com/takio1981/korat-health-kpi/blob/main/api/services/hierarchy.js"
click node_formula "https://github.com/takio1981/korat-health-kpi/blob/main/api/kpi-formula.js"
click node_export "https://github.com/takio1981/korat-health-kpi/blob/main/api/services/export.js"
click node_backup "https://github.com/takio1981/korat-health-kpi/blob/main/api/services/backup.js"
click node_jobs "https://github.com/takio1981/korat-health-kpi/blob/main/api/jobs/export-scheduler.js"
click node_notify "https://github.com/takio1981/korat-health-kpi/blob/main/api/core/notify.js"
click node_dbpool "https://github.com/takio1981/korat-health-kpi/blob/main/api/db.js"

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_portal,node_authui,node_dashboard,node_kpimanage,node_reportui,node_user toneBlue
class node_server,node_router,node_authroutes,node_indicators,node_results,node_review,node_access,node_database toneAmber
class node_summary,node_hierarchy,node_formula toneMint
class node_export,node_backup,node_jobs,node_notify,node_dbpool toneRose
```

## Components

### Web application

- [Application routes](https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/app.routes.ts): `frontend/src/app/app.routes.ts`
- [Authentication UI](https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/services/auth.ts): `frontend/src/app/services/auth.ts`
- [KPI dashboard](https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/dashboard/dashboard.ts): `frontend/src/app/dashboard/dashboard.ts`
- [KPI management](https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/kpi-manage/kpi-manage.ts): `frontend/src/app/kpi-manage/kpi-manage.ts`
- [Reports and charts](https://github.com/takio1981/korat-health-kpi/blob/main/frontend/src/app/report/report.ts): `frontend/src/app/report/report.ts`

### API and access

- [API server](https://github.com/takio1981/korat-health-kpi/blob/main/api/server.js): `api/server.js`
- [API router](https://github.com/takio1981/korat-health-kpi/blob/main/api/core/router.js): `api/core/router.js`
- [Authentication routes](https://github.com/takio1981/korat-health-kpi/blob/main/api/routes/auth.js): `api/routes/auth.js`
- [Indicator routes](https://github.com/takio1981/korat-health-kpi/blob/main/api/routes/indicators.js): `api/routes/indicators.js`
- [KPI result routes](https://github.com/takio1981/korat-health-kpi/blob/main/api/routes/kpi-results.js): `api/routes/kpi-results.js`
- [Review and notifications](https://github.com/takio1981/korat-health-kpi/blob/main/api/routes/review.js): `api/routes/review.js`
- [Access control](https://github.com/takio1981/korat-health-kpi/blob/main/api/core/access.js): `api/core/access.js`

### KPI processing

- [KPI summaries](https://github.com/takio1981/korat-health-kpi/blob/main/api/services/summary.js): `api/services/summary.js`
- [KPI hierarchy](https://github.com/takio1981/korat-health-kpi/blob/main/api/services/hierarchy.js): `api/services/hierarchy.js`
- [Formula engine](https://github.com/takio1981/korat-health-kpi/blob/main/api/kpi-formula.js): `api/kpi-formula.js`

### Operations

- [KPI export](https://github.com/takio1981/korat-health-kpi/blob/main/api/services/export.js): `api/services/export.js`
- [Backup service](https://github.com/takio1981/korat-health-kpi/blob/main/api/services/backup.js): `api/services/backup.js`
- [Scheduled jobs](https://github.com/takio1981/korat-health-kpi/blob/main/api/jobs/export-scheduler.js): `api/jobs/export-scheduler.js`
- [Notifications](https://github.com/takio1981/korat-health-kpi/blob/main/api/core/notify.js): `api/core/notify.js`
- [Database pool](https://github.com/takio1981/korat-health-kpi/blob/main/api/db.js): `api/db.js`

### Other components

- **User**
- **MySQL database**

## Connections

- User → Application routes: uses (evidence: `frontend/src/app/app.routes.ts`)
- Application routes → Authentication UI: routes to (evidence: `frontend/src/app/app.routes.ts`)
- Application routes → KPI dashboard: routes to (evidence: `frontend/src/app/app.routes.ts`)
- Application routes → KPI management: routes to (evidence: `frontend/src/app/app.routes.ts`)
- Application routes → Reports and charts: routes to (evidence: `frontend/src/app/app.routes.ts`)
- KPI dashboard → Authentication UI: uses (evidence: `frontend/src/app/dashboard/dashboard.ts`)
- API server → API router: mounts (evidence: `api/core/router.js`)
- API server → Authentication routes: loads (evidence: `api/server.js`)
- API server → Indicator routes: loads (evidence: `api/server.js`)
- API server → KPI result routes: loads (evidence: `api/server.js`)
- API server → Review and notifications: loads (evidence: `api/server.js`)
- Authentication routes → API router: registers routes (evidence: `api/routes/auth.js`)
- Indicator routes → API router: registers routes (evidence: `api/routes/indicators.js`)
- KPI result routes → API router: registers routes (evidence: `api/routes/kpi-results.js`)
- Review and notifications → API router: registers routes (evidence: `api/routes/review.js`)
- Authentication routes → Access control: checks access (evidence: `api/routes/auth.js`)
- KPI result routes → Access control: checks access (evidence: `api/routes/kpi-results.js`)
- Indicator routes → KPI hierarchy: uses (evidence: `api/routes/indicators.js`)
- Indicator routes → KPI summaries: uses (evidence: `api/routes/indicators.js`)
- KPI result routes → KPI summaries: uses (evidence: `api/routes/kpi-results.js`)
- KPI summaries → Formula engine: evaluates formulas (evidence: `api/services/summary.js`)
- KPI summaries → KPI hierarchy: loads aggregates (evidence: `api/services/summary.js`)
- KPI hierarchy → Formula engine: rolls up KPI
- KPI export → Formula engine: evaluates formulas (evidence: `api/services/export.js`)
- KPI export → KPI hierarchy: loads aggregates (evidence: `api/services/export.js`)
- Scheduled jobs → KPI export: runs exports (evidence: `api/jobs/export-scheduler.js`)
- Scheduled jobs → Notifications: sends alerts (evidence: `api/jobs/export-scheduler.js`)
- API server → Scheduled jobs: starts jobs (evidence: `api/server.js`)
- API server → Backup service: loads service (evidence: `api/server.js`)
- Authentication routes → Database pool: queries (evidence: `api/routes/auth.js`)
- Indicator routes → Database pool: queries (evidence: `api/routes/indicators.js`)
- KPI result routes → Database pool: queries (evidence: `api/routes/kpi-results.js`)
- Review and notifications → Database pool: queries (evidence: `api/routes/review.js`)
- KPI summaries → Database pool: queries (evidence: `api/services/summary.js`)
- KPI hierarchy → Database pool: queries (evidence: `api/services/hierarchy.js`)
- KPI export → Database pool: queries (evidence: `api/services/export.js`)
- Database pool → MySQL database: connects (evidence: `api/db.js`)
