# ramanpreetx/langgraph-memory-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/ramanpreetx/langgraph-memory-chatbot
- Repository: https://github.com/ramanpreetx/langgraph-memory-chatbot

## Overview

This is a Streamlit chat application with LangGraph-managed short-term conversation summaries and cross-conversation long-term user memories. A browser user sends messages through the app; the graph summarizes when needed, retrieves relevant memories, generates a reply, and hands eligible messages to background LTM processing. That pipeline extracts candidate facts, retrieves similar stored memories, resolves each candidate, and applies the decision. README documents thread history, titles, memory management, and PostgreSQL persistence. Some details are documented but their implementation is not sampled, so those links cite the README.

Main entry points: [`app.py`](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/app.py) (Streamlit chat UI), [`chatbot.py`](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/chatbot.py) (Reply generation), [`memory.py`](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py) (Similar-memory retrieval), [`prompt.py`](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/prompt.py) (Prompt templates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat interface"]
  node_app["Streamlit chat UI<br/>[app.py]"]
end

subgraph group_conversation["Conversation graph"]
  node_graph["LangGraph runtime<br/>[chatbot.py]"]
  node_summarizer["STM summarizer<br/>[chatbot.py]"]
  node_reply["Reply generation<br/>[chatbot.py]"]
  node_ltm_trigger["LTM trigger<br/>[chatbot.py]"]
  node_prompts["Prompt templates<br/>[prompt.py]"]
end

subgraph group_ltm["Long-term memory"]
  node_ltm_pipeline["LTM pipeline<br/>[memory.py]"]
  node_batch_select["Batch selection<br/>[memory.py]"]
  node_extraction["Memory extraction<br/>[memory.py]"]
  node_retrieval["Similar-memory retrieval<br/>[memory.py]"]
  node_resolution["Memory resolution<br/>[memory.py]"]
  node_memory_admin["Memory management<br/>[memory.py]"]
end

subgraph group_persistence["Persistence and identity"]
  node_identity["User identity<br/>[identity.py]"]
  node_thread_tools["Thread and titles<br/>[utils.py]"]
  node_postgres[("PostgreSQL")]
end

node_user(("Browser user"))
node_groq{{"Groq models"}}
node_embedding{{"Sentence embeddings"}}

node_user -->|"sends messages"| node_app
node_app -->|"gets user ID"| node_identity
node_app -->|"streams graph"| node_graph
node_app -->|"manages threads"| node_thread_tools
node_app -->|"manages memories"| node_memory_admin
node_graph -->|"runs first"| node_summarizer
node_summarizer -->|"then runs"| node_reply
node_reply -->|"then runs"| node_ltm_trigger
node_summarizer -->|"uses templates"| node_prompts
node_reply -->|"uses templates"| node_prompts
node_summarizer -->|"generates summary"| node_groq
node_reply -->|"looks up memories"| node_retrieval
node_reply -->|"generates reply"| node_groq
node_ltm_trigger -->|"dispatches background work"| node_ltm_pipeline
node_ltm_pipeline -->|"selects messages"| node_batch_select
node_ltm_pipeline -->|"extracts candidates"| node_extraction
node_extraction -->|"uses template"| node_prompts
node_extraction -->|"extracts facts"| node_groq
node_ltm_pipeline -->|"searches candidates"| node_retrieval
node_retrieval -->|"supplies matches"| node_resolution
node_resolution -->|"uses template"| node_prompts
node_resolution -.->|"chooses operation"| node_groq
node_resolution -->|"applies decisions"| node_postgres
node_retrieval -->|"searches memories"| node_postgres
node_memory_admin -->|"deletes memories"| node_postgres
node_identity -->|"provides identity"| node_app
node_thread_tools -.->|"persists threads"| node_postgres
node_graph -->|"saves thread state"| node_postgres
node_retrieval -.->|"indexes queries"| node_embedding

click node_app "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/app.py"
click node_identity "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/identity.py"
click node_thread_tools "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/utils.py"
click node_graph "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/chatbot.py"
click node_summarizer "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/chatbot.py"
click node_reply "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/chatbot.py"
click node_ltm_trigger "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/chatbot.py"
click node_prompts "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/prompt.py"
click node_ltm_pipeline "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py"
click node_batch_select "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py"
click node_extraction "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py"
click node_retrieval "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py"
click node_resolution "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py"
click node_memory_admin "https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.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_app,node_user toneBlue
class node_graph,node_summarizer,node_reply,node_ltm_trigger,node_prompts toneAmber
class node_ltm_pipeline,node_batch_select,node_extraction,node_retrieval,node_resolution,node_memory_admin toneMint
class node_identity,node_thread_tools,node_postgres toneRose
class node_groq,node_embedding toneIndigo
```

## Components

### Chat interface

- [Streamlit chat UI](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/app.py): `app.py`

### Conversation graph

- [LangGraph runtime](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/chatbot.py): `chatbot.py`
- [STM summarizer](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Reply generation](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/chatbot.py): `chatbot.py`
- [LTM trigger](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Prompt templates](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/prompt.py): `prompt.py`

### Long-term memory

- [LTM pipeline](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py): `memory.py`
- [Batch selection](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py): `memory.py`
- [Memory extraction](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py): `memory.py`
- [Similar-memory retrieval](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py): `memory.py`
- [Memory resolution](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py): `memory.py`
- [Memory management](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/memory.py): `memory.py`

### Persistence and identity

- [User identity](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/identity.py): `identity.py`
- [Thread and titles](https://github.com/ramanpreetx/langgraph-memory-chatbot/blob/main/utils.py): `utils.py`
- **PostgreSQL**

### Other components

- **Browser user**
- **Groq models**
- **Sentence embeddings**

## Connections

- Browser user → Streamlit chat UI: sends messages (evidence: `README.md`)
- Streamlit chat UI → User identity: gets user ID (evidence: `app.py`)
- Streamlit chat UI → LangGraph runtime: streams graph (evidence: `README.md`)
- Streamlit chat UI → Thread and titles: manages threads (evidence: `app.py`)
- Streamlit chat UI → Memory management: manages memories (evidence: `app.py`)
- LangGraph runtime → STM summarizer: runs first (evidence: `chatbot.py`)
- STM summarizer → Reply generation: then runs (evidence: `chatbot.py`)
- Reply generation → LTM trigger: then runs (evidence: `chatbot.py`)
- STM summarizer → Prompt templates: uses templates (evidence: `chatbot.py`)
- Reply generation → Prompt templates: uses templates (evidence: `chatbot.py`)
- STM summarizer → Groq models: generates summary (evidence: `chatbot.py`)
- Reply generation → Similar-memory retrieval: looks up memories (evidence: `chatbot.py`)
- Reply generation → Groq models: generates reply (evidence: `chatbot.py`)
- LTM trigger → LTM pipeline: dispatches background work (evidence: `chatbot.py`)
- LTM pipeline → Batch selection: selects messages (evidence: `memory.py`)
- LTM pipeline → Memory extraction: extracts candidates (evidence: `memory.py`)
- Memory extraction → Prompt templates: uses template (evidence: `memory.py`)
- Memory extraction → Groq models: extracts facts (evidence: `memory.py`)
- LTM pipeline → Similar-memory retrieval: searches candidates (evidence: `memory.py`)
- Similar-memory retrieval → Memory resolution: supplies matches (evidence: `memory.py`)
- Memory resolution → Prompt templates: uses template (evidence: `memory.py`)
- Memory resolution → Groq models: chooses operation
- Memory resolution → PostgreSQL: applies decisions (evidence: `memory.py`)
- Similar-memory retrieval → PostgreSQL: searches memories (evidence: `memory.py`)
- Memory management → PostgreSQL: deletes memories
- User identity → Streamlit chat UI: provides identity (evidence: `app.py`)
- Thread and titles → PostgreSQL: persists threads (evidence: `README.md`)
- LangGraph runtime → PostgreSQL: saves thread state (evidence: `chatbot.py`)
- Similar-memory retrieval → Sentence embeddings: indexes queries
