Files
momentry_core/docs_v1.0/REFERENCE/Architecture_Reference.md
T

8.7 KiB

title, version, date, author, status
title version date author status
Momentry Core Architecture Reference 1.3.5 2026-10-25 Core Team Active

Momentry Core Architecture Reference

Search Architecture

1. Search Types & Data Sources

Search Type Core Mechanism Data Source Storage Notes
Keyword Search PostgreSQL ts_rank FTS asrx.json (chunks), ocr.json PostgreSQL chunks BM25 full-text search
Semantic Search PostgreSQL FTS + Qdrant Vector asrx.json (chunks) only PostgreSQL + Qdrant _chunks EmbeddingGemma-300m (768D)
Visual Search Qdrant Vector Similarity 10s scenes + face trace FS keyframes (VLM) Qdrant _scenes + _vlm Gemma4 VLM descriptions
People Search SQLite TEXT match face_cluster.json (group names) SQLite trace_profiles ILIKE fuzzy match on names

2. JSON Data Lineage

video.mp4
  ↓ (ASR processor)
{file_uuid}.asr.json → (ONLY intermediate input for asrx tool, NOT used for search)
  ↓ (ASRX processor)
{file_uuid}.asrx.json → (Authoritative source for Keyword + Semantic search)

Key Clarification:

  • asr.json: Raw ASR output, used ONLY as input for the asrx processor
  • asrx.json: Speaker-aware ASR output, feeds BOTH Keyword and Semantic search
  • ocr.json: OCR text output, feeds Keyword search only
  • face_cluster.json: Face clustering output, feeds People Search (TEXT only)

3. Face / Identity Data Flow

Component Purpose Vector/Search Notes
Face 512D ONLY for rust_face_cluster tool NOT used for search FaceNet CoreML embeddings
Group Name People Search TEXT matching SQLite TEXT (ILIKE) From face_cluster.json
Identity Placeholder field - Currently unused
Trace Profile Face trace metadata + VLM annotations PostgreSQL + SQLite Contains name, vlm_* fields

4. VLM & Qdrant Vector Search Architecture

VLM Source Analysis Target Output Qdrant Collection Search Type
Scene VLM (scene_vlm.rs) 10-second scene frames Scene description vectors _scenes Semantic vector search
Trace VLM (vlm_summary.rs) Face trace FS keyframes Person description vectors _vlm Semantic vector search

VLM Dual-Source Flow:

┌─────────────────────────────────────────────────────────────────┐
│                        VLM Processing                           │
├──────────────────────────┬──────────────────────────────────────┤
│ Scene VLM                │ Trace VLM                            │
│ - Analyzes 10s scenes    │ - Analyzes face trace FS keyframes   │
│ - Generates descriptions │ - Generates person descriptions      │
│ - Embeds to Qdrant       │ - Embeds to Qdrant                   │
│   `_scenes` collection    │   `_vlm` collection                  │
└──────────────────────────┴──────────────────────────────────────┘
          │                                      │
          └──────────────┬───────────────────────┘
                         ▼
              Qdrant Vector Search
         (Cosine similarity on 768D embeddings)

Implementation Files:

  • Scene VLM: /Users/accusys/momentry_core/src/core/processor/scene_vlm.rs
  • Trace VLM: /Users/accusys/momentry_core/src/core/processor/vlm_summary.rs
  • Qdrant upsert: /Users/accusys/momentry_core/src/core/db/qdrant_db.rs
    • upsert_scene_embedding() → _scenes collection
    • upsert_vlm_embedding() → _vlm collection
  • Search endpoints: /Users/accusys/momentry_core/src/api/vlm_search.rs
    • POST /api/v1/search/vlm/scenes
    • POST /api/v1/search/vlm/traces

Pipeline Stages & JSON Outputs

Stage 1: Media Analysis

Primary Output: {file_uuid}.workspace.sqlite

JSON Outputs (7 files):

