Resilient Crypto Tracker: API Resilience & Headless Test Architecture
A real-time financial tracking dashboard engineered to survive aggressive third-party HTTP 429 rate limits through transient caching, exponential jitter retry backoffs, and automated headless Streamlit AppTest assertions.
1. Problem Statement: Public API Quota Exhaustion
Public cryptocurrency APIs (such as CoinGecko) enforce strict tier-based rate limits (frequently 10 to 30 requests per minute). When users rapidly switch currency pairs or adjust time-series aggregations, naive web applications quickly trigger HTTP 429 (Too Many Requests) errors, resulting in broken charts and degraded user experience.
2. Resilience Architecture: Jitter & Transient Cache
To eliminate quota exhaustion, the application implements two coordinated defensive layers:
TTL-Bounded In-Memory Cache
Caches historical OHLCV dataframes with a 60-second sliding TTL, preventing redundant API calls for recently requested ticker symbols.
Decorated Exponential Retry
Intercepts HTTP 429 and connection timeout responses, retrying with exponential backoff T = min(M, B · 2ⁱ) + jitter before failing gracefully.
3. Headless Verification with Streamlit AppTest
Unlike standard Streamlit scripts that lack test coverage, this project utilizes the headless Streamlit AppTest framework:
- Simulates headless user interactions (selecting currency dropdowns, toggling timeframes).
- Asserts that mock API errors render clean warning banners rather than unhandled Python tracebacks.
- Verifies that dataframes passed to Plotly charting components contain non-null price series.