# rayhanrinzan/keepsake architecture

> Architecture diagram of the GitHub repository rayhanrinzan/keepsake, 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/rayhanrinzan/keepsake
- Repository: https://github.com/rayhanrinzan/keepsake
- Video tour (about a minute): https://gitdiagram.com/rayhanrinzan/keepsake/video

## Overview

Keepsake’s primary workflow is worn-camera capture, item detection and stabilization, persistent last-sighting/photo memory, then retrieval through web or mobile and voice. Its optional Photon integration sends reminders by iMessage. The repository also contains Last Seen, a separate wearable-memory app with its own camera loop, memory, assistant, proactive prompts, and dashboard. Unexcerpted subsystem links are omitted unless the README or source index supports them.

Main entry points: [`backend/main.py`](https://github.com/rayhanrinzan/keepsake/blob/main/backend/main.py) (Keepsake API), [`backend/vision.py`](https://github.com/rayhanrinzan/keepsake/blob/main/backend/vision.py) (Item detection), [`lastseen-wearable/lastseen/engine/vision_loop.py`](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/engine/vision_loop.py) (Vision and tracking loop), [`lastseen-wearable/lastseen/server/app.py`](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/server/app.py) (Dashboard and API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_keepsake["Keepsake backend"]
  node_camera["Camera capture<br/>[cameras.py]"]
  node_vision["Item detection<br/>[vision.py]"]
  node_verify["Detection verification<br/>[verify.py]"]
  node_catalog["Tracked-item catalog<br/>[catalog.py]"]
  node_events["Observation events<br/>[events.py]"]
  node_memory["Sighting memory<br/>[memory.py]"]
  node_snapshots["Photo snapshots<br/>[snapshots.py]"]
  node_db[("SQLite records<br/>[database.py]")]
  node_api["Keepsake API<br/>[main.py]"]
  node_reminders["Reminder engine<br/>[reminders.py]"]
end

subgraph group_clients["Keepsake clients"]
  node_web["Web app<br/>[App.tsx]"]
  node_webapi["Web API client<br/>[api.ts]"]
  node_webvoice["Web voice<br/>[voice.ts]"]
  node_mobile["Mobile app<br/>[index.tsx]"]
  node_mobileapi["Mobile API client<br/>[api.ts]"]
end

subgraph group_photon["iMessage reminders"]
  node_photonagent["Photon agent<br/>[index.ts]"]
  node_photonuser(("Reminder recipient"))
end

subgraph group_lastseen["Last Seen wearable"]
  node_lastseen["Last Seen app<br/>[__main__.py]"]
  node_lastcamera["Camera capture<br/>[camera.py]"]
  node_lastloop["Vision and tracking loop<br/>[vision_loop.py]"]
  node_lastconfig["Wearable configuration<br/>[config.py]"]
  node_laststore[("Memory store<br/>[store.py]")]
  node_lastclips["Clip memory<br/>[clips.py]"]
  node_lastbrain["Question answering<br/>[answer.py]"]
  node_lost["Lost-sight prompts<br/>[lost_sight.py]"]
  node_lastserver["Dashboard and API<br/>[app.py]"]
end

node_wearer(("Camera wearer"))

node_wearer -->|"wears camera"| node_camera
node_camera -->|"sends frames"| node_vision
node_vision -->|"checks detections"| node_verify
node_vision -->|"updates sightings"| node_memory
node_vision -->|"emits observations"| node_events
node_vision -->|"captures photos"| node_snapshots
node_memory -->|"persists records"| node_db
node_events -->|"stores events"| node_db
node_snapshots -->|"stores metadata"| node_db
node_api -->|"reads records"| node_db
node_api -->|"clears memory"| node_memory
node_api -->|"serves photos"| node_snapshots
node_api -->|"uses reminders"| node_reminders
node_web -->|"loads data"| node_webapi
node_web -->|"handles voice"| node_webvoice
node_webapi -->|"requests data"| node_api
node_mobile -->|"loads items"| node_mobileapi
node_mobileapi -->|"requests data"| node_api
node_photonagent -.->|"retrieves memories"| node_api
node_photonagent -->|"sends reminders"| node_photonuser
node_lastcamera -->|"provides frames"| node_lastloop
node_lastloop -.->|"stores tracking"| node_laststore
node_lastloop -->|"uses clips"| node_lastclips
node_lastloop -->|"uses settings"| node_lastconfig
node_lastserver -.->|"serves item data"| node_laststore
node_lastserver -.->|"serves clips"| node_lastclips
node_lastserver -.->|"routes questions"| node_lastbrain
node_lost -->|"uses intents"| node_lastbrain
node_lastseen -->|"exposes dashboard"| node_lastserver

click node_camera "https://github.com/rayhanrinzan/keepsake/blob/main/backend/cameras.py"
click node_vision "https://github.com/rayhanrinzan/keepsake/blob/main/backend/vision.py"
click node_verify "https://github.com/rayhanrinzan/keepsake/blob/main/backend/verify.py"
click node_catalog "https://github.com/rayhanrinzan/keepsake/blob/main/backend/catalog.py"
click node_events "https://github.com/rayhanrinzan/keepsake/blob/main/backend/events.py"
click node_memory "https://github.com/rayhanrinzan/keepsake/blob/main/backend/memory.py"
click node_snapshots "https://github.com/rayhanrinzan/keepsake/blob/main/backend/snapshots.py"
click node_db "https://github.com/rayhanrinzan/keepsake/blob/main/backend/database.py"
click node_api "https://github.com/rayhanrinzan/keepsake/blob/main/backend/main.py"
click node_reminders "https://github.com/rayhanrinzan/keepsake/blob/main/backend/reminders.py"
click node_web "https://github.com/rayhanrinzan/keepsake/blob/main/frontend/src/App.tsx"
click node_webapi "https://github.com/rayhanrinzan/keepsake/blob/main/frontend/src/lib/api.ts"
click node_webvoice "https://github.com/rayhanrinzan/keepsake/blob/main/frontend/src/lib/voice.ts"
click node_mobile "https://github.com/rayhanrinzan/keepsake/blob/main/mobile/src/app/index.tsx"
click node_mobileapi "https://github.com/rayhanrinzan/keepsake/blob/main/mobile/src/lib/api.ts"
click node_photonagent "https://github.com/rayhanrinzan/keepsake/blob/main/integrations/photon/src/index.ts"
click node_lastseen "https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/__main__.py"
click node_lastcamera "https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/capture/camera.py"
click node_lastloop "https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/engine/vision_loop.py"
click node_lastconfig "https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/config.py"
click node_laststore "https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/memory/store.py"
click node_lastclips "https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/memory/clips.py"
click node_lastbrain "https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/brain/answer.py"
click node_lost "https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/proactive/lost_sight.py"
click node_lastserver "https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/server/app.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_camera,node_vision,node_verify,node_catalog,node_events,node_memory,node_snapshots,node_db,node_api,node_reminders toneBlue
class node_web,node_webapi,node_webvoice,node_mobile,node_mobileapi toneAmber
class node_photonagent,node_photonuser toneMint
class node_lastseen,node_lastcamera,node_lastloop,node_lastconfig,node_laststore,node_lastclips,node_lastbrain,node_lost,node_lastserver toneRose
class node_wearer toneIndigo
```

## Components

### Keepsake backend

- [Camera capture](https://github.com/rayhanrinzan/keepsake/blob/main/backend/cameras.py): `backend/cameras.py`
- [Item detection](https://github.com/rayhanrinzan/keepsake/blob/main/backend/vision.py): `backend/vision.py`
- [Detection verification](https://github.com/rayhanrinzan/keepsake/blob/main/backend/verify.py): `backend/verify.py`
- [Tracked-item catalog](https://github.com/rayhanrinzan/keepsake/blob/main/backend/catalog.py): `backend/catalog.py`
- [Observation events](https://github.com/rayhanrinzan/keepsake/blob/main/backend/events.py): `backend/events.py`
- [Sighting memory](https://github.com/rayhanrinzan/keepsake/blob/main/backend/memory.py): `backend/memory.py`
- [Photo snapshots](https://github.com/rayhanrinzan/keepsake/blob/main/backend/snapshots.py): `backend/snapshots.py`
- [SQLite records](https://github.com/rayhanrinzan/keepsake/blob/main/backend/database.py): `backend/database.py`
- [Keepsake API](https://github.com/rayhanrinzan/keepsake/blob/main/backend/main.py): `backend/main.py`
- [Reminder engine](https://github.com/rayhanrinzan/keepsake/blob/main/backend/reminders.py): `backend/reminders.py`

### Keepsake clients

- [Web app](https://github.com/rayhanrinzan/keepsake/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Web API client](https://github.com/rayhanrinzan/keepsake/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Web voice](https://github.com/rayhanrinzan/keepsake/blob/main/frontend/src/lib/voice.ts): `frontend/src/lib/voice.ts`
- [Mobile app](https://github.com/rayhanrinzan/keepsake/blob/main/mobile/src/app/index.tsx): `mobile/src/app/index.tsx`
- [Mobile API client](https://github.com/rayhanrinzan/keepsake/blob/main/mobile/src/lib/api.ts): `mobile/src/lib/api.ts`

### iMessage reminders

- [Photon agent](https://github.com/rayhanrinzan/keepsake/blob/main/integrations/photon/src/index.ts): `integrations/photon/src/index.ts`
- **Reminder recipient**

### Last Seen wearable

- [Last Seen app](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/__main__.py): `lastseen-wearable/lastseen/__main__.py`
- [Camera capture](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/capture/camera.py): `lastseen-wearable/lastseen/capture/camera.py`
- [Vision and tracking loop](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/engine/vision_loop.py): `lastseen-wearable/lastseen/engine/vision_loop.py`
- [Wearable configuration](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/config.py): `lastseen-wearable/lastseen/config.py`
- [Memory store](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/memory/store.py): `lastseen-wearable/lastseen/memory/store.py`
- [Clip memory](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/memory/clips.py): `lastseen-wearable/lastseen/memory/clips.py`
- [Question answering](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/brain/answer.py): `lastseen-wearable/lastseen/brain/answer.py`
- [Lost-sight prompts](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/proactive/lost_sight.py): `lastseen-wearable/lastseen/proactive/lost_sight.py`
- [Dashboard and API](https://github.com/rayhanrinzan/keepsake/blob/main/lastseen-wearable/lastseen/server/app.py): `lastseen-wearable/lastseen/server/app.py`

### Other components

- **Camera wearer**

## Connections

- Camera wearer → Camera capture: wears camera (evidence: `README.md`)
- Camera capture → Item detection: sends frames (evidence: `README.md`)
- Item detection → Detection verification: checks detections (evidence: `README.md`)
- Item detection → Sighting memory: updates sightings (evidence: `README.md`)
- Item detection → Observation events: emits observations (evidence: `README.md`)
- Item detection → Photo snapshots: captures photos (evidence: `README.md`)
- Sighting memory → SQLite records: persists records (evidence: `backend/main.py`)
- Observation events → SQLite records: stores events (evidence: `README.md`)
- Photo snapshots → SQLite records: stores metadata (evidence: `backend/database.py`)
- Keepsake API → SQLite records: reads records (evidence: `backend/main.py`)
- Keepsake API → Sighting memory: clears memory (evidence: `backend/main.py`)
- Keepsake API → Photo snapshots: serves photos (evidence: `backend/main.py`)
- Keepsake API → Reminder engine: uses reminders (evidence: `backend/main.py`)
- Web app → Web API client: loads data (evidence: `frontend/src/App.tsx`)
- Web app → Web voice: handles voice (evidence: `frontend/src/App.tsx`)
- Web API client → Keepsake API: requests data (evidence: `README.md`)
- Mobile app → Mobile API client: loads items (evidence: `mobile/src/app/index.tsx`)
- Mobile API client → Keepsake API: requests data (evidence: `mobile/src/lib/api.ts`)
- Photon agent → Keepsake API: retrieves memories
- Photon agent → Reminder recipient: sends reminders (evidence: `README.md`)
- Camera capture → Vision and tracking loop: provides frames (evidence: `lastseen-wearable/lastseen/__main__.py`)
- Vision and tracking loop → Memory store: stores tracking
- Vision and tracking loop → Clip memory: uses clips (evidence: `lastseen-wearable/lastseen/engine/vision_loop.py`)
- Vision and tracking loop → Wearable configuration: uses settings (evidence: `lastseen-wearable/lastseen/engine/vision_loop.py`)
- Dashboard and API → Memory store: serves item data
- Dashboard and API → Clip memory: serves clips
- Dashboard and API → Question answering: routes questions
- Lost-sight prompts → Question answering: uses intents (evidence: `lastseen-wearable/lastseen/proactive/lost_sight.py`)
- Last Seen app → Dashboard and API: exposes dashboard (evidence: `README.md`)
