# 05satyam/ai-ml architecture

> Architecture diagram of the GitHub repository 05satyam/ai-ml, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/05satyam/ai-ml
- Repository: https://github.com/05satyam/ai-ml

## Overview

#### 1. Repository Shape and Purpose
This is a curated Python learning/cookbook repository, not a single deployable product. Its primary units are Jupyter notebooks, Markdown guides, and independent demo applications covering ML, RAG, agents, MCP, observability, and interview preparation. The root `README.md` is the navigation entry point; most examples are launched interactively from notebooks or directly as Python modules.

#### 2. Executable Application Entry Points
A few directories contain service-like applications rather than notebooks:
- Multimodal RAG API: `demo_applications/advance_rag/multimodal-rag/app/main.py`, with HTTP routes in `demo_applications/advance_rag/multimodal-rag/app/api/routes.py`.
- Production-style RAG mock service: `interview-prep/rag_service_mock_prod/app/main.py`, orchestrated by `interview-prep/rag_service_mock_prod/app/pipeline.py`.
- MCP demos: `demo_applications/mcp_handson/mcp_server_demo/app.py` and `demo_applications/mcp_handson/hello_world_of_mcp/simple_mcp_server.py`.
- Standalone ML example: transformer training/inference through `demo_applications/simple_transformer_addition/train.py` and `demo_applications/simple_transformer_addition/inference.py`.

#### 3. RAG Pipeline Patterns
RAG is the most substantial application theme. The multimodal app separates configuration, embedding creation, retrieval, and answer orchestration:
- `demo_applications/advance_rag/multimodal-rag/app/core/config.py`
- `demo_applications/advance_rag/multimodal-rag/app/services/embeddings.py`
- `demo_applications/advance_rag/multimodal-rag/app/services/retriever.py`
- `demo_applications/advance_rag/multimodal-rag/app/services/rag_pipeline.py`

The expected flow is source documents/images → embeddings/indexing → retrieval → LLM-grounded response exposed by API routes. Sample PDF/image inputs are local under `demo_applications/advance_rag/multimodal-rag/data/`.

Other RAG variants are self-contained notebooks: hybrid/vector search under `demo_applications/simple-rag/`, graph RAG under `demo_applications/graph_based_applications/`, and corrective RAG in `demo_applications/advance_rag/CRAG/crag_code.ipynb`.

#### 4. Production-Style RAG Boundary
`interview-prep/rag_service_mock_prod/` is the clearest reference architecture for a deployable RAG backend. It decomposes request handling, schemas, knowledge ingestion, vector storage, retrieval, LLM calls, and cross-cutting concerns:
- API/application boundary: `interview-prep/rag_service_mock_prod/app/main.py`, `interview-prep/rag_service_mock_prod/app/schemas.py`
- Retrieval/data boundary: `interview-prep/rag_service_mock_prod/app/knowledge.py`, `interview-prep/rag_service_mock_prod/app/vectorstore.py`, `interview-prep/rag_service_mock_prod/app/retriever.py`
- Runtime controls: `interview-prep/rag_service_mock_prod/app/guardrails.py`, `interview-prep/rag_service_mock_prod/app/cache.py`, `interview-prep/rag_service_mock_prod/app/resilience.py`, `interview-prep/rag_service_mock_prod/app/tracing.py`

This layout makes external LLM, cache, vector-store, and tracing integrations replaceable behind local modules.

#### 5. Agent and MCP Implementations
Agent concepts are primarily taught through LangChain/LangGraph notebooks and citation-oriented agent cookbooks:
- `demo_applications/agent-patterns-cookbooks/cite_rag_agent/01_react_pdf_policy_qa.ipynb`
- `demo_applications/agent-patterns-cookbooks/cite_rag_agent/02_plan_and_execute_pdf_policy_qa.ipynb`
- `demo_applications/agent-patterns-cookbooks/cite_rag_agent/claim_verifier.py`