Filename Content Purpose Used For
{file_uuid}.probe.json Video metadata File info Registration
{file_uuid}.asr.json Raw ASR result Speech recognition Input to asrx tool only
{file_uuid}.face.json Face detections Face locations Face tracing
{file_uuid}.ocr.json OCR text Text recognition Keyword search
{file_uuid}.cut.json Scene boundaries Scene cuts Chunking
{file_uuid}.asrx.json Speaker-aware ASR Speaker segments Keyword + Semantic search
{file_uuid}.scenes.json Scene detection Scene info Scene VLM

Stage 2: Text Chunks

Primary Output: PostgreSQL chunks table

  • Sourced from asrx.json (NOT asr.json)
  • Feeds Keyword (BM25) and Semantic (vector) search

Stage 3: Face Tracing

Primary Output: {file_uuid}.face_traced.json

  • 8Hz sampling face tracking
  • Feed to clustering and VLM

Stage 4: Face Clustering

Primary Output: {file_uuid}.face_cluster.json

  • Groups face traces by similarity using FaceNet 512D embeddings
  • 512D vectors are ONLY used here for clustering, not search
  • Produces group_name for People Search TEXT matching

Stage 5: Identity Binding

Primary Output: PostgreSQL identities + identity_bindings tables

  • Cross-file identity management
  • Identity field currently placeholder in People Search

Stage 6: Knowledge Graph (TKG)

Primary Output: PostgreSQL tkg_nodes + tkg_edges tables

  • Graph relationships between entities
  • Enables Agent TKG tools

Stage 7: Vector Index (Qdrant)

Primary Output: Qdrant Collections

Collection Content Source Dimension
_chunks Text chunk embeddings asrx.json chunks 768D
_faces Face embeddings Face detections 512D
_scenes Scene VLM embeddings 10s scene frames 768D
_vlm Trace VLM embeddings Face trace FS keyframes 768D

Stage 8: VLM Processing

Dual VLM Pipeline:

VLM Type Input Output Qdrant Collection
Scene VLM 10s scene frames Scene descriptions + vectors _scenes
Trace VLM Face trace FS keyframes Person descriptions + vectors _vlm

API Endpoint Reference

Search Endpoints

Method Endpoint Type Data Source Auth
POST /api/v1/search/smart Semantic Qdrant _chunks + PostgreSQL API Key
POST /api/v1/search/universal Multi-type (BM25) PostgreSQL FTS API Key
POST /api/v1/search/frames Visual filter YOLO/OCR/Face data API Key
POST /api/v1/search/llm-smart LLM reranked Smart search + Gemma4 API Key
GET /api/v1/search/people TEXT match SQLite trace_profiles API Key
POST /api/v1/search/vlm/scenes Vector Qdrant _scenes API Key
POST /api/v1/search/vlm/traces Vector Qdrant _vlm API Key
POST /api/v1/agent/search Agent routing All above API Key

Configuration & Environment

Key Environment Variables

Variable Default Purpose
MOMENTRY_SERVER_PORT 3002 API server port
MOMENTRY_REDIS_PREFIX momentry: Redis key prefix
MOMENTRY_OUTPUT_DIR /Users/accusys/momentry/output Processing output
DATABASE_URL postgres://accusys@localhost:5432/momentry PostgreSQL
MOMENTRY_LLM_CHAT_URL http://localhost:8080/v1/chat/completions Gemma4 Chat/Summary
MOMENTRY_LLM_VISION_URL http://localhost:8080/v1/chat/completions Gemma4 VLM (with mmproj)
MOMENTRY_LLM_SUMMARY_URL http://localhost:8080/v1/chat/completions Gemma4 Summary

LLM Services

Service Model Port API Format Purpose
Chat/Summary/VLM gemma-4-12b-it 8080 /v1/chat/completions Unified text + vision
Embedding embeddinggemma-300m 11436 Custom 768D embeddings

Version History

Version Date Changes
1.0 2026-10-25 Initial architecture reference
1.1 2026-10-25 Corrected JSON lineage (asr.json → asrx.json), People Search TEXT mechanism, Face 512D scope, VLM dual-source architecture