# omsupe15/memengine architecture

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

- Interactive diagram: https://gitdiagram.com/omsupe15/memengine
- Repository: https://github.com/omsupe15/memengine

## Overview

MemEngine is an offline conversational-memory engine: users submit turns or structured facts, the engine filters and extracts durable memories, resolves revisions while preserving lineage, and retrieves relevant active memories with hybrid search and unknown-query rejection. Users can access these workflows through the FastAPI API/dashboard or the Streamlit console. The graph also includes durable storage, local embeddings, and the documented evaluation capability. Some subsystem details are documented but unsampled, so those relationships are shown only where supported.

Main entry points: [`app/retrieval.py`](https://github.com/omsupe15/memengine/blob/main/app/retrieval.py) (Hybrid recall), [`app/updates.py`](https://github.com/omsupe15/memengine/blob/main/app/updates.py) (Conflict resolver), [`app/storage.py`](https://github.com/omsupe15/memengine/blob/main/app/storage.py) (Memory ledger), [`app/main.py`](https://github.com/omsupe15/memengine/blob/main/app/main.py) (FastAPI API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_fastapi["FastAPI API<br/>[main.py]"]
  node_streamlit["Streamlit console<br/>[streamlit_app.py]"]
end

subgraph group_memory["Memory lifecycle"]
  node_schemas["Request and response models<br/>[schemas.py]"]
  node_resolver["Conflict resolver<br/>[updates.py]"]
  node_extractor["Fact extraction<br/>[ingestion.py]"]
end

subgraph group_retrieval["Recall and ranking"]
  node_embeddings["Local embeddings<br/>[embeddings.py]"]
  node_recall["Hybrid recall<br/>[retrieval.py]"]
end

subgraph group_persistence["Local persistence"]
  node_ledger[("Memory ledger<br/>[storage.py]")]
  node_vectorstore[("Vector index<br/>[vector_store.py]")]
end

subgraph group_evaluation["Evaluation"]
  node_evaluator["Evaluation runner<br/>[evaluator.py]"]
end

node_user(("Chatbot user"))

node_user -->|"submits requests"| node_fastapi
node_user -->|"uses console"| node_streamlit
node_fastapi -->|"routes ingestion"| node_resolver
node_fastapi -->|"routes recall"| node_recall
node_fastapi -->|"lists and deletes"| node_ledger
node_fastapi -->|"validates requests"| node_schemas
node_streamlit -->|"submits turns"| node_resolver
node_streamlit -->|"queries memories"| node_recall
node_streamlit -->|"shows ledger"| node_ledger
node_streamlit -->|"runs evaluation"| node_evaluator
node_resolver -->|"extracts candidates"| node_extractor
node_resolver -->|"checks and saves"| node_ledger
node_resolver -.->|"checks and updates vectors"| node_vectorstore
node_extractor -->|"forms memory candidates"| node_schemas
node_ledger -->|"indexes saved memories"| node_vectorstore
node_ledger -->|"embeds saved memories"| node_embeddings
node_recall -->|"loads active records"| node_ledger
node_recall -->|"embeds query"| node_embeddings
node_recall -.->|"searches vectors"| node_vectorstore
node_recall -->|"returns recall response"| node_schemas
node_evaluator -->|"ingests test turns"| node_resolver
node_evaluator -->|"evaluates recall"| node_recall
node_evaluator -->|"uses embedding engine"| node_embeddings

click node_fastapi "https://github.com/omsupe15/memengine/blob/main/app/main.py"
click node_streamlit "https://github.com/omsupe15/memengine/blob/main/streamlit_app.py"
click node_schemas "https://github.com/omsupe15/memengine/blob/main/app/schemas.py"
click node_resolver "https://github.com/omsupe15/memengine/blob/main/app/updates.py"
click node_extractor "https://github.com/omsupe15/memengine/blob/main/app/ingestion.py"
click node_ledger "https://github.com/omsupe15/memengine/blob/main/app/storage.py"
click node_vectorstore "https://github.com/omsupe15/memengine/blob/main/app/vector_store.py"
click node_embeddings "https://github.com/omsupe15/memengine/blob/main/app/embeddings.py"
click node_recall "https://github.com/omsupe15/memengine/blob/main/app/retrieval.py"
click node_evaluator "https://github.com/omsupe15/memengine/blob/main/app/evaluator.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_fastapi,node_streamlit,node_user toneBlue
class node_schemas,node_resolver,node_extractor toneAmber
class node_embeddings,node_recall toneMint
class node_ledger,node_vectorstore toneRose
class node_evaluator toneIndigo
```

## Components

### User interfaces

- [FastAPI API](https://github.com/omsupe15/memengine/blob/main/app/main.py): `app/main.py`
- [Streamlit console](https://github.com/omsupe15/memengine/blob/main/streamlit_app.py): `streamlit_app.py`

### Memory lifecycle

- [Request and response models](https://github.com/omsupe15/memengine/blob/main/app/schemas.py): `app/schemas.py`
- [Conflict resolver](https://github.com/omsupe15/memengine/blob/main/app/updates.py): `app/updates.py`
- [Fact extraction](https://github.com/omsupe15/memengine/blob/main/app/ingestion.py): `app/ingestion.py`

### Recall and ranking

- [Local embeddings](https://github.com/omsupe15/memengine/blob/main/app/embeddings.py): `app/embeddings.py`
- [Hybrid recall](https://github.com/omsupe15/memengine/blob/main/app/retrieval.py): `app/retrieval.py`

### Local persistence

- [Memory ledger](https://github.com/omsupe15/memengine/blob/main/app/storage.py): `app/storage.py`
- [Vector index](https://github.com/omsupe15/memengine/blob/main/app/vector_store.py): `app/vector_store.py`

### Evaluation

- [Evaluation runner](https://github.com/omsupe15/memengine/blob/main/app/evaluator.py): `app/evaluator.py`

### Other components

- **Chatbot user**

## Connections

- Chatbot user → FastAPI API: submits requests (evidence: `app/main.py`)
- Chatbot user → Streamlit console: uses console (evidence: `streamlit_app.py`)
- FastAPI API → Conflict resolver: routes ingestion (evidence: `app/main.py`)
- FastAPI API → Hybrid recall: routes recall (evidence: `app/main.py`)
- FastAPI API → Memory ledger: lists and deletes (evidence: `app/main.py`)
- FastAPI API → Request and response models: validates requests (evidence: `app/main.py`)
- Streamlit console → Conflict resolver: submits turns (evidence: `streamlit_app.py`)
- Streamlit console → Hybrid recall: queries memories (evidence: `streamlit_app.py`)
- Streamlit console → Memory ledger: shows ledger (evidence: `streamlit_app.py`)
- Streamlit console → Evaluation runner: runs evaluation (evidence: `streamlit_app.py`)
- Conflict resolver → Fact extraction: extracts candidates (evidence: `app/updates.py`)
- Conflict resolver → Memory ledger: checks and saves (evidence: `app/updates.py`)
- Conflict resolver → Vector index: checks and updates vectors (evidence: `README.md`)
- Fact extraction → Request and response models: forms memory candidates (evidence: `app/ingestion.py`)
- Memory ledger → Vector index: indexes saved memories (evidence: `app/storage.py`)
- Memory ledger → Local embeddings: embeds saved memories (evidence: `app/storage.py`)
- Hybrid recall → Memory ledger: loads active records (evidence: `app/retrieval.py`)
- Hybrid recall → Local embeddings: embeds query (evidence: `app/retrieval.py`)
- Hybrid recall → Vector index: searches vectors (evidence: `README.md`)
- Hybrid recall → Request and response models: returns recall response (evidence: `app/retrieval.py`)
- Evaluation runner → Conflict resolver: ingests test turns (evidence: `app/evaluator.py`)
- Evaluation runner → Hybrid recall: evaluates recall (evidence: `app/evaluator.py`)
- Evaluation runner → Local embeddings: uses embedding engine (evidence: `app/evaluator.py`)