MCP examples establish a client/server and tool-hosting boundary. The richer server demo exposes separate echo, math, and GitHub-oriented servers, assembled from:
- `demo_applications/mcp_handson/mcp_server_demo/mounted_servers.py`
- `demo_applications/mcp_handson/mcp_server_demo/github_server.py`
- `demo_applications/mcp_handson/mcp_server_demo/math_server.py`

The policy-gated MCP agent adds tool-risk controls, LLM routing, tracing, and evaluation around potentially untrusted MCP tools: `demo_applications/mcp_handson/policy_gated_mcp_agent/agent/run_agent.py`, `agent/policy.py`, and `servers/evil_server.py`.

#### 6. Runtime, Infrastructure, and External Dependencies
Python is the material runtime; dependencies are scoped either at repository root (`requirements.txt`) or per executable demo, such as `demo_applications/advance_rag/multimodal-rag/requirements.txt` and `interview-prep/rag_service_mock_prod/requirements.txt`. The mock RAG service includes container/Kubernetes deployment artifacts in `interview-prep/rag_service_mock_prod/deploy/Dockerfile` and `deploy/k8s/deployment.yaml`, with autoscaling in `deploy/k8s/hpa.yaml`.

External services/frameworks represented by the examples include OpenAI-compatible LLM routing, Pinecone vector search, LangChain/LangGraph, LlamaIndex, MCP tool servers, and Arize Phoenix observability. These are educational integrations, not repository-wide mandatory infrastructure.

