ghtrends is a small project of mine. Every hour it pulls GitHub Archive events, writes them to Parquet on S3, runs dbt models over them, and a Streamlit page shows the trends.
The ingest code is boring. The storage layout is not. That turned out to be the whole design.
GitHub Archive gives you one file per hour. The natural move is to keep that shape: one Parquet file per hour, partitioned by date and hour in S3, something like year=2026/month=12/day=05/hour=17/.
I did that, and it works, but only because of how the queries look. Almost every question I ask is time-bounded. What repos spiked today. What languages moved this week. With date partitions, the engine prunes whole folders before it opens a single file. A query over one day reads 24 files, not everything I have ever ingested.
The mistake would be partitioning by something that feels analytical, like event type or repo. That looks smart and performs badly. Cardinality is the problem. There are millions of repos. Partition by repo and you get millions of tiny files, and every query pays for listing and opening them. Small files are how S3-backed analytics dies quietly.
So the rule I ended up with is simple. Partition by the column you filter on most, keep the number of partitions low, and let Parquet do the rest inside the file. Column pruning means a query that only needs repo name and event type never reads the payload column at all. That matters here because GitHub event payloads are fat and mostly useless for trend questions.
dbt sits on top and does the unglamorous part. Staging models clean the raw events, then a few marts aggregate by hour and day. When an hour lands late or gets re-ingested, I rerun that partition instead of rebuilding everything. Idempotent hourly loads sound like a buzzword until the first duplicate hour doubles your star count.
That duplicate problem is the real lesson. Append-only ingest plus hourly files means retries will eventually write the same hour twice. If the dbt layer does not dedupe on event id, your numbers are wrong and nothing errors. Silent wrong numbers are worse than a crashed pipeline. A crash gets fixed. A doubled count gets screenshotted.
Streamlit is just the last mile. It queries the marts, not the raw events. If it queried raw Parquet on every page load, it would be slow and I would be paying to scan payloads nobody looks at.
None of this is clever. One file per hour, partition by date, dedupe in dbt, aggregate before serving. But it runs every hour without me touching it, and the queries stay fast because the layout matches the questions.
Storage layout is not a detail you fix later. It is the design.
