How dev07060/mobile_rag_engine works
Mobile RAG Engine is a Flutter package whose Rust core supports private, on-device document retrieval. The main workflow is local document input → extraction and chunking → embedding → persistent indexing → hybrid search → hydrated, budgeted context for the host app’s LLM. The graph also preserves collection/index management and the simple RAG API. Dart implementation files are absent from the supplied tree, so the Flutter facade and embedding orchestration are represented only as documented host-app responsibilities; implementation edges are limited to documented or indexed relationships.
Main entry points: source_rag.rs Source RAG API · hybrid_search.rs Hybrid search · db_pool.rs SQLite connection pool · frb_generated.rs Flutter Rust bridge
Components 19
Document ingestion
- Document input
- Document parser
rust_builder/rust/src/api/document_parser.rs - Semantic chunker
rust_builder/rust/src/api/semantic_chunker.rs - Ingest session
rust_builder/rust/src/api/ingest_session.rs - Source RAG API
rust_builder/rust/src/api/source_rag.rs - Tokenizer
rust_builder/rust/src/api/tokenizer.rs
Retrieval and context
- Hybrid search
rust_builder/rust/src/api/hybrid_search.rs - BM25 search
rust_builder/rust/src/api/bm25_search.rs - Vector math
rust_builder/rust/src/api/vector_math.rs - Simple RAG API
rust_builder/rust/src/api/simple_rag.rs - Context assembly
rust_builder/rust/src/api/source_rag.rs
Persistence and indexing
- HNSW index
rust_builder/rust/src/api/hnsw_index.rs - Vector quantization
rust_builder/rust/src/api/vector_quant.rs - SQLite connection pool
rust_builder/rust/src/api/db_pool.rs - Memory-mapped store
rust_builder/rust/src/api/mmap_store.rs - Index migration
rust_builder/rust/src/api/migration_meta.rs
Rust and Flutter bridge
- Flutter Rust bridge
rust_builder/rust/src/frb_generated.rs
Other components
- Flutter host app
- On-device embedder
Connections 25
- Flutter host app → Document input: provides documents
- Document input → Source RAG API: ingests locally
- Source RAG API → Document parser: extracts text
rust_builder/rust/src/frb_generated.rs - Document parser → Semantic chunker: chunks text
rust_builder/rust/src/api/document_parser.rs - Source RAG API → Ingest session: prepares ingestion
rust_builder/rust/src/api/ingest_session.rs - Ingest session → On-device embedder: requests embeddings
- On-device embedder → Ingest session: returns vectors
- Ingest session → SQLite connection pool: commits chunks
rust_builder/rust/src/api/ingest_session.rs - Source RAG API → SQLite connection pool: persists sources
rust_builder/rust/src/api/source_rag.rs - Flutter host app → Flutter Rust bridge: calls Rust API
- Flutter Rust bridge → Source RAG API: dispatches calls
rust_builder/rust/src/frb_generated.rs - Flutter Rust bridge → Hybrid search: dispatches search
rust_builder/rust/src/frb_generated.rs - Hybrid search → BM25 search: runs keyword search
rust_builder/rust/src/api/hybrid_search.rs - Hybrid search → HNSW index: runs vector search
rust_builder/rust/src/api/hybrid_search.rs - Hybrid search → SQLite connection pool: reads search data
rust_builder/rust/src/api/hybrid_search.rs - HNSW index → Vector quantization: uses quantization
rust_builder/rust/src/api/hnsw_index.rs - Hybrid search → Vector math: scores vectors
rust_builder/rust/src/api/hybrid_search.rs - HNSW index → Memory-mapped store: loads mapped index
rust_builder/rust/src/api/hnsw_index.rs - Source RAG API → Context assembly: assembles context
rust_builder/rust/src/api/source_rag.rs - Context assembly → Tokenizer: budgets tokens
rust_builder/rust/src/api/source_rag.rs - Flutter Rust bridge → Simple RAG API: dispatches simple API
rust_builder/rust/src/frb_generated.rs - Simple RAG API → SQLite connection pool: stores documents
rust_builder/rust/src/api/simple_rag.rs - Simple RAG API → BM25 search: rebuilds keyword index
rust_builder/rust/src/api/simple_rag.rs - Index migration → SQLite connection pool: uses pooled connection
rust_builder/rust/src/api/migration_meta.rs - Flutter host app → Source RAG API: scopes collections