Architecture Overview
Basic Memory consists of four main components working together:Markdown Files
Your knowledge lives in plain Markdown files on disk. These are the source of truth - you maintain complete ownership and they work with git, Obsidian, and any text editor.
SQLite Database
A local database indexes your files for fast search and graph traversal. The database is derived from files and can be rebuilt at any time.
Model Context Protocol
The MCP server exposes tools that let AI assistants read, write, search, and navigate your knowledge graph through a standardized protocol.
From Files to Knowledge Graph
When you add or modify a Markdown file, Basic Memory extracts semantic structure to build the knowledge graph:Step 1: File Detection
The sync engine watches your project directory for changes:- New files → parsed and indexed
- Modified files → re-parsed and updated
- Deleted files → removed from database
Step 2: Markdown Parsing
The parser (usingmarkdown-it with custom plugins) extracts:
- Frontmatter - YAML metadata between
---fences - Observations - List items matching
- [category] content - Relations - Wiki links in list items or prose:
[[Target]] - Content - Everything else preserved as-is
The parser is intelligent about what’s an observation. It excludes checkboxes (
- [ ] task), markdown links ([text](url)), and bare wiki links without context.Step 3: Entity Creation
Each Markdown file becomes an Entity in the knowledge graph:- ID: Database-generated unique identifier
- External ID: UUID for stable API references
- Permalink: Stable identifier (e.g.,
coffee-brewing-methods) - File Path: Relative path from project root
- Checksum: For change detection
- Metadata: Title, type, tags, and custom fields
Step 4: Observation Extraction
Observations become atomic facts linked to their entity:method, tip, and preference.
Step 5: Relation Building
Relations form the edges of your knowledge graph:- Explicit Relations
- Inline Relations
List items with relation type and wiki link:The text before
[[ becomes the relation type.Bidirectional Sync
Changes flow in both directions:Files → Database
- File watcher detects change
- Checksum computed and compared
- If different, file is parsed
- Database updated with new entities/observations/relations
- Old data cleaned up
Database → Files (AI Writes)
- AI assistant calls MCP tool (e.g.,
write_note) - MCP tool communicates with API
- API creates/updates database entities
- File is written with proper frontmatter
- Sync engine sees new file, validates consistency
Change Detection
Basic Memory uses multiple strategies for efficient change detection:- Checksums: SHA-256 hash of file content
- Modification time: File system mtime
- File size: Quick check before computing checksum
Database Backend
By default, Basic Memory uses SQLite for local storage:- Single file database (no server required)
- Full-text search with FTS5
- WAL mode for concurrent access
- Alembic migrations for schema evolution
MCP Integration
The Model Context Protocol server exposes your knowledge graph to AI assistants:Performance Characteristics
- Parsing: ~1000 files/second on modern hardware
- Search: Sub-millisecond for most queries (FTS5 indexed)
- Sync: Incremental, only changed files processed
- Memory: Lightweight - typical project uses less than 100MB RAM
Next Steps
Knowledge Graph
Learn about entities, observations, and relations
Markdown Format
Detailed syntax reference for notes