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
User selects directory
User chooses an empty or existing folder via native file picker
src/contexts/SpaceContext.tsx
Backend initializes structure
Rust backend creates directories and schema marker
src-tauri/src/space/commands.rs
Opening a Space
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
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.Backend computes hash
SHA256 hash of file contents determines storage path
src-tauri/src/notes/attachments.rs
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