Media and content data
TrendingZ: Trending video intelligence across 53 countries
TrendingZ is a hub for trending YouTube videos and Shorts across 53 countries, on the web and Android. Scheduled background jobs fetch the charts and store them; visitors are served from storage, so traffic no longer decides how much of YouTube’s daily API quota is spent.


The problem
Why it exists.
The YouTube Data API allows 10,000 units a day for the whole project, not per user. When visits triggered API calls, the quota capped the audience, and it ran out: the site went blank. The product had to serve any amount of traffic inside the same fixed quota.
The product
What it does.

Trending charts by country, category and language.

Every video with its rank and why it is trending.

Rising Now, Shorts, archive and a local-first library.
Trending videos and Shorts by country
Charts for 53 countries, with category and language filters.
Rising Now
Videos ranked by places climbed and views gained, compared against 3, 6, 12 or 24 hours ago.
A page for every video
Shareable, indexable pages. Link previews in chat apps and search engines get a server-rendered page with the video’s own title and image.
Archive
Past charts kept as daily snapshots, so you can look back at what was trending.
Installable everywhere
A progressive web app that opens offline, an Android app on Google Play, and desktop builds for Windows and macOS.
Local-first library
History, saved videos and followed channels work without an account and merge into it when one is created.
Engineering
The hard parts, and how we solved them.
- 01
Traffic decoupled from API cost
Pages are served from MongoDB. Scheduled ingestion is the only code that calls YouTube on a timer, so a million visitors cost the same scheduled units as one.
- 02
Three budgets and one shared ledger
The 10,000 daily units are split into budgets: 3,000 for chart sweeps, 4,500 for genre enrichment and 2,000 for calls a visitor triggers. Every call asks the ledger first. The counters live in MongoDB, so all workers share them, and they reset at midnight Pacific time, when YouTube resets the quota.
- 03
Tiered sweeps
Three regions are swept hourly at full depth, twelve every six hours and the rest daily: about 1,600 units a day, where a flat hourly sweep of every country and category would cost about 51,000.
- 04
Snapshots make movement possible
Each sweep stores a snapshot. Rising Now and view velocity come from comparing them, at no extra API cost. After a week only one snapshot a day is kept, for the archive.
- 05
Stale but labelled, never blank
A chart older than 90 minutes can be refreshed from the visitor budget. When that budget is spent, a chart up to 72 hours old is served with a notice instead of an empty page. Stored YouTube data is deleted after 30 days, as YouTube’s terms require.
Architecture
How it fits together.
Clients
- Web app (PWA): React 19
- Mobile apps: Capacitor
- Desktop builds: Electron
- Link previews: Search and chat bots
Edge
- nginx: App, bot routing
API
- Accounts: JWT, bcrypt
- FastAPI: 55 endpoints
- Quota ledger: 3 budgets, 10,000/day
Background jobs
- Chart sweeps: Hourly, 6-hourly, daily
- Genre enrichment: Daily searches
- Pruning: 30-day rule
Data and source
- MongoDB: Charts, snapshots
- YouTube Data API: v3
Connections
- Web app (PWA) → nginx: HTTPS
- Mobile apps → nginx: HTTPS
- Desktop builds → nginx: HTTPS
- Link previews → nginx: Sent to server-rendered video pages
- nginx → FastAPI: API requests and preview pages
- FastAPI → Accounts: Sign-in and synced library
- FastAPI → Quota ledger: Asks before any visitor-triggered call
- FastAPI → MongoDB: Every page is read from storage
- Quota ledger → Chart sweeps: Reserved chart budget
- Quota ledger → Genre enrichment: Reserved enrichment budget
- Quota ledger → YouTube Data API: Capped visitor budget
- Chart sweeps → YouTube Data API: Tiered chart requests
- Genre enrichment → YouTube Data API: Genre searches
- Chart sweeps → MongoDB: Charts and snapshots
- Genre enrichment → MongoDB: Genres
- Pruning → MongoDB: Deletes data older than 30 days
Technology
The stack, layer by layer.
Each technology with the job it does in this product.
Frontend
- React
- The web app (React 19, built with Create React App and CRACO).
- React Router
- Pages for charts, videos, channels and the library.
- Tailwind CSS
- Styling.
- Framer Motion
- Interface animation.
- Recharts
- Charts in the admin analytics dashboard.
- PWA
- Service worker, offline page and an update prompt.
Mobile
- Capacitor
- The Android app, and an iPhone build, from the same web app (Capacitor 7).
- Electron
- Desktop builds for Windows and macOS.
Backend
- FastAPI
- The API: 55 endpoints, plus server-rendered pages for link previews.
- Python
- Backend language; one asyncio loop runs the five background jobs.
- PyJWT and bcrypt
- Optional user accounts and admin sign-in.
Data
- MongoDB
- Charts stored as YouTube returns them, hourly snapshots, quota counters and accounts (MongoDB 7).
Integrations
- YouTube Data API v3
- Source of every chart, called through the quota ledger.
Infrastructure
- Docker
- Docker Compose runs MongoDB, the API and nginx.
- nginx
- Serves the app and sends link-preview bots to server-rendered video pages.
- GitHub Actions
- Deploys to the server over SSH.
In numbers
Facts about the build.
- countries covered
- 53
- quota budgets: 3,000 / 4,500 / 2,000 units
- 3
- units a day for chart sweeps, instead of ~51,000
- ~1,600
- API endpoints
- 55
Building something like TrendingZ?
Tell us what you are working on. A person from Dessot will reply.


