Projects

Meridian Mart retail data pipeline and warehouse

A daily pipeline that pulls sales data from five mismatched sources into a tested star schema, and keeps the numbers right when files arrive late, twice, or in a new shape.

Meridian Mart pipeline: five sources extracted into raw tables, transformed with dbt into staging views and a tested star schema
Status
In progress
My role
Solo project
Areas
Data engineering
Tools
Python, PostgreSQL, dbt, Apache Airflow, Docker, pytest, GitHub Actions, BigQuery
Skills
Multi-source extraction, Watermark and incremental loading, Late data and backfills, Type 2 dimensions, Star schema modelling, Data testing and reconciliation, Orchestration
Data
Simulated business, including its awkward behaviour

The business

Meridian Mart is a simulated Nigerian grocery and pharmacy chain with 24 stores and an online shop. Its data lives in five places that were never designed to meet:

  • Till files sent by each store as CSV
  • An operational PostgreSQL database
  • An online orders API that returns results page by page
  • Supplier price lists in Excel, in two different layouts
  • A daily foreign-exchange rate, from a file or an API

The problem

Real pipelines rarely fail loudly. A store file arrives a week late, or twice, or with a new column, and the warehouse quietly reports the wrong sales. Prices change, and old sales get costed at today’s price. This project is built to keep the numbers right through all of that, and to prove it.

How it works

  1. Extract and load. Python extractors pull from all five sources every day and land the data unchanged. Each file is identified by a fingerprint of its contents, so a re-sent file is skipped. The database extractor reads only rows changed since the last run (a watermark), and moves the watermark in the same step as the load. The API extractor retries with growing delays and writes nothing until every page has arrived.
  2. Raw layer. Append-only and untyped. Every version of every row is kept, which is what makes history rebuildable.
  3. Staging. One dbt view per source table casts types, converts naira to whole kobo, derives the sale date in Lagos time, and keeps the latest copy of each record.
  4. Marts. A star schema: sales, online orders, daily inventory snapshots and exchange rates, with product, store, supplier, date and channel dimensions. The product dimension keeps every price version, so each sale is joined to the price in force at the moment it happened.
  5. Tests. Keys are unique and complete, every fact links to a dimension, warehouse totals equal source totals for every date in the lookback window, and each product has exactly one current version.
  6. Orchestration. An Airflow DAG runs the five extracts in parallel, then the dbt build, then freshness and volume checks.

Design choices

  • Transform inside the warehouse (ELT). Raw data lands first; dbt does the shaping, so every model is version-controlled and tested.
  • Money as integer kobo. No rounding drift in totals.
  • A seven-day lookback for incremental loads, plus a single backfill command for anything later.
  • Never two runs at once, because overlapping runs would race on the watermarks.