Interface
Architecture
System design and data flow for Interface
Interface is a Python 3.13 FastAPI service that sits between the Bubble app and Cloud Spanner, exposing a read-mostly HTTP API.
System context
Bubble app ---> Interface (FastAPI) ---> Cloud Spanner
|-> Secret Manager (API key, Sentry DSN)
|-> Sentry (errors + traces)Request flow
- Bubble sends a request with the
X-API-Keyheader. APIKeyMiddlewarevalidates the header (health checks are exempt).- The endpoint builds parameterized Spanner SQL using
QueryBuilder. - Spanner executes a read-only transaction and returns rows.
- Results are mapped to Pydantic models and returned as JSON.
Write exceptions
Interface is read-mostly. The only write paths are legacy updates for appointment types and appointment statuses.
Components
services/interface/main.py: app setup, middleware, CORS, Spanner lifecycle.services/interface/routers/: API version routing (v1 and v2).services/interface/api/: endpoint implementations.services/interface/core/query_builder.py: query assembly and parameter binding.services/interface/models/: request/response models.services/interface/middleware/api_key_middleware.py: API key enforcement.packages/python/common/: Spanner client and Secret Manager helpers.
Reliability and scaling
- Spanner pool is warmed at startup and cleared on shutdown.
- The production container runs
granianwith a single worker by default. - Changes must preserve response shapes and pagination semantics due to legacy clients.
Last updated on