Main entry points: [`README.md`](https://github.com/05satyam/ai-ml/blob/main/README.md) (Repository guide), [`demo_applications/mcp_handson/policy_gated_mcp_agent/agent/run_agent.py`](https://github.com/05satyam/ai-ml/blob/main/demo_applications/mcp_handson/policy_gated_mcp_agent/agent/run_agent.py) (Policy-gated MCP agent), [`interview-prep/rag_service_mock_prod/app/main.py`](https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/main.py) (Service API), [`interview-prep/rag_service_mock_prod/app/pipeline.py`](https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/pipeline.py) (RAG pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Learning content"]
  node_readme["Repository guide<br/>navigation<br/>[README.md]"]
  node_rag_notebooks["RAG notebook variants<br/>notebooks"]
  node_citation_agents["Citation agent cookbooks<br/>notebooks"]
end

subgraph group_multimodal["Multimodal RAG demo"]
  node_mm_api["RAG API routes<br/>Python HTTP API<br/>[routes.py]"]
  node_mm_app["Multimodal app<br/>Python entry point<br/>[main.py]"]
  node_mm_pipeline["Answer pipeline<br/>RAG orchestration<br/>[rag_pipeline.py]"]
  node_mm_retriever["Retriever<br/>retrieval service<br/>[retriever.py]"]
  node_mm_embeddings["Embeddings and index<br/>embedding service<br/>[embeddings.py]"]
  node_mm_data[("PDF and image inputs<br/>local corpus")]
end

subgraph group_prod_rag["Production RAG mock"]
  node_prod_api["Service API<br/>Python entry point<br/>[main.py]"]
  node_prod_pipeline["RAG pipeline<br/>orchestration<br/>[pipeline.py]"]
  node_prod_retrieval["Knowledge and retrieval<br/>data-access layer<br/>[retriever.py]"]
  node_prod_controls["Runtime controls<br/>cross-cutting modules<br/>[guardrails.py]"]
  node_deployment{{"Container and Kubernetes<br/>deployment artifacts<br/>[deployment.yaml]"}}
end

subgraph group_mcp["MCP and agents"]
  node_mcp_servers["Mounted MCP servers<br/>tool host<br/>[mounted_servers.py]"]
  node_policy_agent["Policy-gated MCP agent<br/>agent entry point<br/>[run_agent.py]"]
  node_tool_policy["Tool risk policy<br/>agent policy<br/>[policy.py]"]
  node_untrusted_tool["Untrusted MCP tool<br/>demo tool server<br/>[evil_server.py]"]
end

node_readme -->|"indexes"| node_rag_notebooks
node_readme -->|"indexes"| node_citation_agents
node_readme -->|"indexes"| node_mm_app
node_readme -->|"indexes"| node_prod_api
node_mm_app -->|"serves"| node_mm_api
node_mm_api -->|"submits queries"| node_mm_pipeline
node_mm_pipeline -->|"retrieves context"| node_mm_retriever
node_mm_retriever -->|"searches index"| node_mm_embeddings
node_mm_data -->|"indexes"| node_mm_embeddings
node_prod_api -->|"handles requests"| node_prod_pipeline
node_prod_pipeline -->|"retrieves context"| node_prod_retrieval
node_prod_controls -.->|"guards and observes"| node_prod_pipeline
node_deployment -->|"deploys"| node_prod_api
node_policy_agent -->|"checks tool calls"| node_tool_policy
node_tool_policy -->|"gates access"| node_untrusted_tool
node_policy_agent -->|"uses MCP tools"| node_mcp_servers
node_citation_agents -.->|"teaches agent patterns alongside"| node_policy_agent

click node_readme "https://github.com/05satyam/ai-ml/blob/main/README.md"
click node_citation_agents "https://github.com/05satyam/ai-ml/blob/main/demo_applications/agent-patterns-cookbooks/cite_rag_agent/01_react_pdf_policy_qa.ipynb"
click node_mm_api "https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/api/routes.py"
click node_mm_app "https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/main.py"
click node_mm_pipeline "https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/services/rag_pipeline.py"
click node_mm_retriever "https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/services/retriever.py"
click node_mm_embeddings "https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/services/embeddings.py"
click node_prod_api "https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/main.py"
click node_prod_pipeline "https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/pipeline.py"
click node_prod_retrieval "https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/retriever.py"
click node_prod_controls "https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/guardrails.py"
click node_deployment "https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/deploy/k8s/deployment.yaml"
click node_mcp_servers "https://github.com/05satyam/ai-ml/blob/main/demo_applications/mcp_handson/mcp_server_demo/mounted_servers.py"
click node_policy_agent "https://github.com/05satyam/ai-ml/blob/main/demo_applications/mcp_handson/policy_gated_mcp_agent/agent/run_agent.py"
click node_tool_policy "https://github.com/05satyam/ai-ml/blob/main/demo_applications/mcp_handson/policy_gated_mcp_agent/agent/policy.py"
click node_untrusted_tool "https://github.com/05satyam/ai-ml/blob/main/demo_applications/mcp_handson/policy_gated_mcp_agent/servers/evil_server.py"

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_readme,node_rag_notebooks,node_citation_agents toneBlue
class node_mm_api,node_mm_app,node_mm_pipeline,node_mm_retriever,node_mm_embeddings,node_mm_data toneAmber
class node_prod_api,node_prod_pipeline,node_prod_retrieval,node_prod_controls,node_deployment toneMint
class node_mcp_servers,node_policy_agent,node_tool_policy,node_untrusted_tool toneRose
```

## Components

### Learning content

Notebook and guide-based cookbook material.

- [Repository guide](https://github.com/05satyam/ai-ml/blob/main/README.md): navigation · Root entry point to independent learning examples. · `README.md`
- **RAG notebook variants**: notebooks · Hybrid, graph, and corrective RAG exercises.
- [Citation agent cookbooks](https://github.com/05satyam/ai-ml/blob/main/demo_applications/agent-patterns-cookbooks/cite_rag_agent/01_react_pdf_policy_qa.ipynb): notebooks · ReAct and plan-and-execute policy QA lessons. · `demo_applications/agent-patterns-cookbooks/cite_rag_agent/01_react_pdf_policy_qa.ipynb`

### Multimodal RAG demo

Interactive API-backed multimodal retrieval example.

- [RAG API routes](https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/api/routes.py): Python HTTP API · `demo_applications/advance_rag/multimodal-rag/app/api/routes.py`
- [Multimodal app](https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/main.py): Python entry point · `demo_applications/advance_rag/multimodal-rag/app/main.py`
- [Answer pipeline](https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/services/rag_pipeline.py): RAG orchestration · `demo_applications/advance_rag/multimodal-rag/app/services/rag_pipeline.py`
- [Retriever](https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/services/retriever.py): retrieval service · `demo_applications/advance_rag/multimodal-rag/app/services/retriever.py`
- [Embeddings and index](https://github.com/05satyam/ai-ml/blob/main/demo_applications/advance_rag/multimodal-rag/app/services/embeddings.py): embedding service · `demo_applications/advance_rag/multimodal-rag/app/services/embeddings.py`
- **PDF and image inputs**: local corpus

### Production RAG mock

Deployable reference backend with replaceable integrations.

- [Service API](https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/main.py): Python entry point · Request boundary using local schemas. · `interview-prep/rag_service_mock_prod/app/main.py`
- [RAG pipeline](https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/pipeline.py): orchestration · `interview-prep/rag_service_mock_prod/app/pipeline.py`
- [Knowledge and retrieval](https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/retriever.py): data-access layer · Local ingestion, vector-store, and retrieval adapters. · `interview-prep/rag_service_mock_prod/app/retriever.py`
- [Runtime controls](https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/app/guardrails.py): cross-cutting modules · Guardrails, cache, resilience, and tracing wrap integrations. · `interview-prep/rag_service_mock_prod/app/guardrails.py`
- [Container and Kubernetes](https://github.com/05satyam/ai-ml/blob/main/interview-prep/rag_service_mock_prod/deploy/k8s/deployment.yaml): deployment artifacts · Container deployment with autoscaling manifest. · `interview-prep/rag_service_mock_prod/deploy/k8s/deployment.yaml`

### MCP and agents

Tool-server and policy-gated agent demonstrations.

- [Mounted MCP servers](https://github.com/05satyam/ai-ml/blob/main/demo_applications/mcp_handson/mcp_server_demo/mounted_servers.py): tool host · Composes echo, math, and GitHub-oriented tools. · `demo_applications/mcp_handson/mcp_server_demo/mounted_servers.py`
- [Policy-gated MCP agent](https://github.com/05satyam/ai-ml/blob/main/demo_applications/mcp_handson/policy_gated_mcp_agent/agent/run_agent.py): agent entry point · Routes tool use through policy, tracing, and evaluation. · `demo_applications/mcp_handson/policy_gated_mcp_agent/agent/run_agent.py`
- [Tool risk policy](https://github.com/05satyam/ai-ml/blob/main/demo_applications/mcp_handson/policy_gated_mcp_agent/agent/policy.py): agent policy · `demo_applications/mcp_handson/policy_gated_mcp_agent/agent/policy.py`
- [Untrusted MCP tool](https://github.com/05satyam/ai-ml/blob/main/demo_applications/mcp_handson/policy_gated_mcp_agent/servers/evil_server.py): demo tool server · `demo_applications/mcp_handson/policy_gated_mcp_agent/servers/evil_server.py`

## Connections

- Repository guide → RAG notebook variants: indexes
- Repository guide → Citation agent cookbooks: indexes
- Repository guide → Multimodal app: indexes
- Repository guide → Service API: indexes
- Multimodal app → RAG API routes: serves
- RAG API routes → Answer pipeline: submits queries
- Answer pipeline → Retriever: retrieves context
- Retriever → Embeddings and index: searches index
- PDF and image inputs → Embeddings and index: indexes
- Service API → RAG pipeline: handles requests
- RAG pipeline → Knowledge and retrieval: retrieves context
- Runtime controls → RAG pipeline: guards and observes
- Container and Kubernetes → Service API: deploys
- Policy-gated MCP agent → Tool risk policy: checks tool calls
- Tool risk policy → Untrusted MCP tool: gates access
- Policy-gated MCP agent → Mounted MCP servers: uses MCP tools
- Citation agent cookbooks → Policy-gated MCP agent: teaches agent patterns alongside
