Overview
The MABQ BigQuery Agent backend is built with FastAPI and integrates the Google ADK (Agent Development Kit) to provide a conversational interface for BigQuery data analysis.Application Configuration
The FastAPI app is configured with strict CORS policies and security middleware.CORS Middleware
The application enforces strict CORS to allow only authorized frontend origins:Single frontend URL from environment variable
FRONTEND_URLEnables cookie and authorization header support
All HTTP methods allowed
All headers allowed for authenticated requests
Endpoints
ADK Agent Endpoint
The main conversational agent endpoint is registered at the root path by the ADK framework.Root path where the ADK agent is mounted
Uses in-memory session storage for conversation state
Response Format
The ADK endpoint returns agent responses in a streaming or JSON format depending on the client configuration.Agent’s response to the user query
Generated SQL query (when applicable)
Query results from BigQuery (when executed)
Documentation Endpoints
FastAPI automatically generates interactive API documentation:- Swagger UI:
/docs - ReDoc:
/redoc - OpenAPI Schema:
/openapi.json
Security Middleware
All endpoints (except/docs, /openapi.json, and GET requests to /) are protected by the authentication middleware. See Authentication for details.
The middleware exempts OPTIONS requests and specific paths for development and root access (see main.py:34-37).
Running the Server
The application runs with Uvicorn on port 8000:Binds to all network interfaces for container deployment
HTTP port for the FastAPI application
Environment Variables
Authorized frontend origin for CORS
Azure AD tenant ID for JWT validation
Azure AD application client ID (audience)
Example Deployment
Related Documentation
- Agent Interface - Learn about the underlying BigQuery agent
- Authentication - Understand the security model
- CopilotKit Endpoint - Frontend integration