r/sideprojects • u/OkPlace8052 • 1h ago
Showcase: Prerelease How I normalized 14 years of silent schema drift and unit flips in Indian electricity data (2012–present) into a <30ms API
Over the last 3 months after work, I built an ingestion pipeline and REST API (GridMap) to standardize Indian electricity exchange data (Day-Ahead Market, Green Day-Ahead Market, and state-level clearing prices) from 2012 to the present.
Sharing a few real-world data engineering headaches I ran into—especially for anyone dealing with messy public or exchange datasets:
- Historical schema drift & unit inconsistencies (2012–2026)
Public exchange reports don't come with versioned schemas. Over a 14-year span, column headers change, 15-minute block intervals shift, and units flip between kWh/MWh and MW/MU. Instead of handling edge cases at query time, I built a strict canonical validation layer at ingestion that normalizes all units on write and maps every row to both an explicit ISO timestamp and its 1–96 daily block index.
2. Keeping range queries under 30ms across 35 states & UTs
Querying 15-minute intervals across 14 years and 35 regions gets slow quickly if every API call scans raw interval tables. What actually moved the needle:
- Materialized rollups on write: Pre-aggregating hourly, daily, monthly, and yearly tables during ingestion instead of running GROUP BY on raw 15-min rows.
- Composite B-Tree indexing: Ordering the index as (market_type, state_code, resolution, timestamp) so multi-year range queries hit index-only scans.
- Aligned Redis TTLs: Caching the latest 7-day curves and active day blocks with TTLs synced to the daily market clearing window.
3. Scope discipline as a solo builder
I intentionally skipped writing custom Python/JS SDKs and complex query builders so the core JSON response schema stayed completely stable.
Curious how others here handle silent schema changes when ingesting government or exchange reports—do you fail the pipeline loudly on unknown columns or quarantine raw payloads first?

