Stage 1: Problem
The Problem
You are building a report generation system for an analytics dashboard. The system must produce reports in three formats: PDF, CSV, and Excel.
Every report follows the same workflow:
- Fetch raw data from the database
- Validate that the data meets minimum thresholds
- Transform/aggregate the data
- Render the final output in the target format
The first three steps are mostly identical across formats. Only the final rendering step differs significantly, though some formats need slight tweaks in transformation too (CSV needs flat rows, Excel needs grouped sheets).
Your PM says: "We'll add HTML and Markdown formats next quarter."
Before reading further: How would you structure this so that adding a new format is easy, the shared logic lives in one place, and each format can customize the steps it needs to?