Data Engineering · Cloud Architecture · DevOps · Open Source
Production Data Engineering Platform
A public, end-to-end implementation of how I build analytical systems: Python ingestion, dbt transformation, Airflow orchestration, automated testing, continuous integration, and analytical applications.
- Status
- Public repository
- My role
- Designed and built independently
- Technology
Select a component to see what it does, its inputs and outputs, and why it's there.
Market data API
- What it does
- Source of prices, fundamentals, news sentiment, technicals and macro data.
- Outputs
- JSON responses
- Technology
- Alpha Vantage (free tier)
- Design notes
- Scope is configuration-driven; a daily-cap hit is a soft skip.
Extract + load
- What it does
- Calls the API, validates responses, archives them and loads raw rows. No transformation.
- Inputs
- API responses
- Outputs
- S3 objects; raw.* rows
- Technology
- Python 3.13, requests, pydantic, tenacity
- Design notes
- Idempotent upserts on the natural grain; pytest-covered.
S3 raw archive
- What it does
- Immutable, verbatim copy of every API response for replay.
- Inputs
- Raw JSON
- Outputs
- Replay source
- Technology
- Amazon S3
- Design notes
- Keyed endpoint/symbol/date.
raw.*
- What it does
- Landing tables with verbatim JSON, source key and load time.
- Inputs
- Upserted raw records
- Outputs
- dbt sources
- Technology
- PostgreSQL (RDS), jsonb
dbt
- What it does
- All typing, cleaning, joining and aggregation, with tests and docs.
- Inputs
- raw.* sources, seeds, SCD2 snapshot
- Outputs
- Intermediate models
- Technology
- dbt Core, dbt_utils, dbt_expectations
- Design notes
- Point-in-time fundamentals via snapshot validity windows.
Marts
- What it does
- Curated dimensions and the incremental daily fact table.
- Inputs
- Intermediate models
- Outputs
- fct_daily_equity_metrics and marts
- Technology
- dbt incremental (delete+insert), contracts
Hex apps
- What it does
- Research, risk and leadership dashboards.
- Inputs
- marts.* only
- Outputs
- Analysis for different audiences
- Technology
- Hex
- Design notes
- No dashboard re-implements business logic.
Airflow DAG
- What it does
- Schedules the pipeline and halts it on a failed freshness check or test.
- Outputs
- Run history, notifications
- Technology
- Self-hosted Airflow
GitHub Actions CI
- What it does
- Runs lint and the full dbt build (every model and test) on each pull request.
- Inputs
- Pull requests
- Outputs
- Pass/fail gate
- Technology
- GitHub Actions, PostgreSQL service container, sqlfluff, ruff
Summary
Employer source code can't be shared publicly, so this project is an independently maintained, public example of how I build analytical systems. It ingests equities market data, archives it, loads it into PostgreSQL, and transforms it with dbt into tested, documented, point-in-time-correct models. Airflow orchestrates it, GitHub Actions gates every change, and three Hex dashboards read only from the curated marts.
The headline output is fct_daily_equity_metrics: one row per security per trading day, enriched with prices, returns, technical indicators, point-in-time fundamentals, daily news sentiment, macro context, and the latest earnings. It's typed, contract-enforced, tested, and documented.
Everything described here is in the public repository, and you can clone and run it yourself.
The problem it demonstrates
The original version of this pipeline was a typical analytics script: pull data from an API, reshape it in pandas, and overwrite tables with to_sql(if_exists='replace'). It worked until it didn't, and there was no way to know which.
That pattern shows up in real companies constantly. The logic lives in code nobody reviews, the tables get rebuilt from scratch on every run, nothing is tested, and dashboards quietly drift from each other because each one recomputes its own version of the numbers.
The rebuild was about the discipline that separates a script from a production pipeline:
- Changes are versioned, reviewed, and tested before they reach the warehouse.
- Every model has a documented grain and at least one test.
- Re-running a day is safe and never creates duplicates.
- Historical numbers don't change because today's data changed.
- Dashboards consume shared, curated models instead of rebuilding business logic.
Architecture
The pipeline is a clean extract-load, then transform, split:
- Extract. Python (with typed validation and retry/backoff) calls the API.
- Archive. Every raw response is written verbatim to S3, keyed by endpoint, symbol, and date. S3 is the immutable replay source.
- Load. Raw JSON lands in
raw.*tables in PostgreSQL, upserted on its natural grain. Python does no transformation at all. - Transform. dbt builds
staging(1:1 with sources),intermediate(returns, pivoted technicals, daily sentiment, forward-filled macro data, point-in-time fundamentals), andmarts(dimensions and the incremental fact table). - Orchestrate. An Airflow DAG runs
extract → freshness → snapshot → build → notifyand halts if any test fails. - Serve. Hex apps for research, risk, and leadership read only from
marts.*.
Select a component in the diagram above to see what it does and why it's there.
Design decisions
Python only extracts and loads; dbt does all transformation
Requirement: transformation logic had to be reviewable, testable, and versioned.
Approach: Python's only job is getting raw data in safely. All cleaning, typing, joining, and aggregation live in dbt SQL, where every model is documented and tested and lineage comes for free.
Trade-off: some transformations are more natural in Python. For this workload, having one place where business logic lives was worth more than that convenience. A pipeline with heavy non-SQL processing, such as text or image work, would need a different split.
Point-in-time correct fundamentals
Requirement: a model joining company fundamentals to daily prices must not leak future information into the past. This is the classic look-ahead bias that makes backtests look better than reality.
Approach: fundamentals are captured as a slowly changing (SCD2) snapshot and joined as of each trading date using validity windows. A singular test proves the windows never overlap. Dates before the first capture get NULL fundamentals by design: current values are never back-stamped onto history.
Trade-off: early history has gaps instead of plausible-looking but wrong numbers. That's the correct answer for analysis, but it has to be explained to people used to fully populated tables.
Idempotent, incremental loads
Requirement: a failed or repeated run must never corrupt the warehouse.
Approach: raw loads upsert on the grain. The fact table is incremental, using delete+insert on (symbol, date), so re-running any day produces the same result with zero duplicates.
Trade-off: incremental models need care when logic changes, because history may need a full refresh. That's handled deliberately instead of by rebuilding everything on every run.
Layering and contracts
Marts never reference staging or raw sources directly. They always go through intermediate models or dimensions, and this is verified against the dbt manifest. Contracts on the fact and dimension tables mean a schema change fails the build instead of silently breaking a dashboard. Reference data, like the sector-to-ETF mapping, is a version-controlled seed.
Testing and data quality
- Generic tests on every grain (
not_null, unique combinations), relationships from the fact to its dimensions, and accepted values on categorical fields. - Range expectations, for example RSI between 0 and 100, prices above zero, and non-negative counts.
- Singular tests for high/low consistency, no future dates, no fabricated sentiment, and non-overlapping point-in-time windows.
- Source freshness: warn after 36 hours and error after 72 on daily prices.
- Python tests for the extract layer (retry behavior, schema validation, idempotency), plus
ruffandsqlfluff.
CI runs linting and the full dbt build, every model and every test, against a PostgreSQL service container on each pull request.
Constraints
The project runs on the free tier of its market-data API, which limits the active symbols and history depth. Scope is entirely configuration-driven: moving to a premium tier is an environment change and a re-run, with no code changes. When the daily API cap is hit, the run is treated as a soft skip so the scheduled DAG stays green.
What's next
These are planned, not yet in the repository:
- Append-only raw storage with event-time partitioning.
- Source reconciliation and statistical anomaly detection with configurable z-score checks.
- Lineage with OpenLineage and Marquez.
Next step
Want to talk through something like this?
I'm happy to go deeper on the architecture, the trade-offs, or how it would apply to your situation.