An ETL project for Twitch data.
It gets streams from the Twitch API and stores the raw JSON in MongoDB. Then it cleans the data in Spark and puts it into PostgreSQL with a star schema. After that, you can look at the data in Superset.
dags/— airflow tasks that get and process the datascripts/— code that uses the twitch api and sparkconfig/— shared configuration (DAG args, Twitch and MongoDB settings)infra/— docker-compose, dockerfile, postgres init (schema + seed data), requirementstools/— setup script
- python
- apache airflow
- apache spark (pyspark)
- mongodb (raw json landing zone)
- postgresql (star schema warehouse)
- docker, docker compose
- apache superset
- collect (
twitch_data_collectorDAG, every 15 min) — pull top streams from the Twitch API and insert the raw JSON documents into MongoDB (twitch.raw_streams). Old documents are cleaned up after 7 days. - process (
twitch_data_processorDAG, daily) — Spark reads the day's documents from MongoDB, resolves the dimensions, builds the fact rows and writes them to PostgreSQL, then refreshes the analytics materialized views. - explore — Superset reads the star schema and materialized views.
The PostgreSQL star schema (dimension/fact tables, indexes, materialized views) and the static dimensions (dim_dates, dim_times, dim_languages) are created automatically by infra/init-postgres.sql on first start — there are no separate migrations to run.
- make a copy of the environment file:
cp env.example .env - add your values in
.env:TWITCH_CLIENT_IDTWITCH_CLIENT_SECRETAIRFLOW_UIDMONGO_URI(defaults tomongodb://mongo:27017)
- start the project:
make setup
- airflow:
http://localhost:8080(airflow/airflow) - superset:
http://localhost:8088(admin/admin) - mongodb:
mongodb://localhost:27017(databasetwitch, collectionraw_streams)
make up— start the servicesmake down— stop the servicesmake status— check the statusmake logs— see the logs