# joeltondf/cnm architecture

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

- Interactive diagram: https://gitdiagram.com/joeltondf/cnm
- Repository: https://github.com/joeltondf/cnm

## Overview

This is a PHP municipal budget-monitoring dashboard. Users choose a municipality and reporting parameters, then the dashboard obtains SICONFI data and presents financial summaries, comparisons, tables, and charts. A separate page synchronizes the municipality list from IBGE. The excerpts show the dashboard-to-service calls, database connection setup, and IBGE synchronization; they do not expose the full query, cache, or persistence flow, so those details are not expanded here.

Main entry points: [`lib/Database.php`](https://github.com/joeltondf/cnm/blob/main/lib/Database.php) (PDO connection), [`lib/SiconfiService.php`](https://github.com/joeltondf/cnm/blob/main/lib/SiconfiService.php) (SICONFI service), [`sync_municipios.php`](https://github.com/joeltondf/cnm/blob/main/sync_municipios.php) (Municipality sync), [`index.php`](https://github.com/joeltondf/cnm/blob/main/index.php) (Dashboard UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_index["Dashboard UI<br/>[index.php]"]
end

subgraph group_financial["Financial data"]
  node_service["SICONFI service<br/>[SiconfiService.php]"]
  node_siconfi{{"SICONFI API"}}
end

subgraph group_storage["Local storage"]
  node_database["PDO connection<br/>[Database.php]"]
  node_config["Runtime config<br/>[config.php]"]
  node_mysql[("MySQL database")]
end

subgraph group_municipalities["Municipality sync"]
  node_sync["Municipality sync"]
  node_ibge{{"IBGE API"}}
end

node_user(("Dashboard user"))

node_user -.->|"uses"| node_index
node_index -->|"requests data"| node_service
node_service -->|"queries"| node_siconfi
node_service -->|"uses"| node_database
node_database -->|"loads settings"| node_config
node_database -->|"opens connection"| node_mysql
node_sync -->|"fetches municipalities"| node_ibge
node_sync -->|"gets connection"| node_database

click node_index "https://github.com/joeltondf/cnm/blob/main/index.php"
click node_service "https://github.com/joeltondf/cnm/blob/main/lib/SiconfiService.php"
click node_database "https://github.com/joeltondf/cnm/blob/main/lib/Database.php"
click node_config "https://github.com/joeltondf/cnm/blob/main/config.php"
click node_sync "https://github.com/joeltondf/cnm/blob/main/sync_municipios.php"

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_index,node_user toneBlue
class node_service,node_siconfi toneAmber
class node_database,node_config,node_mysql toneMint
class node_sync,node_ibge toneRose
```

## Components

### Dashboard

- [Dashboard UI](https://github.com/joeltondf/cnm/blob/main/index.php): `index.php`

### Financial data

- [SICONFI service](https://github.com/joeltondf/cnm/blob/main/lib/SiconfiService.php): `lib/SiconfiService.php`
- **SICONFI API**

### Local storage

- [PDO connection](https://github.com/joeltondf/cnm/blob/main/lib/Database.php): `lib/Database.php`
- [Runtime config](https://github.com/joeltondf/cnm/blob/main/config.php): `config.php`
- **MySQL database**

### Municipality sync

- [Municipality sync](https://github.com/joeltondf/cnm/blob/main/sync_municipios.php): `sync_municipios.php`
- **IBGE API**

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Dashboard UI: uses
- Dashboard UI → SICONFI service: requests data (evidence: `index.php`)
- SICONFI service → SICONFI API: queries (evidence: `lib/SiconfiService.php`)
- SICONFI service → PDO connection: uses (evidence: `lib/SiconfiService.php`)
- PDO connection → Runtime config: loads settings (evidence: `lib/Database.php`)
- PDO connection → MySQL database: opens connection (evidence: `lib/Database.php`)
- Municipality sync → IBGE API: fetches municipalities (evidence: `sync_municipios.php`)
- Municipality sync → PDO connection: gets connection (evidence: `sync_municipios.php`)
