Skip to main content

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

The .glyph/ folder is derived data. It can be safely deleted and will regenerate on next space open. Do not sync it.

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.db
src-tauri/src/index/db.rs
3

Start filesystem watcher

Monitor notes/ directory for changes
src-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

The space.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)

Accessed via Tauri’s state management:

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
Usage:
src-tauri/src/space_fs/read_write/text.rs

Schema Migration

Glyph uses a hard cutover migration policy. When schema version changes:
  • Old app versions cannot open new spaces
  • New app versions cannot open old spaces
  • Users must export data and re-import
This is intentional to keep the codebase simple.

Version Check

src-tauri/src/space/commands.rs