Football Data Pipeline

- Data Engineer
- November 2026
- In Progress
In numbers
- Duplicate rows, against 1,055 in the old scraper
- 0
- To parse and validate 24 seasons of pages
- 0.28s
- Home wins when the home city is 2,500 m or more higher
- 56%
- Full scheduled run end to end on Floci, a local AWS emulator
- 39.1s
About the Project
Football Data Pipeline replaces my two one-off football scrapers with a pipeline that can run every week. Running its quality rules over the old scraper's output showed that 1,055 of its 2,436 Libertadores rows, 43%, were duplicates, and that it still missed 277 matches.
The ingest job fetches the Libertadores and Sudamericana pages for 2014 to 2025 from Wikipedia, one request per second, and stores the raw HTML before parsing it. The parser finds match tables by their header text instead of their position, labels each match with its stage, and expands two-legged ties into two matches. Every row is either valid or sent to quarantine with its reasons: a team that looks like a date, an unparsed score, a match not played, a duplicate. A transform job then uses DuckDB to join each team's city and altitude and write partitioned Parquet, and a FastAPI app reads that Parquet with DuckDB to answer queries. On AWS it is EventBridge Scheduler, Step Functions, three Lambda functions, S3 and API Gateway, all in Terraform modules that CI formats, validates, lints, scans with trivy and tests with a mocked provider. The same Terraform modules also deploy to Floci, a local AWS emulator, and CI runs the whole schedule there on simulated data: the state machine finished in 39.1 seconds, all 249 rows passed the quality checks, and the API answered in about 50 ms through the emulated API Gateway. Those are emulator figures, not AWS ones; the 24-season numbers come from local runs.
I built it in November 2026, first to fix the data and then because it is a good small example of data engineering on AWS. The market values stayed out on purpose: Transfermarkt's terms forbid automated scraping. One early result, which is data and not a causal claim: home teams playing 2,500 meters or more above their visitors won 56% of their matches.
How it works
The path a request takes, step by step.
- SchedulerEventBridge, weekly, through Step Functions
- IngestLambda fetches 24 pages and keeps the raw HTML
- QualityValid rows, or quarantine with reasons
- TransformDuckDB writes partitioned Parquet to S3
- APIFastAPI and DuckDB behind API Gateway
Decisions
The choices that shaped it, and what each one cost.
Keep the raw HTML
- Pages are stored before parsing, so a parser fix can be replayed over every season without fetching Wikipedia again.
- About 26 MB of HTML per full run.
Quarantine, never drop
- The old scripts skipped what they could not parse, which hid the duplicates. Here every rejected row is written with its reasons and counted.
- Someone has to read the quarantine; two rows sit there today.
DuckDB instead of dbt or Spark
- The dataset is a few thousand rows. DuckDB reads JSON and S3 and writes partitioned Parquet from SQL inside a Lambda.
- No lineage view or model tests like dbt would give.
Wikipedia only on the schedule
- Transfermarkt’s terms forbid automated scraping, so the market values stayed out of the pipeline.
- The altitude table cannot weigh in squad value anymore.
