Google Cloud architecture template
RAG chat app on Google Cloud
Retrieval-augmented generation on Google Cloud: Cloud Run chat API, Gemini models and embeddings, AlloyDB pgvector search.
Free to start. Updated .

When to use it
Use this template when you want a chat assistant that answers from your own documents instead of only from what the model was trained on. The ingestion side is event driven: a document lands in Cloud Storage, Eventarc triggers a Cloud Run job, and the job splits the text into chunks, embeds them with a Gemini embedding model and upserts the vectors into AlloyDB with the pgvector extension. At question time the chat API on Cloud Run embeds the query, runs a similarity search in AlloyDB, and sends the best matching chunks to Gemini as context for the answer.
The quality of the answers depends more on chunking, metadata and retrieval than on the model, so log which chunks each answer used. AlloyDB keeps vectors next to your relational data and permissions. If you would rather not run a database, Vertex AI Vector Search or a managed RAG engine trades control for less to operate. Store database credentials in Secret Manager.
What's in this template
User / ActorChat users
Cloud RunChat API (retrieve, then generate)
Gemini Enterprise Agent PlatformGemini model and text embeddings
AlloyDBAlloyDB with pgvector
Cloud RunIngestion job: chunk and embed
EventarcObject finalized trigger
Cloud StorageSource documents
Secret ManagerDatabase credentials
How it connects
- User / Actor → Cloud Run (Chat API (retrieve, then generate)) (api): HTTPS
- Cloud Run (Chat API (retrieve, then generate)) → Gemini Enterprise Agent Platform (api): Embed query, generate answer
- Cloud Run (Chat API (retrieve, then generate)) → AlloyDB (data): Similarity search
- Cloud Run (Chat API (retrieve, then generate)) → Secret Manager (dependency): Credentials
- Cloud Storage → Eventarc (dependency): New object
- Eventarc → Cloud Run (Ingestion job: chunk and embed) (api): Invoke
- Cloud Run (Ingestion job: chunk and embed) → Cloud Storage (data): Read document
- Cloud Run (Ingestion job: chunk and embed) → Gemini Enterprise Agent Platform (api): Embed chunks
- Cloud Run (Ingestion job: chunk and embed) → AlloyDB (data): Upsert vectors
More Google Cloud templates
Make it your own
Open a copy in the editor, then rename, rearrange and extend it.

