How pyranthus-hq/mora works
1. Top-level shape
Mora is a local-first personal memory system implemented in Go. The repo is centered around one executable (cmd/mora) and a large internal/mora orchestration layer that ties together connectors, indexing, retrieval, synthesis, MCP serving, sharing, and background sync.
2. Primary data boundary: the vault
The core architectural boundary is the vault, a folder of Markdown files on disk, backed by a SQLite index in a separate local data directory. The vault is the durable source of truth; the index is disposable and rebuildable. Configuration, OAuth tokens, and sync watermarks live in separate per-user config/state directories.
3. Source connectors
Ingestion starts from source-specific adapters under internal/google, internal/imessage, internal/applecal, and the local-file/memory path in internal/memory. These connectors read from external systems such as Gmail, Google Calendar, iMessage chat databases, Apple Calendar, and filesystem documents, then normalize source records into Mora’s internal model.
4. Normalization and mapping
Each connector has its own mapping layer that converts source-native IDs, timestamps, identities, and thread/event structures into Mora’s canonical objects. This is where cross-source consistency is established: the same person, thread, or event can be linked across mail, messages, and calendar items before anything is written to the vault.
5. Ingest pipeline
The ingest path turns connector output into Markdown artifacts and updates the SQLite index. This is an important write boundary: the system fetches read-only from external sources, but all durable memory creation happens locally in the vault/index pair. The ingest code also handles incremental sync via per-source watermarks so only new or changed items are reprocessed.
6. Search and retrieval
Retrieval is hybrid. The index supports keyword search (BM25), and optional local semantic search can be enabled through an Ollama embedder. Query handling combines lexical search, embeddings, and graph expansion, then re-ranks results for recall and citation quality. This is the main read path used by the CLI and MCP tools.
7. Entity graph
Mora builds a deterministic entity graph over people, addresses, threads, chats, meetings, and tasks. The graph layer is used to unify identity across sources and to answer questions like “what do we know about this person?” The graph is not a separate database; it is derived from indexed vault content and metadata.
8. Synthesis features
Higher-level outputs such as think, brief, digest, meeting prep, and salience ranking are built on top of retrieval and the entity graph. These features do not replace search; they package retrieved evidence into task-oriented views with explicit citations and “gap” detection, so the agent can reason from source-backed memory rather than free-form generation.
9. Interface surfaces: CLI and MCP
The repository exposes the same capabilities through two entry points:
- a CLI for direct shell use
- an MCP server (mora mcp serve) for Claude Code, Codex, Gemini CLI, Cursor, and other clients
The MCP layer is just a local stdio service; it does not proxy to a remote backend. This keeps the agent integration boundary entirely on-device.
10. Background operation and freshness
Mora includes scheduling and loop/hook machinery for recurring sync and freshness maintenance. The architecture treats freshness as a first-class concern: search results and synthesis output can report how current each source is, and scheduled jobs keep the vault updated without requiring a resident server.
11. Sharing and export paths
There are two explicit egress mechanisms:
- git sync for backing up the vault to a private repository
- encrypted sharing for publishing selected authored memories to a separate remote, with per-recipient encryption and a required preview of what leaves
These flows are intentionally separate from normal retrieval and ingest so the default operating mode remains zero-egress.
12. Platform boundaries
The repo is mostly cross-platform Go, but some connectors and integrations are platform-specific: iMessage, Apple Calendar, and Address Book depend on macOS; Windows has its own install/uninstall and Task Scheduler support; Linux/macOS/Windows all support the Google and filesystem-based paths. The codebase includes OS-specific files to keep these boundaries clean.
13. Operational and distribution layer
Packaging is handled by release tooling (goreleaser, GitHub Actions, install scripts). These are not runtime dependencies, but they shape how the binary is distributed and self-updated. The project is intentionally “pure Go, no CGO,” which simplifies cross-platform deployment and local-only operation.
14. Testing and evaluation as architecture support
The large test surface is part of the design: there are connector tests, retrieval tests, graph tests, MCP tests, and evaluation/sweep artifacts. This indicates the architecture is optimized around correctness of ingestion, ranking, freshness, and citation quality rather than around a single monolithic app flow.
Main entry points: ingest.go Ingest · search.go Search · usage.go CLI commands · mcp.go MCP server
Components 21
Entry points
Executable and external interfaces
- mora CLI · Primary executable entrypoint.
cmd/mora/main.go - MCP server · Local agent-facing tool server.
internal/mora/mcp.go - CLI commands · Shell-facing subcommands and UX routing.
internal/mora/usage.go
Core memory
Orchestration, storage, retrieval, and synthesis
- Setup · Config, vault, and runtime initialization.
internal/mora/setup.go - Vault ops · Local Markdown vault and filesystem writes.
internal/mora/vaultops.go - SQLite index · Persistent local index for lookup and rebuilds.
internal/mora/index.go - Ingest · Turns source records into vault artifacts and index updates.
internal/mora/ingest.go - Search · Hybrid retrieval orchestration across lexical, semantic, and graph signals.
internal/mora/search.go - Hybrid rank · Combines BM25, embeddings, and reranking.
internal/mora/hybrid.go - Entity graph · Deterministic identity and relationship graph from indexed content.
internal/mora/graph.go - Entities · People, threads, chats, meetings, tasks, and related links.
internal/mora/entities.go - Think · Evidence-backed reasoning and gap-aware answers.
internal/mora/think.go - Digest · Task-oriented summaries and salience views.
internal/mora/digest.go
Connectors
Source-specific ingestion adapters
- Google · Gmail and Calendar ingestion.
internal/google/gmail.go - iMessage · macOS Messages and address book ingestion.
internal/imessage/chatdb.go - Apple Cal · Apple Calendar ingestion.
internal/applecal/applecal.go - Memory files · Filesystem and local memory ingestion path.
internal/memory/ingest.go
Operations
Sync, sharing, distribution, and maintenance
- Scheduler · Recurring sync, hooks, and freshness maintenance.
internal/mora/schedule.go - Sharing · Vault export, manifests, and encrypted publishing.
internal/mora/share.go - Git sync · Backs up the vault to a git repository.
internal/mora/gitsync.go - Release ops · Packaging and install/uninstall tooling for distribution.
scripts/build-release.sh
Connections 30
- mora CLI → Setup: bootstraps · Initializes config, vault, and runtime state.
- mora CLI → CLI commands: exposes · Routes shell commands through the CLI layer.
- mora CLI → MCP server: serves · Starts the local MCP stdio service.
- Setup → Vault ops: opens · Locates and prepares the local vault boundary.
- Setup → SQLite index: opens · Initializes or validates the SQLite index.
- CLI commands → Ingest: invokes · Triggers ingestion and reingest flows.
- CLI commands → Search: queries · Uses the retrieval path for user search.
- CLI commands → Think: runs · Exposes synthesis-oriented commands.
- CLI commands → Digest: runs · Exposes summary and digest commands.
- MCP server → Search: tools · Agent tools are backed by the search pipeline.
- MCP server → Think: tools · Agent-facing reasoning tools use synthesis.
- MCP server → Digest: tools · Digest and briefing tools are served over MCP.
- Google → Ingest: feeds · Normalized records enter the ingest pipeline.
- iMessage → Ingest: feeds · Messages and address book data are normalized for ingest.
- Apple Cal → Ingest: feeds · Calendar events are normalized for ingest.
- Memory files → Ingest: feeds · Local files and memory content are ingested.
- Ingest → Vault ops: writes · Materializes Markdown artifacts in the vault.
- Ingest → SQLite index: updates · Upserts local index entries after ingest.
- Search → SQLite index: reads · Primary lexical and metadata lookup source.
- Search → Hybrid rank: routes · Delegates ranking and fusion to hybrid retrieval.
- Hybrid rank → Entity graph: expands · Uses graph traversal and related entities to broaden recall.
- Entity graph → Entities: derives from · Graph structure is built from entity and relation metadata.
- Think → Search: depends on · Reasoning packages retrieved evidence.
- Digest → Search: depends on · Digest generation starts from retrieval.
- Digest → Entity graph: uses · Salience and entity context inform digests.
- Scheduler → Ingest: triggers · Recurring freshness jobs drive sync and ingest.
- Scheduler → Search: annotates · Freshness metadata influences read results.
- Sharing → Vault ops: exports · Selects authored memories from the local vault.
- Git sync → Vault ops: backs up · Pushes the vault to git for backup and sync.
- Release ops → mora CLI: packages · Distribution tooling builds and installs the binary.