Real-time quotes fail in the wild. We designed a tiny edge-cached fallback layer so P/L stays fresh.
Problem
Free APIs rate-limit or go down. Users see zeros. Bad.
Approach
-
Client: requests
/prices
with a compact symbol list - Edge function: tries Provider A → B → C with timeouts
-
Envelope: we always return
{price, ts, source, fallbackUsed}
- Cache: hot-ticker TTL on the edge; cold paths bypass
- DX: dev overlay shows which source resolved
ts
type Quote = { s: string; p: number; ts: number; src: string; fb?: boolean }
## Trade-offs
**Slightly higher p99 latency, vastly better success rate**
**Deterministic error surfaces → easier bug reports**
## Help wanted (good first issues)
**Add provider health telemetry**
**Better batching for thin symbols**
**Unit tests for error envelopes**
## Repo → https://github.com/PocketPortfolio/Financialprofilenetwork
## Discord → link on the site (Office Hours: Wednesdays)
What would you improve in this design? PRs welcome.
Top comments (0)