# pratapram/gcp_code_samples architecture

> Architecture diagram of the GitHub repository pratapram/gcp_code_samples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pratapram/gcp_code_samples
- Repository: https://github.com/pratapram/gcp_code_samples

## Overview

This repository is a collection of independent AI/ML sample projects, not a single integrated application. The top level is mostly a catalog of self-contained demos, each with its own runtime, dependencies, and entrypoint.

1. Repository structure
- The repo is organized by sample domain: `autocomplete`, `design_patterns/router`, `langchainrag`, and `bigqueryml/propensity`.
- There is no shared application layer or common library visible across these folders.
- For an architecture diagram, treat each subfolder as a separate system unless you intentionally want to show them as examples grouped under one repo.

2. `autocomplete` sample
- This is a Python web app with a server-rendered HTML template in `templates/autocomplete.html` and an app entrypoint in `main.py`.
- The architecture is likely a simple request/response flow: browser UI submits input, the Python backend computes or serves autocomplete suggestions, and the template renders the result.
- The key boundary here is between the browser-facing UI and the Python service logic.

3. `design_patterns/router`
- This is a containerized Python service (`Dockerfile`, `main.py`, `requirements.txt`) that appears to demonstrate a router pattern.
- `searchpythonapi.py` suggests an internal adapter or client module used by the router to forward requests to a search-related API or service.
- The main architectural idea is request routing: inbound request lands in `main.py`, which dispatches to a specialized integration module.

4. `langchainrag`
- This is another containerized Python application focused on retrieval-augmented generation (RAG) using LangChain.
- The app entrypoint is `main.py`, with packaging via `Dockerfile` and `requirements.txt`.
- The data flow is typically: user query in, retrieval over indexed context/documents, LLM synthesis, response out. The important boundary is between retrieval and generation.

5. `bigqueryml/propensity`
- This sample is notebook-driven rather than service-driven: `Propensity_Pipeline.ipynb` is the main artifact.
- It uses BigQuery ML as the execution environment for the modeling pipeline.
- The architecture is analytics-centric: data lives in BigQuery, the notebook orchestrates feature/model steps, and the output is a propensity model or scored dataset rather than a deployed API.

6. Cross-cutting packaging and deployment style
- `requirements.txt` appears in the Python-based samples, indicating isolated dependency sets per project.
- `Dockerfile` is present where the sample is meant to run as a containerized service.
- The notebook sample is the exception: it is meant for interactive analysis and managed warehouse execution rather than a long-running app container.

7. Main architectural boundaries
- UI boundary: `autocomplete` exposes a browser-facing HTML template.
- API/routing boundary: `design_patterns/router` handles request dispatch and backend integration.
- LLM pipeline boundary: `langchainrag` separates retrieval from generation.
- Data/ML boundary: `bigqueryml/propensity` keeps modeling inside BigQuery ML and a notebook workflow.

8. External systems that matter
- BigQuery is a real external platform dependency for the propensity sample.
- The LangChain RAG sample likely depends on an LLM backend and some retrieval store, though the exact provider is not visible from the file tree.
- The router sample appears to integrate with a search API via `searchpythonapi.py`.

9. How to draw it
- Draw four disconnected subgraphs under a single repo umbrella.
- Show `autocomplete` as a web app with browser-to-Python-to-template flow.
- Show `design_patterns/router` as a request router plus downstream search adapter.
- Show `langchainrag` as a RAG pipeline with retrieval feeding generation.
- Show `bigqueryml/propensity` as a notebook orchestrating BigQuery ML rather than a service.

Overall, the repo is best understood as a set of architecture examples demonstrating different AI/ML execution patterns: web UI, router/API design, RAG, and warehouse-native ML.

