What is a Space?
A space is Glyph’s fundamental organizational unit. Each space is a directory on the user’s filesystem containing:- Notes - Markdown files with YAML frontmatter
- Assets - Content-addressed files (images, PDFs, etc.)
- Cache - Derived data (link previews, thumbnails)
- Metadata - Schema version and configuration
Spaces are portable. You can move a space folder anywhere, sync via Dropbox/iCloud, or manage it with Git.
Directory Structure
Space Lifecycle
Creating a Space
1
User selects directory
User chooses an empty or existing folder via native file picker
src/contexts/SpaceContext.tsx
2
Backend initializes structure
Rust backend creates directories and schema marker
src-tauri/src/space/commands.rs
3
Frontend updates state
SpaceContext tracks current space path
Opening a Space
1
Validate schema version
Ensure space is compatible with app version
2
Initialize SQLite index
Create or open
.glyph/index.dbsrc-tauri/src/index/db.rs
3
Start filesystem watcher
Monitor
notes/ directory for changessrc-tauri/src/space/watcher.rs
4
Rebuild index
Scan all notes and populate SQLite FTS
src/contexts/SpaceContext.tsx
Closing a Space
src/contexts/SpaceContext.tsx
Space.json Schema
Thespace.json file marks a directory as a Glyph space and tracks schema version.
space.json
number
required
Schema version. Current version is 1.If this doesn’t match
CURRENT_SCHEMA_VERSION in Rust code, the space cannot be opened.Content-Addressed Storage
Assets (images, PDFs, etc.) are stored by SHA256 hash to deduplicate files.1
User attaches file
File is selected via file picker
2
Backend computes hash
SHA256 hash of file contents determines storage path
src-tauri/src/notes/attachments.rs
3
Copy if not exists
Only copy file if hash doesn’t already exist
4
Return markdown link
Generate relative markdown link
Benefits
- Deduplication - Same image used in 10 notes = 1 file on disk
- Integrity - Hash mismatch = corrupted file
- Immutability - Content can’t change without changing hash
State Management
Backend State (src-tauri/src/space/state.rs)
Frontend State (src/contexts/SpaceContext.tsx)
Recent Spaces
Glyph tracks up to 20 recently opened spaces, stored in Tauri’s persistent store:src/lib/settings.ts
Path Safety
Preventing Path Traversal
All user-provided paths are validated to prevent traversal attacks:src-tauri/src/paths.rs
src-tauri/src/space_fs/read_write/text.rs
Schema Migration
Version Check
src-tauri/src/space/commands.rs