# lsruaro/projeto-dados-cvm architecture

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

- Interactive diagram: https://gitdiagram.com/lsruaro/projeto-dados-cvm
- Repository: https://github.com/lsruaro/projeto-dados-cvm

## Overview

This is a CVM financial-statements ETL pipeline: it downloads and extracts annual DFP archives, consolidates and standardizes four statement datasets, then upserts them into PostgreSQL staging tables for downstream analysis. The graph separates acquisition, preparation, and staging/consumption. A validation notebook is also documented; its internal implementation was not sampled, so its relationship is based on the README.

Main entry points: [`download_dfp.py`](https://github.com/lsruaro/projeto-dados-cvm/blob/main/download_dfp.py) (Download and extract), [`load_stg.py`](https://github.com/lsruaro/projeto-dados-cvm/blob/main/load_stg.py) (ETL and upsert), [`notebooks/analise_processed_csv.ipynb`](https://github.com/lsruaro/projeto-dados-cvm/blob/main/notebooks/analise_processed_csv.ipynb) (Data validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_acquisition["Data acquisition"]
  node_downloader["Download and extract<br/>[download_dfp.py]"]
  node_archives["ZIP archives"]
  node_raw_csv["Annual raw CSVs"]
end

subgraph group_preparation["Data preparation"]
  node_loader["ETL and upsert<br/>[load_stg.py]"]
  node_raw_reader["Annual CSV reader<br/>[load_stg.py]"]
  node_standardizer["Statement standardizer<br/>[load_stg.py]"]
  node_processed["Processed CSVs"]
end

subgraph group_staging["Staging and use"]
  node_postgres[("PostgreSQL staging")]
  node_validation["Data validation"]
end

node_operator(("Pipeline operator"))
node_cvm["CVM portal"]
node_analyst(("Analysis consumers"))

node_operator -->|"runs"| node_downloader
node_operator -->|"runs"| node_loader
node_downloader -->|"downloads archives"| node_cvm
node_downloader -->|"saves ZIPs"| node_archives
node_downloader -->|"extracts files"| node_raw_csv
node_loader -->|"invokes"| node_raw_reader
node_raw_reader -->|"reads annual files"| node_raw_csv
node_loader -->|"applies"| node_standardizer
node_standardizer -->|"writes consolidated CSVs"| node_processed
node_loader -->|"upserts statements"| node_postgres
node_validation -->|"validates data"| node_processed
node_validation -->|"checks staging coverage"| node_postgres
node_postgres -->|"supplies staging data"| node_analyst

click node_downloader "https://github.com/lsruaro/projeto-dados-cvm/blob/main/download_dfp.py"
click node_loader "https://github.com/lsruaro/projeto-dados-cvm/blob/main/load_stg.py"
click node_raw_reader "https://github.com/lsruaro/projeto-dados-cvm/blob/main/load_stg.py"
click node_standardizer "https://github.com/lsruaro/projeto-dados-cvm/blob/main/load_stg.py"
click node_validation "https://github.com/lsruaro/projeto-dados-cvm/blob/main/notebooks/analise_processed_csv.ipynb"

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_downloader,node_archives,node_raw_csv toneBlue
class node_loader,node_raw_reader,node_standardizer,node_processed toneAmber
class node_postgres,node_validation toneMint
class node_operator,node_cvm,node_analyst toneIndigo
```

## Components

### Data acquisition

- [Download and extract](https://github.com/lsruaro/projeto-dados-cvm/blob/main/download_dfp.py): `download_dfp.py`
- **ZIP archives**
- **Annual raw CSVs**

### Data preparation

- [ETL and upsert](https://github.com/lsruaro/projeto-dados-cvm/blob/main/load_stg.py): `load_stg.py`
- [Annual CSV reader](https://github.com/lsruaro/projeto-dados-cvm/blob/main/load_stg.py): `load_stg.py`
- [Statement standardizer](https://github.com/lsruaro/projeto-dados-cvm/blob/main/load_stg.py): `load_stg.py`
- **Processed CSVs**

### Staging and use

- **PostgreSQL staging**
- [Data validation](https://github.com/lsruaro/projeto-dados-cvm/blob/main/notebooks/analise_processed_csv.ipynb): `notebooks/analise_processed_csv.ipynb`

### Other components

- **Pipeline operator**
- **CVM portal**
- **Analysis consumers**

## Connections

- Pipeline operator → Download and extract: runs (evidence: `README.md`)
- Pipeline operator → ETL and upsert: runs (evidence: `README.md`)
- Download and extract → CVM portal: downloads archives (evidence: `download_dfp.py`)
- Download and extract → ZIP archives: saves ZIPs (evidence: `download_dfp.py`)
- Download and extract → Annual raw CSVs: extracts files (evidence: `download_dfp.py`)
- ETL and upsert → Annual CSV reader: invokes (evidence: `load_stg.py`)
- Annual CSV reader → Annual raw CSVs: reads annual files (evidence: `load_stg.py`)
- ETL and upsert → Statement standardizer: applies (evidence: `load_stg.py`)
- Statement standardizer → Processed CSVs: writes consolidated CSVs (evidence: `load_stg.py`)
- ETL and upsert → PostgreSQL staging: upserts statements (evidence: `load_stg.py`)
- Data validation → Processed CSVs: validates data (evidence: `README.md`)
- Data validation → PostgreSQL staging: checks staging coverage (evidence: `README.md`)
- PostgreSQL staging → Analysis consumers: supplies staging data (evidence: `README.md`)
