Skip to content

ADR-PROTO-003: SQL generator runs in FastAPI, not API Gateway + Lambda

Status: Accepted Source: prd-v2.1.md §C.8

Context

Original design proposed AWS API Gateway → Lambda → Bedrock → Databricks. That's ~200 lines of packaging + IAM + cold-start latency. The existing FastAPI process already has a Bedrock client (per ADR-005) and runs in the same container as the widget data resolver.

Decision

SQL generation is a module inside backend/app/sql_gen/ called directly by the data resolver. No new AWS infrastructure. ~50 lines of integration vs ~200+ for Lambda packaging.

Consequences

  • One process, one deployment, one set of logs to debug during the 1-day build.
  • Reuses existing Bedrock client, error handling, rate limiting.
  • Cold-start latency eliminated.
  • If a future use case needs the SQL generator from a different runtime (e.g. a Slack bot), it can be lifted to its own service later — not a 1-day concern.

Cross-references