Architecture¶

If the image appears blurry, you can view the high‑resolution SVG version here:
View Architecture Diagram (SVG)
Summary¶
DriftSpend follows a simple, serverless-first flow:
Daily ingestion → compact snapshot store → weekly aggregation → email reports + dashboard + read API.
The system is minimal. Each part does one thing well. Components communicate using stable, lightweight JSON + key/value service/day records.
Components¶
Collector (Daily)¶
- Queries AWS Cost Explorer (last 7 days daily granularity).
- Normalizes data into per-day service/region records.
- Stores raw normalized JSON in S3 (
reports/raw/YYYY-MM-DD.json). - Stores per-service items in DynamoDB (partition key = date, sort key = service).
- Designed to be cheap, fast, and resilient to throttling (retry/backoff can be added later).
Snapshot Store¶
- Hybrid: S3 (immutable raw JSON) + DynamoDB (fast key/date lookups).
- S3 provides audit-friendly, append-only history.
- DynamoDB accelerates “latest snapshot” and potential service trend queries.
- Clear separation: ingestion writes; reporting/reader only read.
Reporting Engine (Weekly)¶
- Reads the last 7 days from S3 (raw authoritative source).
- Computes totals, per-service and per-region breakdowns, projections (30d / 90d, min/max range).
- Renders mobile-friendly HTML (Jinja2 template with dark mode).
- Sends report via SES.
- Publishes dashboard HTML to S3 (run-specific + latest path).
Read Service (API)¶
- Lambda + API Gateway.
- Fetches latest snapshot quickly from DynamoDB (no recomputation).
- Returns compact JSON for external consumers or dashboards.
Dashboard (Static)¶
- HTML/CSS/JS served via CloudFront (OAC) or direct S3 (private + signed URLs if needed).
- Displays latest weekly summary plus derived metrics.
- Zero compute on read, globally cached.
Why It Works¶
DriftSpend is intentionally lean:
- Serverless-first: Pay only per execution.
- Immutable snapshots: Reporting never depends on re-querying Cost Explorer.
- Separation of concerns: Ingestion, storage, reporting, presentation decoupled.
- Extensible: Can layer anomaly detection, multi-account, tag dimensions.
- Secure by design: Private S3, least-privilege IAM, CloudFront OAC for dashboard.
Operational overhead stays near zero while providing clear weekly spend visibility.
AWS Cost Notes¶
DriftSpend operates almost entirely within the AWS Free Tier:
- DynamoDB PAY_PER_REQUEST usage is tiny (1 partition write per service/day + simple queries).
- S3 footprint: ≤ a few KB per daily JSON + one HTML per report.
- Lambda + API Gateway invocations are low volume.
- SES: single weekly outbound email (well within free tier).
- Cost Explorer queries are free.
- CloudFront typically stays in free tier for low internal access.
DynamoDB and Lambda often report €0 due to minimal metered usage. If volume grows (more regions, multi-account, higher email distribution), incremental costs will surface automatically.