Skip to content

Architecture

Virgile Thonnier edited this page Jul 17, 2026 · 2 revisions

Architecture

SenseTree is a Tauri v2 desktop app: a Rust core exposing typed IPC commands to a React 19 / TypeScript / Tailwind v4 frontend.

React 19 + TS + Tailwind v4  (Explorer · Search · Meaning tree · Chat · Settings · Catalog)
            │  Tauri IPC (typed commands, see below)
Rust core (Tauri v2)
   crawler ─┐
   watchdog ┼─▶ indexing queue ─▶ worker ─▶ providers (embedding / reasoning / vision)
   folders ─┘                         │
   ┌───────────────┐   ┌────────────┐ │  ┌──────────────────────────┐
   │ SQLite (r2d2) │   │  LanceDB   │ └─▶│ fastembed/ONNX  OR  HTTP  │
   │ metadata+queue│   │  vectors   │    │ (OpenAI-compatible)       │
   └───────────────┘   └────────────┘    └──────────────────────────┘

Data stores

  • SQLite (rusqlite + r2d2 pool; WAL, busy_timeout, synchronous=NORMAL, FKs on) — file catalog, indexing queue (retry_count, last_error), extracted summaries (file_semantics), folder profiles, transaction log.
  • LanceDB (embedded, serverless) — one chunks table: id, path, chunk_index, text, content_hash, mtime, vector. Vector dimension is runtime-mutable (model changes recreate the table). Cosine search with optional path-prefix filter.

Backend modules (src-tauri/src/)

Module Role
lib.rs App setup, shared state, and all Tauri command registrations.
state.rs Shared AppState (DB, config, AI engine, vector store, pause flag, scan registry).
config.rs Persistent settings.json config + built-in default prompts.
providers.rs Model-agnostic AI: local fastembed embedder + OpenAI-compatible embedding/chat/vision clients; AiEngine resolves providers from config.
vectordb.rs LanceDB store: upsert, cosine search, delete/rename, mutable dimension.
db.rs SQLite layer (pool, schema/migrations, queue, semantics, transactions).
crawler.rs Initial recursive scan (the "past"); enqueues work; schedules re-scans; purges orphans.
watchdog.rs Real-time FS events (the "present"), debounced; syncs deletions/renames.
worker.rs Async pipeline: extract → hash → chunk → embed → store; vision + context paths; retries.
folders.rs Recursive-vs-block classifier (heuristics + block_bias + LLM).
classifier.rs Background retry of folders whose classification was deferred.
parser.rs File-type routing (text / document / image / AI-routing / ignored).
chunker.rs Text chunking (size + overlap).
search.rs Query embedding → LanceDB nearest neighbors → disk-verified, de-duplicated hits.
actions.rs Dry-Run planning + transactional apply/rollback + gardener analysis.
explorer.rs Live filesystem listing joined with index status; path details.
catalog.rs Live vision/reasoning benchmarks (OpenCompass / OpenVLM).
benchmarks.rs Live embedding benchmarks (official MTEB leaderboard API).
installs.rs Resolve a model's Ollama/LM Studio install name (GGUF resolution).
ort_setup.rs Provision ONNX Runtime (dynamic loading) for fastembed.
main.rs Binary entry point.

Frontend (src/)

File Role
App.tsx Three-panel layout, state, indexing polling, pause/resume.
components/Sidebar.tsx Indexed roots + health + Settings.
components/Explorer.tsx File list with semantic tags + index status.
components/TreeView.tsx Meaning-tree view.
components/ChatPanel.tsx Assistant chat.
components/ActionPlanCard.tsx Before → After Dry-Run diff with Approve/Discard.
components/DetailDrawer.tsx Per-file details incl. extracted sense.
components/SettingsModal.tsx Providers, indexing, prompts, and the model catalog.
components/ModelCatalog.tsx Per-task live catalog with download + endpoint auto-switch.
components/GardenerModal.tsx Directory audit UI.
lib/ipc.ts Typed wrappers over Tauri commands.
lib/types.ts, lib/models.ts, lib/format.ts Shared types/helpers.

IPC command surface

Config & health: get_config, set_config, get_default_prompts, ai_health, test_chat_endpoint, test_embedding_endpoint, gpu_available. Indexing: indexing_stats, get_recent_activity, set_indexing_paused, indexing_paused, reindex_all, get_roots, add_indexed_folder, remove_indexed_folder, pick_folder, set_folder_mode. Explore & search: list_directory, path_details, open_path, semantic_search, semantic_tree. Models: list_installed_models, list_local_models, download_local_model, pull_model, resolve_installs, model_benchmarks, list_benchmark_boards, vision_benchmarks, list_vision_boards, reasoning_benchmarks, list_reasoning_boards. Chat & actions: chat_with_assistant, plan_reorganization, apply_action_plan, discard_action_plan, analyze_directory.

Key dependencies

Rust: tauri v2, lancedb, rusqlite+r2d2, fastembed+ort, reqwest (rustls), notify+notify-debouncer-mini, pdf-extract/lopdf, zip, sha2, arrow-*, tokio, tracing. Frontend: react 19, @tauri-apps/api, lucide-react, tailwindcss v4, vite, typescript.

Clone this wiki locally