# yccs-26/olist-batch-pipeline architecture

> Architecture diagram of the GitHub repository yccs-26/olist-batch-pipeline, 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/yccs-26/olist-batch-pipeline
- Repository: https://github.com/yccs-26/olist-batch-pipeline

## Overview

This repository implements a monthly Olist orders ETL pipeline: local order CSVs are partitioned into S3 raw objects, ingested for a selected month into PostgreSQL staging, then classified into clean and quarantine outputs. Batch-month parsing is a shared internal layer; audit records and SQL-defined database structures support operation. The graph combines sampled Python behavior with README-documented capabilities; unsampled implementation details are not inferred beyond those documented relationships.

Main entry points: [`scripts/clean_orders.py`](https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/clean_orders.py) (Clean processing), [`scripts/ingest_to_staging.py`](https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/ingest_to_staging.py) (Staging ingestion), [`scripts/ingest_orders.py`](https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/ingest_orders.py) (Monthly uploader), [`sql/DDL/01_create_stg_orders.sql`](https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/01_create_stg_orders.sql) (Staging orders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_raw["Raw ingestion"]
  node_orders_csv["Orders CSV"]
  node_raw_uploader["Monthly uploader<br/>[ingest_orders.py]"]
  node_s3[("S3 raw objects")]
end

subgraph group_transform["Staging and quality"]
  node_staging_ingest["Staging ingestion"]
  node_staging[("Staging orders")]
  node_timestamp_parser["Timestamp parser"]
  node_quality_rules["Quality classification"]
  node_clean_loader["Clean processing<br/>[clean_orders.py]"]
  node_clean_table[("Clean orders")]
  node_quarantine_table[("Quarantine orders")]
end

subgraph group_operations["Batch operations"]
  node_batch_args["Month arguments<br/>[args_parse.py]"]
  node_audit_table[("Batch audit")]
end

node_operator(("Batch operator"))
node_postgres[("PostgreSQL")]

node_orders_csv -->|"reads"| node_raw_uploader
node_raw_uploader -->|"uploads partitions"| node_s3
node_operator -->|"starts batch"| node_staging_ingest
node_operator -->|"starts batch"| node_clean_loader
node_staging_ingest -->|"parses month"| node_batch_args
node_clean_loader -->|"parses month"| node_batch_args
node_staging_ingest -->|"downloads partition"| node_s3
node_staging_ingest -->|"loads batch"| node_staging
node_staging_ingest -->|"connects"| node_postgres
node_staging -->|"provides rows"| node_clean_loader
node_clean_loader -->|"parses timestamps"| node_timestamp_parser
node_clean_loader -->|"classifies rows"| node_quality_rules
node_clean_loader -->|"inserts valid rows"| node_clean_table
node_clean_loader -->|"inserts rejected rows"| node_quarantine_table
node_clean_loader -->|"runs transaction"| node_postgres
node_clean_loader -->|"records outcome"| node_audit_table
node_staging_ingest -.->|"records outcome"| node_audit_table

click node_orders_csv "https://github.com/yccs-26/olist-batch-pipeline/blob/main/csvfiles/olist_orders_dataset.csv"
click node_raw_uploader "https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/ingest_orders.py"
click node_batch_args "https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/args_parse.py"
click node_staging_ingest "https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/ingest_to_staging.py"
click node_staging "https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/01_create_stg_orders.sql"
click node_timestamp_parser "https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/02_create_try_parse_timestamp_function.sql"
click node_quality_rules "https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/03_clean_quarantine_orders.sql"
click node_clean_loader "https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/clean_orders.py"
click node_clean_table "https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/04_load_clean_quarantine_orders.sql"
click node_quarantine_table "https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/04_load_clean_quarantine_orders.sql"
click node_audit_table "https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/05_create_etl_batch_runs.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_orders_csv,node_raw_uploader,node_s3 toneBlue
class node_staging_ingest,node_staging,node_timestamp_parser,node_quality_rules,node_clean_loader,node_clean_table,node_quarantine_table,node_postgres toneAmber
class node_batch_args,node_audit_table toneMint
class node_operator toneIndigo
```

## Components

### Raw ingestion

- [Orders CSV](https://github.com/yccs-26/olist-batch-pipeline/blob/main/csvfiles/olist_orders_dataset.csv): `csvfiles/olist_orders_dataset.csv`
- [Monthly uploader](https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/ingest_orders.py): `scripts/ingest_orders.py`
- **S3 raw objects**

### Staging and quality

- [Staging ingestion](https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/ingest_to_staging.py): `scripts/ingest_to_staging.py`
- [Staging orders](https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/01_create_stg_orders.sql): `sql/DDL/01_create_stg_orders.sql`
- [Timestamp parser](https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/02_create_try_parse_timestamp_function.sql): `sql/DDL/02_create_try_parse_timestamp_function.sql`
- [Quality classification](https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/03_clean_quarantine_orders.sql): `sql/DDL/03_clean_quarantine_orders.sql`
- [Clean processing](https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/clean_orders.py): `scripts/clean_orders.py`
- [Clean orders](https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/04_load_clean_quarantine_orders.sql): `sql/DDL/04_load_clean_quarantine_orders.sql`
- [Quarantine orders](https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/04_load_clean_quarantine_orders.sql): `sql/DDL/04_load_clean_quarantine_orders.sql`

### Batch operations

- [Month arguments](https://github.com/yccs-26/olist-batch-pipeline/blob/main/scripts/args_parse.py): `scripts/args_parse.py`
- [Batch audit](https://github.com/yccs-26/olist-batch-pipeline/blob/main/sql/DDL/05_create_etl_batch_runs.sql): `sql/DDL/05_create_etl_batch_runs.sql`

### Other components

- **Batch operator**
- **PostgreSQL**

## Connections

- Orders CSV → Monthly uploader: reads (evidence: `scripts/ingest_orders.py`)
- Monthly uploader → S3 raw objects: uploads partitions (evidence: `scripts/ingest_orders.py`)
- Batch operator → Staging ingestion: starts batch (evidence: `README.md`)
- Batch operator → Clean processing: starts batch (evidence: `README.md`)
- Staging ingestion → Month arguments: parses month (evidence: `scripts/ingest_to_staging.py`)
- Clean processing → Month arguments: parses month (evidence: `scripts/clean_orders.py`)
- Staging ingestion → S3 raw objects: downloads partition (evidence: `scripts/ingest_to_staging.py`)
- Staging ingestion → Staging orders: loads batch (evidence: `scripts/ingest_to_staging.py`)
- Staging ingestion → PostgreSQL: connects (evidence: `scripts/ingest_to_staging.py`)
- Staging orders → Clean processing: provides rows (evidence: `README.md`)
- Clean processing → Timestamp parser: parses timestamps (evidence: `scripts/clean_orders.py`)
- Clean processing → Quality classification: classifies rows (evidence: `scripts/clean_orders.py`)
- Clean processing → Clean orders: inserts valid rows (evidence: `scripts/clean_orders.py`)
- Clean processing → Quarantine orders: inserts rejected rows (evidence: `scripts/clean_orders.py`)
- Clean processing → PostgreSQL: runs transaction (evidence: `scripts/clean_orders.py`)
- Clean processing → Batch audit: records outcome (evidence: `README.md`)
- Staging ingestion → Batch audit: records outcome (evidence: `README.md`)
