Introduction
Philo is a modern desktop application built using Tauri 2.0, combining a Rust backend with a React frontend. This hybrid architecture provides native performance, security, and cross-platform compatibility while leveraging the rich ecosystem of web technologies for the user interface.High-Level Architecture
Core Components
1. Tauri Backend (Rust)
The Rust backend (src-tauri/) provides:
- Tauri Commands: Exposed Rust functions callable from JavaScript via IPC (Inter-Process Communication)
- File I/O Operations: Reading and writing markdown files with error handling
- Markdown Operations: Parsing frontmatter, extracting titles, searching content
- Vault Management: Obsidian vault detection, folder structure management
- Full-Text Search: SQLite with FTS5 for fast content search across markdown files
- Native OS Integration: Menu building (macOS), window opacity, process management
read_markdown_file(path)- Read markdown file contentwrite_markdown_file(path, content)- Write markdown file with directory creationsearch_markdown(root_dir, query)- Full-text search using SQLite FTS5detect_obsidian_settings(vault_path)- Auto-detect Obsidian configurationbootstrap_obsidian_vault(vault_path, options)- Initialize vault structurescan_obsidian_vaults(start_dir)- Discover Obsidian vaults on filesystemextend_fs_scope(path)- Dynamically extend file system permissionsset_window_opacity(opacity)- macOS-specific window transparency
2. React Frontend (TypeScript)
The React frontend (src/) handles all UI rendering and user interactions:
- Component Architecture: Modular React components organized by feature
- TipTap Editor: Rich text editing with custom extensions
- State Management: React hooks (useState, useEffect, custom hooks)
- Styling: Tailwind CSS with custom typography plugin
- Type Safety: Full TypeScript coverage with strict mode
3. Build System
- Vite: Fast development server and optimized production builds
- HMR (Hot Module Replacement): Instant feedback during development
- TypeScript Compiler: Type checking and transpilation
- Tauri CLI: Orchestrates Rust compilation and frontend bundling
Data Flow
Reading Markdown Files
Writing Markdown Files
Full-Text Search
Widget Generation and Rendering
Security Model
Tauri provides a robust security model:- IPC Validation: All commands validated at Rust boundary
- Scoped File System: Frontend can only access explicitly allowed paths
- Asset Protocol: Secure image/file loading with scope restrictions
- No Remote Code Execution: Frontend cannot execute arbitrary system commands
- Content Security Policy: Configurable CSP for webview content
Extension Points
Custom TipTap Extensions
Philo extends TipTap with custom node types:- WidgetExtension: Embeds interactive UI components using JSON-Render
- ExcalidrawExtension: Embeds Excalidraw diagrams with live editing
- HashtagExtension: Syntax highlighting and navigation for hashtags
- CustomTaskItem: Enhanced task items with better markdown serialization
- CustomParagraph: Improved paragraph handling for markdown compatibility
- Node Schema: Structure and attributes
- Parsing Rules: Markdown → TipTap JSON
- Serialization Rules: TipTap JSON → Markdown
- NodeView: React component for rendering (if needed)
- Commands: Editor commands for insertion/manipulation
Service Layer
Services abstract business logic and Tauri command invocations:storage.ts- Daily note CRUD operationslibrary.ts- Search, collections, library managementobsidian.ts- Vault detection, settings parsing, bootstrappingimages.ts- Image handling, asset URL resolutionexcalidraw.ts- Excalidraw data compression and decompressiongenerate.ts- Widget generation via AI APItasks.ts- Task extraction and manipulationformat.ts- Date formatting utilitiespaths.ts- Path resolution and normalization
Performance Considerations
Rust Backend
- File I/O operations are synchronous but fast (native performance)
- SQLite FTS5 provides millisecond search times for thousands of documents
- Incremental indexing: Only reindex modified files based on mtime
- Directory traversal skips common non-vault folders (node_modules, .git, etc.)
React Frontend
- Debounced saves (500ms) prevent excessive file writes
- TipTap uses ProseMirror for efficient document updates
- Virtual scrolling for large lists (library, search results)
- Lazy loading of images and heavy components
- React.StrictMode enabled for development safety
Communication Overhead
- IPC calls are fast (typically <1ms for simple commands)
- Large payloads (markdown content) compressed when necessary
- Batch operations where possible to reduce round trips
Cross-Platform Support
Philo supports macOS, Windows, and Linux:- Platform-specific code uses
#[cfg(target_os)]directives - macOS-specific features: window opacity, process name
- Paths normalized for each OS (/ vs \)
- Asset protocol scope accounts for different app data locations
Development Workflow
- Starts Vite dev server on port 1421
- Compiles Rust backend with hot reload
- Opens webview window with HMR enabled
- Watches both frontend and backend for changes
Next Steps
- Tech Stack - Detailed breakdown of all dependencies
- File Structure - Complete directory organization
- Contributing - Learn how to contribute to Philo