How liuyuwei/google-adk-server-example works
Project Type and Purpose
• Type: A single-service backend application (no separate frontend) built with Python/FastAPI and containerized with Docker.
• Purpose: Demonstrate how to expose Google ADK (GenAI or Vertex AI) functionality over an HTTP API.
File Structure
• Top-level:
– Dockerfile (builds container)
– .env.template / .env (environment variables for API keys & configuration)
– requirements.txt (Python dependencies)
– app/agent.py (FastAPI app + business logic)
• No separate “frontend” or “database” directories; this is a stateless microservice.
• README.md describes runtime steps, environment variables, and endpoints (/docs via SwaggerUI).
README for Insights
• Shows bootstrapping steps (copy .env, set GOOGLE_API_KEY or VertexAI vars).
• Indicates the main entrypoint is the FastAPI server (invoked via adk api_server in Docker).
• Exposes port 8000 for HTTP clients.
Main Components & Interactions
1. HTTP Client / Consumer (e.g., curl, a frontend app, or SwaggerUI)
2. Docker Host (your machine or cloud VM)
3. Docker Container
• Entrypoint: adk api_server → FastAPI application
• Configuration: .env (mapped via --env-file)
• Code: app/agent.py (defines endpoints & GenAI calls)
• Dependencies: Python runtime + libraries (requirements.txt)
4. External Service: Google GenAI API or Vertex AI endpoint
b. Interactions:
1. Client → HTTP request → FastAPI endpoint
2. FastAPI parses request, loads API key from environment
3. Agent logic invokes Google’s ADK SDK over HTTPS
4. Google GenAI or Vertex AI returns response
5. FastAPI returns results to client
Architectural Patterns & Design Principles
• Microservice: Stateless service behind a single HTTP interface.
• 12-factor app: Config via environment variables; logs to stdout/stderr.
• Containerization: Isolate runtime, dependencies, and deployment.
• Single responsibility: app/agent.py solely handles request routing and SDK calls.