Main entry points: [`autocomplete/main.py`](https://github.com/pratapram/gcp_code_samples/blob/main/autocomplete/main.py) (Autocomplete app), [`design_patterns/router/main.py`](https://github.com/pratapram/gcp_code_samples/blob/main/design_patterns/router/main.py) (Router service), [`design_patterns/router/searchpythonapi.py`](https://github.com/pratapram/gcp_code_samples/blob/main/design_patterns/router/searchpythonapi.py) (Search adapter), [`bigqueryml/propensity/Propensity_Pipeline.ipynb`](https://github.com/pratapram/gcp_code_samples/blob/main/bigqueryml/propensity/Propensity_Pipeline.ipynb) (Pipeline notebook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo_catalog["Repo samples"]
  node_repo["Samples repo<br/>catalog"]
end

subgraph group_autocomplete["Autocomplete"]
  node_autocomplete_ui["Browser UI<br/>web client<br/>[autocomplete.html]"]
  node_autocomplete_app["Autocomplete app<br/>python app<br/>[main.py]"]
  node_autocomplete_templates["Template view<br/>html template<br/>[autocomplete.html]"]
end

subgraph group_router["Router pattern"]
  node_router_app["Router service<br/>python service<br/>[main.py]"]
  node_router_adapter["Search adapter<br/>integration module<br/>[searchpythonapi.py]"]
  node_router_api["Search API<br/>external service"]
end

subgraph group_langchainrag["LangChain RAG"]
  node_rag_app["RAG app<br/>python service<br/>[main.py]"]
  node_rag_query["Query intake<br/>request handler<br/>[main.py]"]
  node_rag_retriever["Retriever<br/>retrieval stage"]
  node_rag_store[("Context store<br/>index/store")]
  node_rag_generator["Generator<br/>generation stage"]
  node_rag_llm["LLM backend<br/>external model"]
end

subgraph group_propensity["Propensity ML"]
  node_propensity_notebook["Pipeline notebook<br/>notebook pipeline"]
  node_bigquery[("BigQuery<br/>warehouse platform")]
  node_scored_output["Scored output<br/>model artifact"]
end

node_repo -.->|"contains"| node_autocomplete_app
node_repo -.->|"contains"| node_router_app
node_repo -.->|"contains"| node_rag_app
node_repo -.->|"contains"| node_propensity_notebook
node_autocomplete_ui -->|"submit"| node_autocomplete_app
node_autocomplete_app -->|"render"| node_autocomplete_templates
node_router_app -->|"dispatch"| node_router_adapter
node_router_adapter -->|"call"| node_router_api
node_rag_query -->|"retrieve"| node_rag_retriever
node_rag_retriever -->|"lookup"| node_rag_store
node_rag_retriever -->|"pass context"| node_rag_generator
node_rag_generator -->|"invoke"| node_rag_llm
node_propensity_notebook -->|"run on"| node_bigquery
node_bigquery -->|"produce"| node_scored_output

click node_autocomplete_ui "https://github.com/pratapram/gcp_code_samples/blob/main/autocomplete/templates/autocomplete.html"
click node_autocomplete_app "https://github.com/pratapram/gcp_code_samples/blob/main/autocomplete/main.py"
click node_autocomplete_templates "https://github.com/pratapram/gcp_code_samples/blob/main/autocomplete/templates/autocomplete.html"
click node_router_app "https://github.com/pratapram/gcp_code_samples/blob/main/design_patterns/router/main.py"
click node_router_adapter "https://github.com/pratapram/gcp_code_samples/blob/main/design_patterns/router/searchpythonapi.py"
click node_rag_app "https://github.com/pratapram/gcp_code_samples/blob/main/langchainrag/main.py"
click node_rag_query "https://github.com/pratapram/gcp_code_samples/blob/main/langchainrag/main.py"
click node_propensity_notebook "https://github.com/pratapram/gcp_code_samples/blob/main/bigqueryml/propensity/Propensity_Pipeline.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_repo toneBlue
class node_autocomplete_ui,node_autocomplete_app,node_autocomplete_templates toneAmber
class node_router_app,node_router_adapter,node_router_api toneMint
class node_rag_app,node_rag_query,node_rag_retriever,node_rag_store,node_rag_generator,node_rag_llm toneRose
class node_propensity_notebook,node_bigquery,node_scored_output toneIndigo
```

## Components

### Repo samples

Top-level catalog of independent AI/ML samples

- **Samples repo**: catalog · Umbrella for independent demos

### Autocomplete

Browser-driven Python sample

- [Browser UI](https://github.com/pratapram/gcp_code_samples/blob/main/autocomplete/templates/autocomplete.html): web client · User-facing autocomplete form · `autocomplete/templates/autocomplete.html`
- [Autocomplete app](https://github.com/pratapram/gcp_code_samples/blob/main/autocomplete/main.py): python app · Serves requests and computes suggestions · `autocomplete/main.py`
- [Template view](https://github.com/pratapram/gcp_code_samples/blob/main/autocomplete/templates/autocomplete.html): html template · Renders autocomplete results · `autocomplete/templates/autocomplete.html`

### Router pattern

Containerized request-routing sample

- [Router service](https://github.com/pratapram/gcp_code_samples/blob/main/design_patterns/router/main.py): python service · Entry point for routed requests · `design_patterns/router/main.py`
- [Search adapter](https://github.com/pratapram/gcp_code_samples/blob/main/design_patterns/router/searchpythonapi.py): integration module · Forwards requests to search backend · `design_patterns/router/searchpythonapi.py`
- **Search API**: external service · Downstream search target

### LangChain RAG

Retrieval-augmented generation sample

- [RAG app](https://github.com/pratapram/gcp_code_samples/blob/main/langchainrag/main.py): python service · LangChain retrieval and generation app · `langchainrag/main.py`
- [Query intake](https://github.com/pratapram/gcp_code_samples/blob/main/langchainrag/main.py): request handler · Accepts user prompts · `langchainrag/main.py`
- **Retriever**: retrieval stage · Finds supporting context
- **Context store**: index/store · Retrieved documents or embeddings
- **Generator**: generation stage · Composes answer from context
- **LLM backend**: external model · Language model used for synthesis

### Propensity ML

Notebook-driven BigQuery ML sample

- [Pipeline notebook](https://github.com/pratapram/gcp_code_samples/blob/main/bigqueryml/propensity/Propensity_Pipeline.ipynb): notebook pipeline · Orchestrates modeling steps in BigQuery · `bigqueryml/propensity/Propensity_Pipeline.ipynb`
- **BigQuery**: warehouse platform · Execution and data platform for BQML
- **Scored output**: model artifact · Propensity model or scored dataset

## Connections

- Samples repo → Autocomplete app: contains · Repository includes the autocomplete sample
- Samples repo → Router service: contains · Repository includes the router sample
- Samples repo → RAG app: contains · Repository includes the RAG sample
- Samples repo → Pipeline notebook: contains · Repository includes the BigQuery ML sample
- Browser UI → Autocomplete app: submit · Browser submits input to backend
- Autocomplete app → Template view: render · Backend renders HTML response
- Router service → Search adapter: dispatch · Router forwards request to adapter
- Search adapter → Search API: call · Adapter sends downstream search request
- Query intake → Retriever: retrieve · Query is used to fetch context
- Retriever → Context store: lookup · Retriever searches indexed context
- Retriever → Generator: pass context · Retrieved evidence is handed to generation
- Generator → LLM backend: invoke · Generator calls the model backend
- Pipeline notebook → BigQuery: run on · Notebook orchestrates warehouse-native ML
- BigQuery → Scored output: produce · BigQuery ML emits model or scored results
