# rianmaia/obrasgov-data-pipeline architecture

> Architecture diagram of the GitHub repository rianmaia/obrasgov-data-pipeline, 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/rianmaia/obrasgov-data-pipeline
- Repository: https://github.com/rianmaia/obrasgov-data-pipeline

## Overview

ObrasGov Data Pipeline collects four public-data domains, stores raw JSON in PostgreSQL Bronze, transforms records through dbt Silver into project-level Gold analytics, and presents them in a Streamlit dashboard. The principal workflow and dashboard capabilities are documented in the README; ingestion calls and persistence are visible in the sampled Python source. dbt model internals were not sampled, so the documented layer transitions are shown without inferring model-to-model joins beyond the stated project-level aggregation.

Main entry points: [`database/init/002_create_bronze_tables.sql`](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/database/init/002_create_bronze_tables.sql) (Bronze raw records), [`dbt/models/gold/fact_project_summary.sql`](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/gold/fact_project_summary.sql) (Project summary fact), [`ingestion/src/main.py`](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/ingestion/src/main.py) (Ingestion runner), [`dbt/models/silver/projects.sql`](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/projects.sql) (Silver projects)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Ingestion"]
  node_ingestion_orchestrator["Ingestion runner<br/>[main.py]"]
  node_api_client["Paged API client<br/>[api_client.py]"]
  node_configuration["Runtime configuration<br/>[config.py]"]
  node_persistence["Bronze persistence<br/>[database.py]"]
end

subgraph group_warehouse["Warehouse"]
  node_postgres[("PostgreSQL")]
  node_bronze[("Bronze raw records")]
  node_silver_projects["Silver projects<br/>[projects.sql]"]
  node_silver_investments["Silver investments"]
  node_silver_execution["Silver execution"]
  node_silver_commitments["Silver commitments<br/>[commitments.sql]"]
  node_silver_contracts["Silver contracts<br/>[contracts.sql]"]
end

subgraph group_analytics["Analytics"]
  node_gold_dimension["Project dimension<br/>[dim_project.sql]"]
  node_gold_summary["Project summary fact"]
end

subgraph group_dashboard["Dashboard"]
  node_streamlit_dashboard["Analytical dashboard<br/>[app.py]"]
end

node_public_api(("ObrasGov API"))

node_ingestion_orchestrator -->|"loads settings"| node_configuration
node_ingestion_orchestrator -->|"fetches pages"| node_api_client
node_api_client -->|"requests pages"| node_public_api
node_ingestion_orchestrator -->|"saves records"| node_persistence
node_persistence -->|"writes Bronze"| node_postgres
node_postgres -.->|"stores raw JSON"| node_bronze
node_bronze -->|"types records"| node_silver_projects
node_bronze -->|"types records"| node_silver_investments
node_bronze -->|"types records"| node_silver_execution
node_bronze -->|"types records"| node_silver_commitments
node_bronze -->|"types records"| node_silver_contracts
node_silver_projects -.->|"models projects"| node_gold_dimension
node_silver_projects -->|"aggregates projects"| node_gold_summary
node_silver_investments -->|"aggregates investments"| node_gold_summary
node_silver_execution -->|"summarizes execution"| node_gold_summary
node_silver_commitments -->|"aggregates commitments"| node_gold_summary
node_silver_contracts -->|"aggregates contracts"| node_gold_summary
node_gold_dimension -->|"queries projects"| node_streamlit_dashboard
node_gold_summary -->|"queries summaries"| node_streamlit_dashboard

click node_ingestion_orchestrator "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/ingestion/src/main.py"
click node_api_client "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/ingestion/src/api_client.py"
click node_configuration "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/ingestion/src/config.py"
click node_persistence "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/ingestion/src/database.py"
click node_bronze "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/database/init/002_create_bronze_tables.sql"
click node_silver_projects "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/projects.sql"
click node_silver_investments "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/project_investments.sql"
click node_silver_execution "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/physical_execution.sql"
click node_silver_commitments "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/commitments.sql"
click node_silver_contracts "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/contracts.sql"
click node_gold_dimension "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/gold/dim_project.sql"
click node_gold_summary "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/gold/fact_project_summary.sql"
click node_streamlit_dashboard "https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dashboard/app.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_ingestion_orchestrator,node_api_client,node_configuration,node_persistence toneBlue
class node_postgres,node_bronze,node_silver_projects,node_silver_investments,node_silver_execution,node_silver_commitments,node_silver_contracts toneAmber
class node_gold_dimension,node_gold_summary,node_public_api toneMint
class node_streamlit_dashboard toneRose
```

## Components

### Ingestion

- [Ingestion runner](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/ingestion/src/main.py): `ingestion/src/main.py`
- [Paged API client](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/ingestion/src/api_client.py): `ingestion/src/api_client.py`
- [Runtime configuration](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/ingestion/src/config.py): `ingestion/src/config.py`
- [Bronze persistence](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/ingestion/src/database.py): `ingestion/src/database.py`

### Warehouse

- **PostgreSQL**
- [Bronze raw records](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/database/init/002_create_bronze_tables.sql): `database/init/002_create_bronze_tables.sql`
- [Silver projects](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/projects.sql): `dbt/models/silver/projects.sql`
- [Silver investments](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/project_investments.sql): `dbt/models/silver/project_investments.sql`
- [Silver execution](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/physical_execution.sql): `dbt/models/silver/physical_execution.sql`
- [Silver commitments](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/commitments.sql): `dbt/models/silver/commitments.sql`
- [Silver contracts](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/silver/contracts.sql): `dbt/models/silver/contracts.sql`

### Analytics

- [Project dimension](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/gold/dim_project.sql): `dbt/models/gold/dim_project.sql`
- [Project summary fact](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dbt/models/gold/fact_project_summary.sql): `dbt/models/gold/fact_project_summary.sql`

### Dashboard

- [Analytical dashboard](https://github.com/rianmaia/obrasgov-data-pipeline/blob/main/dashboard/app.py): `dashboard/app.py`

### Other components

- **ObrasGov API**

## Connections

- Ingestion runner → Runtime configuration: loads settings (evidence: `ingestion/src/main.py`)
- Ingestion runner → Paged API client: fetches pages (evidence: `ingestion/src/main.py`)
- Paged API client → ObrasGov API: requests pages (evidence: `ingestion/src/api_client.py`)
- Ingestion runner → Bronze persistence: saves records (evidence: `ingestion/src/main.py`)
- Bronze persistence → PostgreSQL: writes Bronze (evidence: `ingestion/src/database.py`)
- PostgreSQL → Bronze raw records: stores raw JSON
- Bronze raw records → Silver projects: types records (evidence: `README.md`)
- Bronze raw records → Silver investments: types records (evidence: `README.md`)
- Bronze raw records → Silver execution: types records (evidence: `README.md`)
- Bronze raw records → Silver commitments: types records (evidence: `README.md`)
- Bronze raw records → Silver contracts: types records (evidence: `README.md`)
- Silver projects → Project dimension: models projects
- Silver projects → Project summary fact: aggregates projects (evidence: `README.md`)
- Silver investments → Project summary fact: aggregates investments (evidence: `README.md`)
- Silver execution → Project summary fact: summarizes execution (evidence: `README.md`)
- Silver commitments → Project summary fact: aggregates commitments (evidence: `README.md`)
- Silver contracts → Project summary fact: aggregates contracts (evidence: `README.md`)
- Project dimension → Analytical dashboard: queries projects (evidence: `README.md`)
- Project summary fact → Analytical dashboard: queries summaries (evidence: `dashboard/app.py`)
