# thecountt/data-modeling-with-postgres architecture

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

- Interactive diagram: https://gitdiagram.com/thecountt/data-modeling-with-postgres
- Repository: https://github.com/thecountt/data-modeling-with-postgres

## Overview

Sparkify is a local ETL pipeline that turns song metadata and streaming activity JSON into a SQLite star schema for song-play analysis. The main workflow initializes tables, loads song and artist dimensions, then filters NextSong events to populate time, user, and songplays records; songplays lookup resolves song and artist IDs from the loaded catalog. README documents these schema capabilities and historical subscription-level capture. Source excerpts show SQLite implementations despite README references to Postgres; unsampled analysis tooling is excluded.

Main entry points: [`etl.py`](https://github.com/thecountt/data-modeling-with-postgres/blob/main/etl.py) (Activity event loader), [`main.py`](https://github.com/thecountt/data-modeling-with-postgres/blob/main/main.py) (Pipeline runner), [`create_tables.py`](https://github.com/thecountt/data-modeling-with-postgres/blob/main/create_tables.py) (Table setup), [`sql_queries.py`](https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py) (Songs dimension)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Database setup"]
  node_table_setup["Table setup<br/>[create_tables.py]"]
end

subgraph group_etl["ETL processing"]
  node_song_loader["Song metadata loader<br/>[etl.py]"]
  node_event_loader["Activity event loader<br/>[etl.py]"]
end

subgraph group_schema["Analytics schema"]
  node_query_definitions["Schema and SQL<br/>[sql_queries.py]"]
  node_songplays[("Songplays fact<br/>[sql_queries.py]")]
  node_users[("Users dimension<br/>[sql_queries.py]")]
  node_songs[("Songs dimension<br/>[sql_queries.py]")]
  node_artists[("Artists dimension<br/>[sql_queries.py]")]
  node_time[("Time dimension<br/>[sql_queries.py]")]
end

node_runner(("Pipeline runner<br/>[main.py]"))

node_runner -->|"runs first"| node_table_setup
node_runner -->|"runs next"| node_event_loader
node_table_setup -->|"executes schema SQL"| node_query_definitions
node_song_loader -->|"inserts songs"| node_songs
node_song_loader -->|"inserts artists"| node_artists
node_event_loader -->|"inserts timestamps"| node_time
node_event_loader -->|"upserts users"| node_users
node_event_loader -->|"looks up matches"| node_songs
node_event_loader -->|"looks up matches"| node_artists
node_event_loader -->|"inserts plays"| node_songplays

click node_runner "https://github.com/thecountt/data-modeling-with-postgres/blob/main/main.py"
click node_table_setup "https://github.com/thecountt/data-modeling-with-postgres/blob/main/create_tables.py"
click node_query_definitions "https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py"
click node_song_loader "https://github.com/thecountt/data-modeling-with-postgres/blob/main/etl.py"
click node_event_loader "https://github.com/thecountt/data-modeling-with-postgres/blob/main/etl.py"
click node_songplays "https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py"
click node_users "https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py"
click node_songs "https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py"
click node_artists "https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py"
click node_time "https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.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_table_setup toneBlue
class node_song_loader,node_event_loader toneAmber
class node_query_definitions,node_songplays,node_users,node_songs,node_artists,node_time toneMint
class node_runner toneTeal
```

## Components

### Database setup

- [Table setup](https://github.com/thecountt/data-modeling-with-postgres/blob/main/create_tables.py): `create_tables.py`

### ETL processing

- [Song metadata loader](https://github.com/thecountt/data-modeling-with-postgres/blob/main/etl.py): `etl.py`
- [Activity event loader](https://github.com/thecountt/data-modeling-with-postgres/blob/main/etl.py): `etl.py`

### Analytics schema

- [Schema and SQL](https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py): `sql_queries.py`
- [Songplays fact](https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py): `sql_queries.py`
- [Users dimension](https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py): `sql_queries.py`
- [Songs dimension](https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py): `sql_queries.py`
- [Artists dimension](https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py): `sql_queries.py`
- [Time dimension](https://github.com/thecountt/data-modeling-with-postgres/blob/main/sql_queries.py): `sql_queries.py`

### Other components

- [Pipeline runner](https://github.com/thecountt/data-modeling-with-postgres/blob/main/main.py): `main.py`

## Connections

- Pipeline runner → Table setup: runs first (evidence: `main.py`)
- Pipeline runner → Activity event loader: runs next (evidence: `main.py`)
- Table setup → Schema and SQL: executes schema SQL (evidence: `create_tables.py`)
- Song metadata loader → Songs dimension: inserts songs (evidence: `etl.py`)
- Song metadata loader → Artists dimension: inserts artists (evidence: `etl.py`)
- Activity event loader → Time dimension: inserts timestamps (evidence: `etl.py`)
- Activity event loader → Users dimension: upserts users (evidence: `etl.py`)
- Activity event loader → Songs dimension: looks up matches (evidence: `etl.py`)
- Activity event loader → Artists dimension: looks up matches (evidence: `etl.py`)
- Activity event loader → Songplays fact: inserts plays (evidence: `etl.py`)
