# carina299/rbtl architecture

> Architecture diagram of the GitHub repository carina299/rbtl, 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/carina299/rbtl
- Repository: https://github.com/carina299/rbtl

## Overview

RBTLove is a private, single-user AI companion chat with long-term memory and a photo album. The main interaction runs from the phone PWA through the relay to a locally running AI channel, with replies returning through the relay. Memory can be searched or saved on demand by the agent, or distilled asynchronously from chat; album uploads are stored and exposed for timeline browsing. The graph reflects README-documented links and sampled source references; unsampled UI and integration details are not expanded beyond those references.

Main entry points: [`backend/app.py`](https://github.com/carina299/rbtl/blob/main/backend/app.py) (Relay API), [`backend/memory/extraction_graph.py`](https://github.com/carina299/rbtl/blob/main/backend/memory/extraction_graph.py) (Dialogue extraction), [`backend/album.py`](https://github.com/carina299/rbtl/blob/main/backend/album.py) (Album upload and entries), [`backend/memory/embeddings.py`](https://github.com/carina299/rbtl/blob/main/backend/memory/embeddings.py) (Embedding providers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User and AI interfaces"]
  node_pwa["Phone PWA<br/>[desktop.js]"]
  node_channel["AI channel plugin<br/>[server.ts]"]
  node_mcp["MCP tools<br/>[mcp_server.py]"]
  node_album_ui["Album timeline UI<br/>[memories.html]"]
end

subgraph group_relay["Chat relay"]
  node_relay_app["Relay API<br/>[app.py]"]
  node_live_chat["Live chat and SSE<br/>[app.py]"]
end

subgraph group_memory["Long-term memory"]
  node_tasks["Memory jobs<br/>[tasks.py]"]
  node_celery["Celery scheduler<br/>[celery_app.py]"]
  node_extract["Dialogue extraction"]
  node_llm["LLM extraction<br/>[llm.py]"]
  node_dedup["Memory deduplication<br/>[dedup.py]"]
  node_remember["Explicit memory write<br/>[remember.py]"]
  node_retrieval["Memory retrieval<br/>[retrieval_graph.py]"]
  node_rerank["Memory reranking<br/>[rerank.py]"]
  node_embeddings["Embedding providers<br/>[embeddings.py]"]
end

subgraph group_album["Album and persistence"]
  node_album["Album upload and entries<br/>[album.py]"]
  node_storage["Object storage<br/>[storage.py]"]
  node_repositories["Data repositories<br/>[repositories.py]"]
  node_models["Database models<br/>[models.py]"]
  node_database["Database sessions<br/>[database.py]"]
end

node_person(("Person"))
node_local_ai(("Local AI"))
node_postgres[("PostgreSQL")]
node_llm_service(("LLM services"))
node_embedding_service(("Embedding services"))
node_object_store[("MinIO or S3")]

node_person -->|"uses"| node_pwa
node_pwa -->|"sends chat"| node_relay_app
node_relay_app -->|"routes chat"| node_live_chat
node_local_ai -->|"runs locally"| node_channel
node_channel -->|"exchanges messages"| node_relay_app
node_relay_app -->|"streams messages"| node_channel
node_relay_app -->|"dispatches extraction"| node_tasks
node_celery -->|"schedules jobs"| node_tasks
node_tasks -->|"runs extraction"| node_extract
node_extract -->|"extracts candidates"| node_llm
node_extract -->|"embeds candidates"| node_embeddings
node_extract -->|"decides actions"| node_dedup
node_mcp -->|"calls"| node_remember
node_mcp -->|"calls"| node_retrieval
node_mcp -->|"calls"| node_album
node_remember -->|"embeds content"| node_embeddings
node_remember -->|"checks duplicates"| node_dedup
node_retrieval -->|"embeds query"| node_embeddings
node_retrieval -->|"reranks candidates"| node_rerank
node_album_ui -.->|"browses album"| node_relay_app
node_relay_app -->|"handles uploads"| node_album
node_album -->|"stores photos"| node_storage
node_album -->|"records entries"| node_repositories
node_relay_app -->|"uses repositories"| node_repositories
node_repositories -->|"queries models"| node_models
node_models -->|"inherits base"| node_database
node_database -->|"connects to"| node_postgres
node_llm -.->|"calls provider"| node_llm_service
node_embeddings -.->|"calls provider"| node_embedding_service
node_storage -.->|"stores objects"| node_object_store

click node_pwa "https://github.com/carina299/rbtl/blob/main/frontend/js/desktop.js"
click node_channel "https://github.com/carina299/rbtl/blob/main/channel/server.ts"
click node_relay_app "https://github.com/carina299/rbtl/blob/main/backend/app.py"
click node_live_chat "https://github.com/carina299/rbtl/blob/main/backend/app.py"
click node_mcp "https://github.com/carina299/rbtl/blob/main/backend/mcp_server.py"
click node_tasks "https://github.com/carina299/rbtl/blob/main/backend/tasks.py"
click node_celery "https://github.com/carina299/rbtl/blob/main/backend/celery_app.py"
click node_extract "https://github.com/carina299/rbtl/blob/main/backend/memory/extraction_graph.py"
click node_llm "https://github.com/carina299/rbtl/blob/main/backend/memory/llm.py"
click node_dedup "https://github.com/carina299/rbtl/blob/main/backend/memory/dedup.py"
click node_remember "https://github.com/carina299/rbtl/blob/main/backend/memory/remember.py"
click node_retrieval "https://github.com/carina299/rbtl/blob/main/backend/memory/retrieval_graph.py"
click node_rerank "https://github.com/carina299/rbtl/blob/main/backend/memory/rerank.py"
click node_embeddings "https://github.com/carina299/rbtl/blob/main/backend/memory/embeddings.py"
click node_album_ui "https://github.com/carina299/rbtl/blob/main/frontend/memories.html"
click node_album "https://github.com/carina299/rbtl/blob/main/backend/album.py"
click node_storage "https://github.com/carina299/rbtl/blob/main/backend/storage.py"
click node_repositories "https://github.com/carina299/rbtl/blob/main/backend/repositories.py"
click node_models "https://github.com/carina299/rbtl/blob/main/backend/models.py"
click node_database "https://github.com/carina299/rbtl/blob/main/backend/database.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_pwa,node_channel,node_mcp,node_album_ui toneBlue
class node_relay_app,node_live_chat,node_postgres,node_object_store toneAmber
class node_tasks,node_celery,node_extract,node_llm,node_dedup,node_remember,node_retrieval,node_rerank,node_embeddings toneMint
class node_album,node_storage,node_repositories,node_models,node_database toneRose
class node_person,node_local_ai,node_llm_service,node_embedding_service toneIndigo
```

## Components

### User and AI interfaces

- [Phone PWA](https://github.com/carina299/rbtl/blob/main/frontend/js/desktop.js): `frontend/js/desktop.js`
- [AI channel plugin](https://github.com/carina299/rbtl/blob/main/channel/server.ts): `channel/server.ts`
- [MCP tools](https://github.com/carina299/rbtl/blob/main/backend/mcp_server.py): `backend/mcp_server.py`
- [Album timeline UI](https://github.com/carina299/rbtl/blob/main/frontend/memories.html): `frontend/memories.html`

### Chat relay

- [Relay API](https://github.com/carina299/rbtl/blob/main/backend/app.py): `backend/app.py`
- [Live chat and SSE](https://github.com/carina299/rbtl/blob/main/backend/app.py): `backend/app.py`

### Long-term memory

- [Memory jobs](https://github.com/carina299/rbtl/blob/main/backend/tasks.py): `backend/tasks.py`
- [Celery scheduler](https://github.com/carina299/rbtl/blob/main/backend/celery_app.py): `backend/celery_app.py`
- [Dialogue extraction](https://github.com/carina299/rbtl/blob/main/backend/memory/extraction_graph.py): `backend/memory/extraction_graph.py`
- [LLM extraction](https://github.com/carina299/rbtl/blob/main/backend/memory/llm.py): `backend/memory/llm.py`
- [Memory deduplication](https://github.com/carina299/rbtl/blob/main/backend/memory/dedup.py): `backend/memory/dedup.py`
- [Explicit memory write](https://github.com/carina299/rbtl/blob/main/backend/memory/remember.py): `backend/memory/remember.py`
- [Memory retrieval](https://github.com/carina299/rbtl/blob/main/backend/memory/retrieval_graph.py): `backend/memory/retrieval_graph.py`
- [Memory reranking](https://github.com/carina299/rbtl/blob/main/backend/memory/rerank.py): `backend/memory/rerank.py`
- [Embedding providers](https://github.com/carina299/rbtl/blob/main/backend/memory/embeddings.py): `backend/memory/embeddings.py`

### Album and persistence

- [Album upload and entries](https://github.com/carina299/rbtl/blob/main/backend/album.py): `backend/album.py`
- [Object storage](https://github.com/carina299/rbtl/blob/main/backend/storage.py): `backend/storage.py`
- [Data repositories](https://github.com/carina299/rbtl/blob/main/backend/repositories.py): `backend/repositories.py`
- [Database models](https://github.com/carina299/rbtl/blob/main/backend/models.py): `backend/models.py`
- [Database sessions](https://github.com/carina299/rbtl/blob/main/backend/database.py): `backend/database.py`

### Other components

- **Person**
- **Local AI**
- **PostgreSQL**
- **LLM services**
- **Embedding services**
- **MinIO or S3**

## Connections

- Person → Phone PWA: uses (evidence: `README.md`)
- Phone PWA → Relay API: sends chat (evidence: `README.md`)
- Relay API → Live chat and SSE: routes chat (evidence: `backend/app.py`)
- Local AI → AI channel plugin: runs locally (evidence: `README.md`)
- AI channel plugin → Relay API: exchanges messages (evidence: `README.md`)
- Relay API → AI channel plugin: streams messages (evidence: `README.md`)
- Relay API → Memory jobs: dispatches extraction (evidence: `backend/app.py`)
- Celery scheduler → Memory jobs: schedules jobs (evidence: `backend/tasks.py`)
- Memory jobs → Dialogue extraction: runs extraction (evidence: `backend/tasks.py`)
- Dialogue extraction → LLM extraction: extracts candidates (evidence: `backend/memory/extraction_graph.py`)
- Dialogue extraction → Embedding providers: embeds candidates (evidence: `backend/memory/extraction_graph.py`)
- Dialogue extraction → Memory deduplication: decides actions (evidence: `backend/memory/extraction_graph.py`)
- MCP tools → Explicit memory write: calls (evidence: `backend/mcp_server.py`)
- MCP tools → Memory retrieval: calls (evidence: `backend/mcp_server.py`)
- MCP tools → Album upload and entries: calls (evidence: `backend/mcp_server.py`)
- Explicit memory write → Embedding providers: embeds content (evidence: `backend/memory/remember.py`)
- Explicit memory write → Memory deduplication: checks duplicates (evidence: `backend/memory/remember.py`)
- Memory retrieval → Embedding providers: embeds query (evidence: `backend/memory/retrieval_graph.py`)
- Memory retrieval → Memory reranking: reranks candidates (evidence: `backend/memory/retrieval_graph.py`)
- Album timeline UI → Relay API: browses album
- Relay API → Album upload and entries: handles uploads (evidence: `backend/app.py`)
- Album upload and entries → Object storage: stores photos (evidence: `backend/album.py`)
- Album upload and entries → Data repositories: records entries (evidence: `backend/album.py`)
- Relay API → Data repositories: uses repositories (evidence: `backend/app.py`)
- Data repositories → Database models: queries models (evidence: `backend/repositories.py`)
- Database models → Database sessions: inherits base (evidence: `backend/models.py`)
- Database sessions → PostgreSQL: connects to (evidence: `backend/database.py`)
- LLM extraction → LLM services: calls provider
- Embedding providers → Embedding services: calls provider
- Object storage → MinIO or S3: stores objects
