# simpledotorg/h360tk_grafana_core architecture

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

- Interactive diagram: https://gitdiagram.com/simpledotorg/h360tk_grafana_core
- Repository: https://github.com/simpledotorg/h360tk_grafana_core

## Overview

HEARTS360 Toolkit is a Docker-hosted health-data monitoring system. Its main workflow is facility staff uploading patient line lists, which a file watcher and Python ingester normalize into PostgreSQL; Grafana then presents facility and district dashboards and overdue-patient lists. A separate reporting exchange exports reporting data and imports versioned archives. The README documents hourly and admin-triggered dashboard refreshes, but the sampled source does not show their implementation, so those links are marked unverified. The refresh and dashboard capabilities are represented by the provisioned Grafana dashboards.

Main entry points: [`pg_init_scripts/01_heart360_tables.sql`](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/pg_init_scripts/01_heart360_tables.sql) (PostgreSQL), [`exporter_scripts/exporter.py`](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/exporter_scripts/exporter.py) (Scheduled exporter), [`importer_scripts/importer.py`](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/importer.py) (Scheduled importer), [`importer_scripts/import_versions/base.py`](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/import_versions/base.py) (Import operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Upload and ingestion"]
  node_filebrowser["File upload<br/>[docker-compose.yml]"]
  node_uploadstore["Uploaded files<br/>[docker-compose.yml]"]
  node_watcher["File watcher<br/>[fileproc.sh]"]
  node_ingester["Line-list ingestion"]
end

subgraph group_data["Database and dashboards"]
  node_postgres[("PostgreSQL")]
  node_schema_init["Schema initialization<br/>[00_schemas.sql]"]
  node_grafana["Grafana dashboards"]
  node_refreshdash["Refresh dashboard"]
end

subgraph group_exchange["Reporting exchange"]
  node_exporter["Scheduled exporter<br/>[exporter.py]"]
  node_sftp["SFTP exchange"]
  node_s3["S3 destination"]
  node_importer["Scheduled importer<br/>[importer.py]"]
  node_version_registry["Version registry<br/>[__init__.py]"]
  node_import_v1["Version 1 import<br/>[v1.py]"]
  node_import_base["Import operations<br/>[base.py]"]
end

subgraph group_prep["Data preparation"]
  node_source_data["Prepared CSV data<br/>[prepare_date.py]"]
end

node_staff(("Facility staff"))
node_analyst(("Data staff"))

node_staff -->|"uploads file"| node_filebrowser
node_filebrowser -->|"stores file"| node_uploadstore
node_uploadstore -->|"detects file"| node_watcher
node_watcher -->|"runs ingestion"| node_ingester
node_ingester -->|"inserts records"| node_postgres
node_postgres -->|"supplies dashboard data"| node_grafana
node_analyst -.->|"requests refresh"| node_refreshdash
node_refreshdash -.->|"refreshes precomputed data"| node_postgres
node_exporter -->|"queries reporting data"| node_postgres
node_exporter -->|"uploads archives"| node_sftp
node_exporter -.->|"uploads archives"| node_s3
node_importer -->|"downloads archives"| node_sftp
node_importer -->|"selects importer"| node_version_registry
node_version_registry -->|"registers version"| node_import_v1
node_import_v1 -->|"uses base operations"| node_import_base
node_importer -->|"truncates tables"| node_import_base
node_import_base -->|"loads reporting tables"| node_postgres
node_source_data -->|"writes CSV outputs"| node_analyst

click node_filebrowser "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/docker-compose.yml"
click node_uploadstore "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/docker-compose.yml"
click node_watcher "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/inotify_scripts/fileproc.sh"
click node_ingester "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/inotify_scripts/ingest_file_h360tk.py"
click node_postgres "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/pg_init_scripts/01_heart360_tables.sql"
click node_schema_init "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/pg_init_scripts/00_schemas.sql"
click node_grafana "https://github.com/simpledotorg/h360tk_grafana_core/tree/0.5.1/grafana_provisioning/dashboards/HEARTS360%20Dashboards"
click node_refreshdash "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/grafana_provisioning/dashboards_admin/heart360.data.refresh.json"
click node_exporter "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/exporter_scripts/exporter.py"
click node_importer "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/importer.py"
click node_version_registry "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/import_versions/__init__.py"
click node_import_v1 "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/import_versions/v1.py"
click node_import_base "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/import_versions/base.py"
click node_source_data "https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/prepare_date.py"

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_filebrowser,node_uploadstore,node_watcher,node_ingester toneBlue
class node_postgres,node_schema_init,node_grafana,node_refreshdash toneAmber
class node_exporter,node_sftp,node_s3,node_importer,node_version_registry,node_import_v1,node_import_base toneMint
class node_source_data toneRose
class node_staff,node_analyst toneIndigo
```

## Components

### Upload and ingestion

- [File upload](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/docker-compose.yml): `docker-compose.yml`
- [Uploaded files](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/docker-compose.yml): `docker-compose.yml`
- [File watcher](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/inotify_scripts/fileproc.sh): `inotify_scripts/fileproc.sh`
- [Line-list ingestion](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/inotify_scripts/ingest_file_h360tk.py): `inotify_scripts/ingest_file_h360tk.py`

### Database and dashboards

- [PostgreSQL](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/pg_init_scripts/01_heart360_tables.sql): `pg_init_scripts/01_heart360_tables.sql`
- [Schema initialization](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/pg_init_scripts/00_schemas.sql): `pg_init_scripts/00_schemas.sql`
- [Grafana dashboards](https://github.com/simpledotorg/h360tk_grafana_core/tree/0.5.1/grafana_provisioning/dashboards/HEARTS360%20Dashboards): `grafana_provisioning/dashboards/HEARTS360 Dashboards`
- [Refresh dashboard](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/grafana_provisioning/dashboards_admin/heart360.data.refresh.json): `grafana_provisioning/dashboards_admin/heart360.data.refresh.json`

### Reporting exchange

- [Scheduled exporter](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/exporter_scripts/exporter.py): `exporter_scripts/exporter.py`
- **SFTP exchange**
- **S3 destination**
- [Scheduled importer](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/importer.py): `importer_scripts/importer.py`
- [Version registry](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/import_versions/__init__.py): `importer_scripts/import_versions/__init__.py`
- [Version 1 import](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/import_versions/v1.py): `importer_scripts/import_versions/v1.py`
- [Import operations](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/importer_scripts/import_versions/base.py): `importer_scripts/import_versions/base.py`

### Data preparation

- [Prepared CSV data](https://github.com/simpledotorg/h360tk_grafana_core/blob/0.5.1/prepare_date.py): `prepare_date.py`

### Other components

- **Facility staff**
- **Data staff**

## Connections

- Facility staff → File upload: uploads file (evidence: `README.md`)
- File upload → Uploaded files: stores file (evidence: `README.md`)
- Uploaded files → File watcher: detects file (evidence: `README.md`)
- File watcher → Line-list ingestion: runs ingestion (evidence: `README.md`)
- Line-list ingestion → PostgreSQL: inserts records (evidence: `README.md`)
- PostgreSQL → Grafana dashboards: supplies dashboard data (evidence: `README.md`)
- Data staff → Refresh dashboard: requests refresh (evidence: `README.md`)
- Refresh dashboard → PostgreSQL: refreshes precomputed data (evidence: `README.md`)
- Scheduled exporter → PostgreSQL: queries reporting data (evidence: `exporter_scripts/exporter.py`)
- Scheduled exporter → SFTP exchange: uploads archives (evidence: `exporter_scripts/exporter.py`)
- Scheduled exporter → S3 destination: uploads archives (evidence: `exporter_scripts/exporter.py`)
- Scheduled importer → SFTP exchange: downloads archives (evidence: `importer_scripts/importer.py`)
- Scheduled importer → Version registry: selects importer (evidence: `importer_scripts/importer.py`)
- Version registry → Version 1 import: registers version (evidence: `importer_scripts/import_versions/__init__.py`)
- Version 1 import → Import operations: uses base operations (evidence: `importer_scripts/import_versions/v1.py`)
- Scheduled importer → Import operations: truncates tables (evidence: `importer_scripts/importer.py`)
- Import operations → PostgreSQL: loads reporting tables
- Prepared CSV data → Data staff: writes CSV outputs (evidence: `prepare_date.py`)
