Inspiration

Teams burn through AWS Marketplace AI credits (Bedrock model access, third-party inference) with zero early warning. AWS Cost Explorer shows what you've already spent — not what's about to run out, and not how fast burn rate is accelerating. By the time finance notices, an agent loop or feature launch may have already tripled daily spend. We wanted a tool that watches the trend and tells you the date — not just the dollar amount.

What it does

AI Spend Sentinel ingests AI/Marketplace cost data alongside credit grant records, then for every team or scope it:

  • Calculates the 7-day rolling average burn rate
  • Compares it against the prior 7-day window to detect acceleration (burn rate spiking, not just high)
  • Projects the exact exhaustion date for remaining credit
  • Assigns a severity level (ok / warning / critical) based on days remaining and whether burn is accelerating
  • Surfaces everything on a live dashboard — one card per team, a burn-rate chart, and a prominent critical banner

In the demo, Team A (Anthropic Claude via Bedrock Marketplace) shows an accelerating burn heading toward exhaustion in days. Team B (Cohere via Bedrock Marketplace) stays steady. The contrast proves the model works.

How we built it

  • Database: AWS Aurora PostgreSQL (Serverless v2) — two tables: credit_ledger (grants, provider, scope, status) and cost_lines (daily CUR-shaped spend records)
  • Backend: Next.js API route (/api/projection) querying Aurora via the pg driver, running burn-rate and exhaustion-date logic server-side
  • Core algorithm: compares two trailing 7-day spend windows to flag acceleration, then projects forward from remaining credit to a calendar exhaustion date
  • Seeding: synthetic CUR-shaped data generator producing two contrasting scenarios — one team with a burn-rate spike, one steady — so both severity states are visible without real usage data
  • Frontend: dashboard built with v0.app on Next.js + Tailwind, fetching from /api/projection and rendering per-team cards, a recharts burn-rate line chart, and a critical-state banner
  • Deploy: GitHub → Vercel, with Aurora connection string as an environment variable

Challenges we ran into

The toughest bugs weren't algorithmic — they were environment plumbing:

  • The phantom env var. Running set DATABASE_URL=... in a terminal worked once — but the variable was never written to disk, so the Next.js dev server had no way to see it and every API call silently fell back to localhost:5432
  • 404 before 500. The /api/projection route didn't exist yet when we first tested. A plain 404 became a 500 once the route was created — progress, but a reminder to verify file structure before debugging logic
  • Next.js loads .env.local automatically — plain Node scripts don't. Our standalone seed.js kept throwing ECONNREFUSED even after the API route returned 200. The fix was explicitly loading the env file at the top of every standalone script
  • Cross-origin dev warnings. Running the dev server on a network IP for cross-device testing triggered Next.js's allowedDevOrigins protection

Each was a one-line fix once diagnosed — but diagnosing "why does my code work in one terminal and not another" under deadline pressure was its own challenge.

Accomplishments that we're proud of

  • A clean, working burn-rate acceleration detector that catches spend spikes before they become invoices
  • A real Aurora PostgreSQL integration with a deliberate credit ledger schema — not a generic cost dashboard bolted onto a generic DB
  • Correctly identifying and building around a genuine AWS monitoring gap: Marketplace-billed AI spend is explicitly excluded from AWS Cost Anomaly Detection

What we learned

  • .env.local is magic only inside Next.js's own dev/build process — every standalone script needs its own explicit env loader
  • Terminal session state (set VAR=value) is invisible and process-scoped — never a substitute for a persisted config file
  • Burn-rate acceleration (comparing two trailing windows) is more actionable than a static "total remaining" metric — knowing your fuel gauge is dropping faster than yesterday is more urgent than knowing you're at 30%
  • AWS Marketplace AI billing genuinely has a monitoring gap that native tools don't cover well

What's next for AI Spend Sentinel

  • Live AWS Cost Explorer ingestion via cross-account IAM role assumption — so real teams can connect their own AWS account without sharing credentials
  • Per-vendor breakdown using CUR 2.0 via S3/Athena — distinguishing Anthropic vs Cohere vs other Marketplace vendors within the same billing surface
  • Slack/email webhook alerts firing automatically when a scope crosses the warning or critical threshold
  • Multi-account support — one dashboard watching credits across an entire organization's AWS accounts

Built With

  • awsaurora
  • awsserverless
  • next.js
  • react
  • tailwindcss
  • vercel
Share this project:

Updates

Submission history