# stephaniew1/agentic-rag-assistant architecture

> Architecture diagram of the GitHub repository stephaniew1/agentic-rag-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stephaniew1/agentic-rag-assistant
- Repository: https://github.com/stephaniew1/agentic-rag-assistant

## Overview

Tempo Assistant answers product questions with cited help articles and acts on the caller’s Tempo account. The principal flow is an authenticated chat request through the HTTP app to a shared agent, which either searches the knowledge base or invokes account tools; uploaded PDFs are extracted and safely bounded before reaching the agent. A separate ingestion path builds the article index. The graph also preserves the documented AWS deployment path. Some subsystem links are based on README statements because their implementation was not sampled.

Main entry points: [`app/server.py`](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/server.py) (Chat API), [`infra/lib/assistant-stack.ts`](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/infra/lib/assistant-stack.ts) (CDK assistant stack), [`app/agent.py`](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/agent.py) (Function agent), [`app/rag.py`](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/rag.py) (Article search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request entry"]
  node_gateway["HTTP API gateway<br/>[assistant-stack.ts]"]
  node_lambda["Lambda adapter<br/>[lambda_handler.py]"]
  node_server["Chat API<br/>[server.py]"]
  node_auth["JWT verification<br/>[auth.py]"]
  node_documents["PDF boundary<br/>[documents.py]"]
end

subgraph group_assistant["Assistant runtime"]
  node_agent["Function agent<br/>[agent.py]"]
  node_prompts["Assistant policy<br/>[prompts.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_rag["Article search<br/>[rag.py]"]
  node_ingest["Article indexing<br/>[ingest.py]"]
  node_articles["Help articles"]
  node_vectorstore[("pgvector index")]
end

subgraph group_actions["Account actions"]
  node_tools["Account tools<br/>[tools.py]"]
  node_productapi["Tempo product API<br/>[main.py]"]
end

subgraph group_aws["AWS deployment"]
  node_stack["CDK assistant stack<br/>[assistant-stack.ts]"]
  node_secrets[("Secrets Manager")]
  node_alarms["CloudWatch alarms"]
end

node_client(("Tempo user"))
node_openai["OpenAI models"]
node_identity["JWT identity provider"]

node_client -->|"sends JWT"| node_gateway
node_gateway -->|"routes requests"| node_lambda
node_lambda -->|"adapts to"| node_server
node_server -->|"verifies caller"| node_auth
node_server -->|"extracts and wraps"| node_documents
node_server -->|"runs agent"| node_agent
node_server -->|"returns response"| node_client
node_auth -->|"checks JWKS"| node_identity
node_agent -->|"uses policy"| node_prompts
node_agent -->|"registers search"| node_rag
node_agent -->|"registers tools"| node_tools
node_rag -->|"queries index"| node_vectorstore
node_rag -->|"uses models"| node_openai
node_ingest -->|"loads articles"| node_articles
node_ingest -->|"rebuilds index"| node_vectorstore
node_tools -->|"calls API"| node_productapi
node_stack -->|"configures routes"| node_gateway
node_stack -->|"configures function"| node_lambda
node_stack -->|"grants secret access"| node_secrets
node_stack -->|"sets metrics alarms"| node_alarms
node_config -.->|"loads runtime values"| node_secrets

click node_gateway "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/infra/lib/assistant-stack.ts"
click node_lambda "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/lambda_handler.py"
click node_server "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/server.py"
click node_auth "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/auth.py"
click node_documents "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/documents.py"
click node_agent "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/agent.py"
click node_prompts "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/prompts.py"
click node_config "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/config.py"
click node_rag "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/rag.py"
click node_ingest "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/ingest.py"
click node_articles "https://github.com/stephaniew1/agentic-rag-assistant/tree/main/data/articles"
click node_tools "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/tools.py"
click node_productapi "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/mock_api/main.py"
click node_stack "https://github.com/stephaniew1/agentic-rag-assistant/blob/main/infra/lib/assistant-stack.ts"

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_gateway,node_lambda,node_server,node_auth,node_documents,node_client toneBlue
class node_agent,node_prompts,node_config toneAmber
class node_rag,node_ingest,node_articles,node_vectorstore toneMint
class node_tools,node_productapi toneRose
class node_stack,node_secrets,node_alarms,node_openai,node_identity toneIndigo
```

## Components

### Request entry

- [HTTP API gateway](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/infra/lib/assistant-stack.ts): `infra/lib/assistant-stack.ts`
- [Lambda adapter](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/lambda_handler.py): `app/lambda_handler.py`
- [Chat API](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/server.py): `app/server.py`
- [JWT verification](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/auth.py): `app/auth.py`
- [PDF boundary](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/documents.py): `app/documents.py`

### Assistant runtime

- [Function agent](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/agent.py): `app/agent.py`
- [Assistant policy](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/prompts.py): `app/prompts.py`
- [Runtime configuration](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/config.py): `app/config.py`

### Knowledge retrieval

- [Article search](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/rag.py): `app/rag.py`
- [Article indexing](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/ingest.py): `app/ingest.py`
- [Help articles](https://github.com/stephaniew1/agentic-rag-assistant/tree/main/data/articles): `data/articles`
- **pgvector index**

### Account actions

- [Account tools](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/app/tools.py): `app/tools.py`
- [Tempo product API](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/mock_api/main.py): `mock_api/main.py`

### AWS deployment

- [CDK assistant stack](https://github.com/stephaniew1/agentic-rag-assistant/blob/main/infra/lib/assistant-stack.ts): `infra/lib/assistant-stack.ts`
- **Secrets Manager**
- **CloudWatch alarms**

### Other components

- **Tempo user**
- **OpenAI models**
- **JWT identity provider**

## Connections

- Tempo user → HTTP API gateway: sends JWT (evidence: `README.md`)
- HTTP API gateway → Lambda adapter: routes requests (evidence: `infra/lib/assistant-stack.ts`)
- Lambda adapter → Chat API: adapts to (evidence: `app/lambda_handler.py`)
- Chat API → JWT verification: verifies caller (evidence: `app/server.py`)
- Chat API → PDF boundary: extracts and wraps (evidence: `app/server.py`)
- Chat API → Function agent: runs agent (evidence: `app/server.py`)
- Chat API → Tempo user: returns response (evidence: `app/server.py`)
- JWT verification → JWT identity provider: checks JWKS (evidence: `app/auth.py`)
- Function agent → Assistant policy: uses policy (evidence: `app/agent.py`)
- Function agent → Article search: registers search (evidence: `app/agent.py`)
- Function agent → Account tools: registers tools (evidence: `app/agent.py`)
- Article search → pgvector index: queries index (evidence: `app/rag.py`)
- Article search → OpenAI models: uses models (evidence: `app/rag.py`)
- Article indexing → Help articles: loads articles (evidence: `app/ingest.py`)
- Article indexing → pgvector index: rebuilds index (evidence: `app/ingest.py`)
- Account tools → Tempo product API: calls API (evidence: `app/tools.py`)
- CDK assistant stack → HTTP API gateway: configures routes (evidence: `infra/lib/assistant-stack.ts`)
- CDK assistant stack → Lambda adapter: configures function (evidence: `infra/lib/assistant-stack.ts`)
- CDK assistant stack → Secrets Manager: grants secret access (evidence: `infra/lib/assistant-stack.ts`)
- CDK assistant stack → CloudWatch alarms: sets metrics alarms (evidence: `infra/lib/assistant-stack.ts`)
- Runtime configuration → Secrets Manager: loads runtime values (evidence: `README.md`)
