Data Engineering
Fake-News Data Pipeline
Case study: A fact-checking team
Before anyone can train a fake-news detector, they need clean examples. This pipeline collects news articles and their images every night from six French sources, one of them satirical.
Play: real news or satire?The problem
Case study: a fact-checking team wants a model that spots fake news. The most common fakes mix text and pictures: a real photo used out of context, an edited image, a headline that does not match its picture. To learn that, a model needs many examples where each text stays attached to its image. My job was the step before any model: collect those examples automatically, every day, and store them clean.
I built it on French sources: the NewsData.io news API, the RSS feeds of Le Monde, franceinfo, Les Décodeurs and 20 Minutes Fake Off (the last two are fact-checking sections), and Le Gorafi, a satirical site, collected by scraping. No model is trained in this project. It is data engineering: collection, cleaning, storage, scheduling and monitoring.
What the demo does
The game shows a headline taken from the collected data. You decide: real news or satire? The answer and the source appear right away, and after ten headlines you get your score. It is harder than it sounds, because satire copies the style of real news. That is also why the data needs labels before anyone trains on it (more on this below).
The explorer lists the collected articles, with filters by source and date and a few counts: articles per source, share with an image.
A diagram walks through the nightly pipeline. The pipeline itself does not run on this site: the demo reads an export of its output.
Only headlines and links to the original articles are published here. Headlines are shown in French, as published, with an English machine translation next to them. The full texts and the images belong to their publishers, so they stay out of the site.
Results
- 535Clean, unique articles
- The last run re-read all 1,867 raw records collected so far and kept 535 unique articles once duplicates were removed. Each one has a title, a text, a date, a source and a stable ID.
- 92%Articles with a verified image
- 490 of the 535 articles come with an image that was downloaded and checked. The other 45 are kept and flagged, so the team training the detector can decide what to do with them.
- ~30 sLength of a nightly run
- Three extractions run side by side, then cleaning, loading and the quality check. A run that takes more than 5 minutes raises an alert.
The final dataset, after the run of 5 October 2026:
- 535 unique articles, from 1,867 raw rows collected over successive runs;
- 266 from the news API (73 different outlets), 112 from franceinfo, 77 from Le Monde, 33 from 20 Minutes Fake Off, 29 from Les Décodeurs, 18 from Le Gorafi;
- 490 with a verified image (92%); 19 articles whose image is also used by another article are flagged rather than deleted;
- 62 articles from fact-checking sections.
Each run uses 5 of the 200 daily credits of the free API plan. The satirical site is scraped politely: robots.txt is checked first, there is a 2-second pause between pages and at most 10 articles per run.
Limits, stated plainly:
- Almost no labels. Only the 18 satirical articles carry one, and satire is not disinformation. A detector trained to tell Le Gorafi from Le Monde would learn a writing style, not how to spot a lie. Useful labels would come from fact-checkers (Google Fact Check Tools) or a research dataset such as Fakeddit. I studied both in the source report and left them for the next step.
- The free API plan returns a short description, not the full article, with a 12-hour delay.
- 18 satirical headlines is a small pool for the game. Getting more means scraping more, slowly and within the site's rules.
- Le Monde's RSS feeds are for personal use. That is fine for a study, but it would need checking before any other use.
How it's built
Architecture, stack and technical choices.
Diagram as text
flowchart LR
A["NewsData.io API"] --> E1["extract_newsdata"]
B["4 RSS feeds"] --> E2["extract_rss"]
C["Le Gorafi (scraping)"] --> E3["extract_legorafi"]
E1 --> T["transform<br/>clean URLs and text, dedupe,<br/>check images"]
E2 --> T
E3 --> T
T --> P[("articles.parquet")]
P --> L["load<br/>upsert on article ID"]
L --> DB[("PostgreSQL")]
L --> Q["quality check<br/>thresholds"]
DB --> D["Streamlit dashboard<br/>read-only user"]Stack
- Python
- Apache Airflow
- PostgreSQL
- Docker Compose
- pandas
- Parquet
- requests
- feedparser
- BeautifulSoup
- Pillow
- Streamlit
- uv
Choices and trade-offs:
- One module per source, plus shared functions for cleaning, image download and saving. If a source fails, the error goes to the logs and the others carry on. In Airflow, the transform task runs with
trigger_rule="all_done"for the same reason, and each task gets one retry after 5 minutes. - The article ID is a hash of its cleaned URL (tracking parameters removed), and the image file carries the same ID. Text and image stay linked, and loading is idempotent: the load task upserts on the ID, so running it twice gives the same table.
- The transform step re-reads every extracted file each time. It is slower than processing only the new files, but two runs on the same data always give the same result, and each step logs how many rows it changed or dropped.
- Parquet for the dataset, because it keeps the types (dates, integers). PostgreSQL for the shared table, because the schema is fixed and a primary key on the ID blocks duplicates from one night to the next. The database runs in its own container, apart from Airflow's internal one, reachable only from the machine, with two roles: a writer for the DAG and a read-only user for the dashboard. Passwords and the API key sit in a
.envfile, and Airflow encrypts its stored connections with a Fernet key. - Monitoring. Each task writes its numbers (rows in, rows out, images, duration, API credits) to a
pipeline_metricstable. The last task compares them with thresholds kept in one config file. An extraction that still fails after its retry, or zero rows loaded, turns the run red. Fewer than 60% valid articles for a source, fewer than 80% with an image, a run over 5 minutes or more than 150 API credits in a day raise a warning. The Streamlit dashboard reads the same table and also flags a pipeline that has not run for 26 hours, a case Airflow cannot see on its own. - A change of course mid-project: at first I dropped articles without an image. Then the requirement changed: they are now kept and flagged with an
a_imagecolumn, and only duplicates and articles missing a title or a text are removed.
Next steps
- Plan the labels from day one. A detector needs "true" and "false" examples, and I would connect a fact-checking source while building the collection, not after.
- Run it on a small server. On a laptop, a nightly schedule only runs when the laptop is on.
- Send alerts by email or chat. Today a red run is only visible to someone who opens Airflow or the dashboard.
- Pay for the full article text if the detector needs it. The free plan's short descriptions limit what a text model can learn.