AWS cost aggregation and recommendation engine for multi-team organizations.
Ingests AWS billing CSVs (monthly or on-demand), aggregates costs by service/team/environment, and generates 4 types of cost optimization recommendations: idle resource detection, storage class optimization, instance right-sizing, and reserved instance candidates.
CSV Ingestion & Parsing — Python batch worker parses both CUR (Cost and Usage Report) and simplified billing CSV formats. Supports AWS standard columns (date, service, region) plus custom tags (team, project, environment, resource_id).
(worker/csv_parser.py)
Cost Aggregation — Daily and monthly cost rollups grouped by:
- Service (EC2, S3, RDS, Lambda, etc.)
- Team (via tag)
- Environment (production, staging, dev, via tag)
- Region (optional)
Computed aggregations stored in Supabase PostgreSQL.
(worker/aggregator.py)
Recommendation Engine — Analyzes aggregated spend and generates 4 recommendation types:
- Idle Resources — Services with zero usage hours over lookback window
- Storage Optimization — S3 storage classes + EBS volume consolidation
- Right-Sizing — High-cost services with low utilization (compute instances, RDS)
- Reserved Instances — Steady workloads eligible for RI purchases (cost/benefit analysis)
Each recommendation includes: estimated monthly savings, implementation effort, confidence score.
(worker/recommendation_engine.py)
Multi-Tenant Isolation — Supabase PostgreSQL with Row-Level Security (RLS) policies. Each user sees only their organization's costs and recommendations.
(supabase/migrations/ — RLS policies on costs, recommendations, budgets tables)
Budget Alerts — Set per-service/per-team/per-environment cost thresholds. Alerts via email (Resend integration) when budget exceeded.
(supabase/functions/send-budget-alert.ts)
Dashboard — React 18 + Recharts visualization:
- Daily/monthly cost trends by service
- Service-level cost breakdown
- Top-cost services ranking
- Budget consumption progress
- Recommendation list with implementation guidance
(src/pages/DashboardPage.tsx, src/components/CostTrendChart.tsx)
What-If Simulator — Model cost changes from configuration updates (storage class changes, instance downsizing, retention policy adjustments). Projects estimated savings.
(src/pages/SimulatorPage.tsx)
Stack — React 18, Vite, Supabase (PostgreSQL + Auth + Edge Functions), Python 3.9+ (pandas, psycopg2), Tailwind CSS, shadcn-ui, Recharts.
- Export AWS billing CSV → Download from AWS Cost Management or use Cost and Usage Reports (CUR)
- Load into SpendLens → Run Python worker:
python3 batch_aggregator.py billing.csv --org-id ORG_ID - Worker processes → Parser normalizes CSV → Aggregator computes daily/monthly rollups → Recommendation engine generates suggestions
- Data persists to Supabase → All team members see aggregated costs + recommendations via dashboard
- User sets budgets → Define per-service or per-team thresholds → Alerts trigger if exceeded
- Optimize → Review recommendations → Use simulator to model changes → Update cloud infra
- Supabase account (PostgreSQL database)
- AWS billing CSV (export from AWS Cost Management or CUR)
- Python 3.9+ (local worker processing)
npm install
npm run dev # http://localhost:5173cd worker
pip install -r requirements.txt
cp .env.example .env
# Edit .env with Supabase connection string# Generate 30 days of synthetic billing data
python3 scripts/generate_sample_billing.py --days 30 --output billing.csv
# Process with worker
python3 batch_aggregator.py billing.csv --org-id demo-org
# Open dashboard: http://localhost:5173python3 batch_aggregator.py /path/to/your/billing.csv --org-id your-org-idParser supports two formats:
Simplified (recommended for testing):
date,service,cost,usage,unit,region,team,project,environment,resource_id
2024-01-15,EC2,125.50,100,Hours,us-east-1,backend,web-app,production,i-123456
2024-01-15,S3,45.20,500,GB-Month,us-west-2,data,analytics,production,
AWS CUR (standard format):
- Automatically detected and normalized by parser
- Supports all CUR columns + custom tags
# Frontend
npm run test
# Backend
cd worker
python3 -m pytest tests/npm run build
# Deploy to Vercel, Netlify, or any static host- GitHub Actions — Schedule CSV processing via Actions workflow
- Cron —
0 2 * * * python3 batch_aggregator.py /billing/latest.csv --org-id ORG_ID - Docker — Build and deploy worker as container with scheduled triggers
AWS Billing CSV
↓
Python Worker Pipeline
├─ csv_parser.py → Normalize CSV
├─ aggregator.py → Daily/monthly rollups
└─ recommendation_engine.py → Generate 4 recommendation types
↓
Supabase PostgreSQL (RLS-protected)
↓
React Dashboard
├─ Cost trends (Recharts)
├─ Service breakdown
├─ Budget alerts
└─ What-if simulator
- Row-Level Security — All tables (costs, recommendations, budgets) protected by RLS policies
- Multi-tenant isolation — Users see only their organization's data
- No secrets in git —
.envfile gitignored, credentials in Supabase Secrets Manager
MIT