# aakash1999/awsbedrockrag architecture

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

- Interactive diagram: https://gitdiagram.com/aakash1999/awsbedrockrag
- Repository: https://github.com/aakash1999/awsbedrockrag

## Overview

This is a single-file command-line RAG demo. Running it invokes `main`, which embeds a fixed query and six in-memory documents through Amazon Bedrock, ranks the documents by cosine similarity, then sends the top matches as grounded context to a text-generation model and prints the answer. The retrieval and generation stages are separate functions in the same file; there is no persistent index or user-facing service. The graph reflects the sampled source; AWS is an external dependency.

Main entry points: [`rag_demo.py`](https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py) (CLI entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_rag["RAG demo"]
  node_entry["CLI entry point<br/>[rag_demo.py]"]
  node_corpus["Sample documents<br/>[rag_demo.py]"]
  node_retrieval["Semantic retrieval<br/>[rag_demo.py]"]
  node_similarity["Cosine scoring<br/>[rag_demo.py]"]
  node_generation["Grounded generation<br/>[rag_demo.py]"]
  node_output["Printed results<br/>[rag_demo.py]"]
end

node_user(("Demo user"))
node_bedrock{{"Bedrock Runtime"}}

node_user -->|"runs"| node_entry
node_entry -->|"uses"| node_corpus
node_entry -->|"calls"| node_retrieval
node_retrieval -->|"requests embeddings"| node_bedrock
node_retrieval -->|"scores vectors"| node_similarity
node_entry -->|"calls"| node_generation
node_generation -->|"requests completion"| node_bedrock
node_entry -->|"prints"| node_output

click node_entry "https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py"
click node_corpus "https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py"
click node_retrieval "https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py"
click node_similarity "https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py"
click node_generation "https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py"
click node_output "https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.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_entry,node_corpus,node_retrieval,node_similarity,node_generation,node_output,node_user toneBlue
class node_bedrock toneIndigo
```

## Components

### RAG demo

- [CLI entry point](https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py): `rag_demo.py`
- [Sample documents](https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py): `rag_demo.py`
- [Semantic retrieval](https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py): `rag_demo.py`
- [Cosine scoring](https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py): `rag_demo.py`
- [Grounded generation](https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py): `rag_demo.py`
- [Printed results](https://github.com/aakash1999/awsbedrockrag/blob/main/rag_demo.py): `rag_demo.py`

### Other components

- **Demo user**
- **Bedrock Runtime**

## Connections

- Demo user → CLI entry point: runs (evidence: `rag_demo.py`)
- CLI entry point → Sample documents: uses (evidence: `rag_demo.py`)
- CLI entry point → Semantic retrieval: calls (evidence: `rag_demo.py`)
- Semantic retrieval → Bedrock Runtime: requests embeddings (evidence: `rag_demo.py`)
- Semantic retrieval → Cosine scoring: scores vectors (evidence: `rag_demo.py`)
- CLI entry point → Grounded generation: calls (evidence: `rag_demo.py`)
- Grounded generation → Bedrock Runtime: requests completion (evidence: `rag_demo.py`)
- CLI entry point → Printed results: prints (evidence: `rag_demo.py`)
