# asmitrandomtrees/memory-pdf-rag-agent architecture

> Architecture diagram of the GitHub repository asmitrandomtrees/memory-pdf-rag-agent, 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/asmitrandomtrees/memory-pdf-rag-agent
- Repository: https://github.com/asmitrandomtrees/memory-pdf-rag-agent

## Overview

This is a conversational AI product whose main workflow is a user request entering through the web API or CLI, loading a thread, running a LangGraph conversation pipeline with query analysis and selected STM/LTM/PDF retrieval, then returning an answer and processing memory writes. PDF ingestion, document comparison, evaluation, persistence, and tracing are separate capabilities. Some wiring is supported only by the SOURCE INDEX or README; edges without visible evidence are omitted rather than inferred.

Main entry points: [`app/graph/graph.py`](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/graph/graph.py) (LangGraph Runner), [`app/runtime/agent.py`](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/runtime/agent.py) (Conversation Agent), [`app/vectorstores/base.py`](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/vectorstores/base.py) (Vector Store), [`app/memory/stm/retriever.py`](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/memory/stm/retriever.py) (STM Retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_web["Chat UI<br/>[App.jsx]"]
  node_api["FastAPI<br/>[api_multiuser_1.py]"]
end

subgraph group_conversation["Conversation Runtime"]
  node_agent["Conversation Agent<br/>[agent.py]"]
  node_sessions["Sessions and Threads<br/>[session.py]"]
  node_graph["LangGraph Runner<br/>[graph.py]"]
  node_query["Query Analysis<br/>[query.py]"]
  node_answer["Answer Generation<br/>[answer.py]"]
  node_context["Context Assembly<br/>[context.py]"]
end

subgraph group_knowledge["Memory and Retrieval"]
  node_stm["Short-Term Memory<br/>[manager.py]"]
  node_stm_retrieval["STM Retrieval<br/>[retriever.py]"]
  node_ltm["Long-Term Memory<br/>[manager.py]"]
  node_ltm_retrieval["LTM Retrieval<br/>[retriever.py]"]
  node_pdf_retrieval["PDF Retrieval<br/>[pdf_retriever.py]"]
  node_ingestion["PDF Ingestion<br/>[pdf_ingest.py]"]
end

subgraph group_services["Models and Storage"]
  node_embeddings["Embedding Provider<br/>[provider.py]"]
  node_vectorstore[("Vector Store<br/>[base.py]")]
  node_llm["LLM Provider<br/>[provider.py]"]
end

subgraph group_support["Product Capabilities"]
  node_comparison["Document Comparison<br/>[comparator.py]"]
  node_evaluation["Evaluation Runner<br/>[runner.py]"]
  node_tracing["Tracing<br/>[retrieval.py]"]
  node_observability["Observability<br/>[tracker.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_web
node_web -->|"requests"| node_api
node_api -->|"invokes"| node_agent
node_agent -->|"loads session"| node_sessions
node_agent -->|"runs"| node_graph
node_graph -->|"dispatches"| node_query
node_graph -->|"dispatches"| node_answer
node_graph -->|"dispatches"| node_context
node_query -->|"analyzes with"| node_llm
node_graph -->|"dispatches"| node_stm_retrieval
node_graph -->|"dispatches"| node_ltm_retrieval
node_graph -->|"dispatches"| node_pdf_retrieval
node_stm -->|"uses"| node_stm_retrieval
node_ltm -->|"provides retrieval"| node_ltm_retrieval
node_agent -->|"writes"| node_stm
node_agent -->|"consolidates"| node_ltm
node_ltm -->|"indexes"| node_vectorstore
node_stm_retrieval -->|"searches"| node_vectorstore
node_ltm_retrieval -->|"searches"| node_vectorstore
node_pdf_retrieval -->|"searches"| node_vectorstore
node_ingestion -->|"embeds chunks"| node_embeddings
node_ingestion -->|"stores chunks"| node_vectorstore
node_stm_retrieval -.->|"embeds query"| node_embeddings
node_ltm_retrieval -.->|"embeds query"| node_embeddings
node_pdf_retrieval -.->|"embeds query"| node_embeddings
node_graph -->|"calls"| node_llm
node_graph -->|"records metrics"| node_observability
node_agent -->|"tracks latency"| node_observability
node_comparison -->|"uses"| node_llm
node_comparison -->|"retrieves evidence"| node_vectorstore
node_evaluation -->|"evaluates runs"| node_graph

click node_web "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/frontend/src/App.jsx"
click node_api "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/api_multiuser_1.py"
click node_agent "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/runtime/agent.py"
click node_sessions "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/runtime/session.py"
click node_graph "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/graph/graph.py"
click node_query "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/graph/nodes/query.py"
click node_answer "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/graph/nodes/answer.py"
click node_context "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/graph/nodes/context.py"
click node_stm "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/memory/stm/manager.py"
click node_stm_retrieval "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/memory/stm/retriever.py"
click node_ltm "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/memory/ltm/manager.py"
click node_ltm_retrieval "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/memory/ltm/retriever.py"
click node_pdf_retrieval "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/rag/pdf_retriever.py"
click node_ingestion "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/rag/pdf_ingest.py"
click node_embeddings "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/embeddings/provider.py"
click node_vectorstore "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/vectorstores/base.py"
click node_llm "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/llm/provider.py"
click node_comparison "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/comparison/comparator.py"
click node_evaluation "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/evaluation/runner.py"
click node_tracing "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/tracing/retrieval.py"
click node_observability "https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/observability/tracker.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_web,node_api,node_user toneBlue
class node_agent,node_sessions,node_graph,node_query,node_answer,node_context toneAmber
class node_stm,node_stm_retrieval,node_ltm,node_ltm_retrieval,node_pdf_retrieval,node_ingestion toneMint
class node_embeddings,node_vectorstore,node_llm toneRose
class node_comparison,node_evaluation,node_tracing,node_observability toneIndigo
```

## Components

### User Interfaces

- [Chat UI](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [FastAPI](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/api_multiuser_1.py): `app/api_multiuser_1.py`

### Conversation Runtime

- [Conversation Agent](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/runtime/agent.py): `app/runtime/agent.py`
- [Sessions and Threads](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/runtime/session.py): `app/runtime/session.py`
- [LangGraph Runner](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/graph/graph.py): `app/graph/graph.py`
- [Query Analysis](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/graph/nodes/query.py): `app/graph/nodes/query.py`
- [Answer Generation](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/graph/nodes/answer.py): `app/graph/nodes/answer.py`
- [Context Assembly](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/graph/nodes/context.py): `app/graph/nodes/context.py`

### Memory and Retrieval

- [Short-Term Memory](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/memory/stm/manager.py): `app/memory/stm/manager.py`
- [STM Retrieval](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/memory/stm/retriever.py): `app/memory/stm/retriever.py`
- [Long-Term Memory](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/memory/ltm/manager.py): `app/memory/ltm/manager.py`
- [LTM Retrieval](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/memory/ltm/retriever.py): `app/memory/ltm/retriever.py`
- [PDF Retrieval](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/rag/pdf_retriever.py): `app/rag/pdf_retriever.py`
- [PDF Ingestion](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/rag/pdf_ingest.py): `app/rag/pdf_ingest.py`

### Models and Storage

- [Embedding Provider](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/embeddings/provider.py): `app/embeddings/provider.py`
- [Vector Store](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/vectorstores/base.py): `app/vectorstores/base.py`
- [LLM Provider](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/llm/provider.py): `app/llm/provider.py`

### Product Capabilities

- [Document Comparison](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/comparison/comparator.py): `app/comparison/comparator.py`
- [Evaluation Runner](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/evaluation/runner.py): `app/evaluation/runner.py`
- [Tracing](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/tracing/retrieval.py): `app/tracing/retrieval.py`
- [Observability](https://github.com/asmitrandomtrees/memory-pdf-rag-agent/blob/main/app/observability/tracker.py): `app/observability/tracker.py`

### Other components

- **User**

## Connections

- User → Chat UI: uses
- Chat UI → FastAPI: requests (evidence: `frontend/src/App.jsx`)
- FastAPI → Conversation Agent: invokes (evidence: `app/api_multiuser_1.py`)
- Conversation Agent → Sessions and Threads: loads session (evidence: `app/runtime/agent.py`)
- Conversation Agent → LangGraph Runner: runs (evidence: `app/runtime/agent.py`)
- LangGraph Runner → Query Analysis: dispatches (evidence: `app/graph/graph.py`)
- LangGraph Runner → Answer Generation: dispatches (evidence: `app/graph/graph.py`)
- LangGraph Runner → Context Assembly: dispatches (evidence: `app/graph/graph.py`)
- Query Analysis → LLM Provider: analyzes with (evidence: `app/graph/nodes/query.py`)
- LangGraph Runner → STM Retrieval: dispatches (evidence: `app/graph/graph.py`)
- LangGraph Runner → LTM Retrieval: dispatches (evidence: `app/graph/graph.py`)
- LangGraph Runner → PDF Retrieval: dispatches (evidence: `app/graph/graph.py`)
- Short-Term Memory → STM Retrieval: uses (evidence: `app/memory/stm/manager.py`)
- Long-Term Memory → LTM Retrieval: provides retrieval (evidence: `app/memory/ltm/manager.py`)
- Conversation Agent → Short-Term Memory: writes (evidence: `app/runtime/agent.py`)
- Conversation Agent → Long-Term Memory: consolidates (evidence: `app/runtime/agent.py`)
- Long-Term Memory → Vector Store: indexes (evidence: `app/memory/ltm/manager.py`)
- STM Retrieval → Vector Store: searches (evidence: `app/memory/stm/retriever.py`)
- LTM Retrieval → Vector Store: searches (evidence: `app/memory/ltm/retriever.py`)
- PDF Retrieval → Vector Store: searches (evidence: `app/rag/pdf_retriever.py`)
- PDF Ingestion → Embedding Provider: embeds chunks (evidence: `app/rag/pdf_ingest.py`)
- PDF Ingestion → Vector Store: stores chunks (evidence: `app/rag/pdf_ingest.py`)
- STM Retrieval → Embedding Provider: embeds query (evidence: `app/memory/stm/retriever.py`)
- LTM Retrieval → Embedding Provider: embeds query (evidence: `app/memory/ltm/retriever.py`)
- PDF Retrieval → Embedding Provider: embeds query (evidence: `app/rag/pdf_retriever.py`)
- LangGraph Runner → LLM Provider: calls (evidence: `app/graph/graph.py`)
- LangGraph Runner → Observability: records metrics (evidence: `app/graph/graph.py`)
- Conversation Agent → Observability: tracks latency (evidence: `app/runtime/agent.py`)
- Document Comparison → LLM Provider: uses (evidence: `app/comparison/comparator.py`)
- Document Comparison → Vector Store: retrieves evidence (evidence: `app/comparison/comparator.py`)
- Evaluation Runner → LangGraph Runner: evaluates runs (evidence: `app/evaluation/runner.py`)
