nafi@portfolio:~$
bash — ~/projects/currency-api
$cd ~/projects/currency-api && cat summary.txt
Automated real-time currency tracking API — Python FastAPI service scraping live exchange rates every 60 minutes, storing historical data in SQLite, serving REST endpoints for latest rates and time-series queries.

REAL-TIME CURRENCY API

Backend Developer · #7c1b408 backend
Python · FastAPI · SQLite github.com/sleepyhead000
~/projects/currency-api $

cat README.md

README.md
$cat overview.txt
Built an end-to-end pipeline that ingests live currency fluctuations from multiple public sources, normalizes them into a canonical schema, and exposes them via a fast REST API. The system runs autonomously on a 60-minute cron loop with exponential backoff retries and structured logging.
$cat scraper.txt
Scraper module uses httpx with connection pooling and timeout budgets. Parses HTML tables and JSON feeds from 4 primary sources. Implements selector fallback chains — if primary DOM structure changes, secondary selectors take over automatically. Rate-limited to 1 req/sec per domain with jitter.
$cat storage.txt
SQLite database with WAL mode for concurrent reads. Schema: currencies (code, name, symbol), rates (currency_id, rate, source, fetched_at), snapshots (daily aggregates). Indexed on (currency_id, fetched_at) for O(log n) time-range queries. Vacuum runs weekly via cron.
$cat api.txt
FastAPI endpoints: GET /rates/latest?base=USD, GET /rates/history?from=2024-01-01&to=2024-01-31, GET /currencies. Response times < 50ms p99 on cold start. OpenAPI docs auto-generated at /docs. CORS configured for browser clients.
~/projects/currency-api $

ls -l features/

scheduler
APScheduler cron (60 min interval) · exponential backoff · jitter
sources
4 public feeds (HTML tables + JSON) · selector fallbacks · rate limiting
storage
SQLite WAL · indexed time-series · weekly vacuum · 2+ years retention
api
FastAPI · OpenAPI docs · CORS · < 50ms p99 latency
observability
Structured JSON logs · Prometheus metrics endpoint · health checks
reliability
Retry with circuit breaker · dead-letter queue · manual re-run CLI
~/projects/currency-api $

cat stack.yaml

language
Python 3.11+
framework
FastAPI + Uvicorn
scheduler
APScheduler (BackgroundScheduler)
http
httpx (async client + connection pool)
database
SQLite (WAL mode, aiosqlite)
validation
Pydantic v2 (request/response models)
logging
structlog + stdlib logging (JSON output)
~/projects/currency-api $

git log --oneline

#a1b2c3dfeat/scraper

Multi-source scraper with fallback selectors

Python · httpx · BeautifulSoup4
  • Abstract base scraper class; 4 concrete implementations for each source.
  • Selector chains: primary → secondary → tertiary; auto-promotion on success.
  • Per-domain rate limiter (token bucket) with configurable capacity.
#b2c3d4efeat/storage

SQLite schema & migration system

SQLite · aiosqlite · alembic-lite
  • Normalized schema: currencies, rates, snapshots tables with FK constraints.
  • Composite index on (currency_id, fetched_at DESC) for fast history lookups.
  • Lightweight migration runner (no heavy ORM) applying versioned SQL files.
#c3d4e5ffeat/api

FastAPI REST layer with caching

FastAPI · Pydantic · Redis (optional)
  • /rates/latest: in-memory LRU cache (TTL 30s) for hot base currencies.
  • /rates/history: cursor-based pagination; supports CSV export param.
  • Request validation + automatic OpenAPI schema at /docs and /redoc.
#d4e5f6aops/scheduler

Resilient cron loop with observability

APScheduler · structlog · Prometheus client
  • Job misfire grace time 10 min; coalesce=True to skip stacked runs.
  • Metrics: scrape_duration_seconds, scrape_success_total, rate_staleness_seconds.
  • Health endpoint /healthz checks DB connectivity + last successful scrape age.
#e5f6a7bops/deploy

Containerized deployment

Docker · GitHub Actions · systemd (VM) / Fly.io
  • Multi-stage Dockerfile: builder → runtime (distroless python).
  • GitHub Actions: lint → test → build → push to GHCR → deploy.
  • systemd unit with restart=on-failure; log rotation via journald.