# margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs architecture

> Architecture diagram of the GitHub repository margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs, 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/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs
- Repository: https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs

## Overview

This repository supports an ELT pipeline for analyzing competition in Estonia’s dynamic purchasing systems (DHS): public procurement data is collected and loaded, transformed into analytical models, and presented in dashboards. The graph follows relationships documented in the README; no source excerpts were provided, so SQL-script responsibilities are inferred only from their filenames and documented pipeline stages.

Main entry points: [`scripts/vw_hanked_superset.sql`](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/vw_hanked_superset.sql) (Reporting views), [`scripts/02_star_schema_fact_dim_tables_v2.sql`](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/02_star_schema_fact_dim_tables_v2.sql) (Procurement facts), [`scripts/03_views_superset_powerbi_DHS_dhsSH.sql`](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/03_views_superset_powerbi_DHS_dhsSH.sql) (DHS hierarchy), [`scripts/01_star_schema_dim_tables.sql`](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/01_star_schema_dim_tables.sql) (Star dimensions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion"]
  node_n8n["n8n ingestion"]
  node_cpv["CPV classification<br/>[cpv.csv]"]
end

subgraph group_warehouse["Data warehouse"]
  node_staging[("Staging tables")]
  node_dimensions[("Star dimensions")]
  node_fact[("Procurement facts")]
  node_dhs_hierarchy[("DHS hierarchy")]
  node_reporting_views[("Reporting views")]
  node_refresh["View refresh"]
end

subgraph group_analytics["Analytics"]
  node_quality["Data quality checks"]
  node_superset["Superset dashboards"]
end

node_erhr(("eRHR open data"))
node_analysts(("Dashboard users"))

node_erhr -->|"provides XML"| node_n8n
node_n8n -->|"loads parsed data"| node_staging
node_cpv -->|"supplies classification"| node_staging
node_staging -->|"transforms into"| node_dimensions
node_staging -->|"transforms into"| node_fact
node_staging -->|"derives DHS links"| node_dhs_hierarchy
node_fact -->|"feeds analysis views"| node_reporting_views
node_dimensions -->|"feeds analysis views"| node_reporting_views
node_dhs_hierarchy -->|"supports reporting"| node_reporting_views
node_refresh -->|"refreshes views"| node_dhs_hierarchy
node_reporting_views -->|"provides dashboard data"| node_superset
node_fact -->|"checks data quality"| node_quality
node_analysts -->|"explores dashboards"| node_superset

click node_cpv "https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/cpv.csv"
click node_dimensions "https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/01_star_schema_dim_tables.sql"
click node_fact "https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/02_star_schema_fact_dim_tables_v2.sql"
click node_dhs_hierarchy "https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/03_views_superset_powerbi_DHS_dhsSH.sql"
click node_reporting_views "https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/vw_hanked_superset.sql"
click node_refresh "https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/04_refresh_materialized_views.sql"
click node_quality "https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/control_queries.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_n8n,node_cpv,node_analysts toneBlue
class node_staging,node_dimensions,node_fact,node_dhs_hierarchy,node_reporting_views,node_refresh toneAmber
class node_quality,node_superset toneMint
class node_erhr toneIndigo
```

## Components

### Ingestion

- **n8n ingestion**
- [CPV classification](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/cpv.csv): `cpv.csv`

### Data warehouse

- **Staging tables**
- [Star dimensions](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/01_star_schema_dim_tables.sql): `scripts/01_star_schema_dim_tables.sql`
- [Procurement facts](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/02_star_schema_fact_dim_tables_v2.sql): `scripts/02_star_schema_fact_dim_tables_v2.sql`
- [DHS hierarchy](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/03_views_superset_powerbi_DHS_dhsSH.sql): `scripts/03_views_superset_powerbi_DHS_dhsSH.sql`
- [Reporting views](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/vw_hanked_superset.sql): `scripts/vw_hanked_superset.sql`
- [View refresh](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/04_refresh_materialized_views.sql): `scripts/04_refresh_materialized_views.sql`

### Analytics

- [Data quality checks](https://github.com/margitviidas-commits/m.v_andmeinsenerid_projekt_rhr_dhs/blob/main/scripts/control_queries.sql): `scripts/control_queries.sql`
- **Superset dashboards**

### Other components

- **eRHR open data**
- **Dashboard users**

## Connections

- eRHR open data → n8n ingestion: provides XML (evidence: `README.md`)
- n8n ingestion → Staging tables: loads parsed data (evidence: `README.md`)
- CPV classification → Staging tables: supplies classification (evidence: `README.md`)
- Staging tables → Star dimensions: transforms into (evidence: `README.md`)
- Staging tables → Procurement facts: transforms into (evidence: `README.md`)
- Staging tables → DHS hierarchy: derives DHS links (evidence: `README.md`)
- Procurement facts → Reporting views: feeds analysis views (evidence: `README.md`)
- Star dimensions → Reporting views: feeds analysis views (evidence: `README.md`)
- DHS hierarchy → Reporting views: supports reporting (evidence: `README.md`)
- View refresh → DHS hierarchy: refreshes views (evidence: `README.md`)
- Reporting views → Superset dashboards: provides dashboard data (evidence: `README.md`)
- Procurement facts → Data quality checks: checks data quality (evidence: `README.md`)
- Dashboard users → Superset dashboards: explores dashboards (evidence: `README.md`)
