mirror of
https://github.com/zadam/trilium.git
synced 2025-10-28 16:56:34 +01:00
Trilium Architecture Documentation
This comprehensive guide documents the architecture of Trilium Notes, providing developers with detailed information about the system's core components, data flow, and design patterns.
Table of Contents
- Three-Layer Cache System
- Entity System
- Widget-Based UI Architecture
- API Architecture
- Monorepo Structure
Overview
Trilium Notes is built as a TypeScript monorepo using NX, featuring a sophisticated architecture that balances performance, flexibility, and maintainability. The system is designed around several key architectural patterns:
- Three-layer caching system for optimal performance across backend, frontend, and shared content
- Entity-based data model supporting hierarchical note structures with multiple parent relationships
- Widget-based UI architecture enabling modular and extensible interface components
- Multiple API layers for internal operations, external integrations, and real-time synchronization
- Monorepo structure facilitating code sharing and consistent development patterns
Quick Start for Developers
If you're new to Trilium development, start with these sections:
- Monorepo Structure - Understand the project organization
- Entity System - Learn about the core data model
- Three-Layer Cache System - Understand data flow and caching
For UI development, refer to:
For API integration, see:
Architecture Principles
Performance First
- Lazy loading of note content
- Efficient caching at multiple layers
- Optimized database queries with prepared statements
Flexibility
- Support for multiple note types
- Extensible through scripting
- Plugin architecture for UI widgets
Data Integrity
- Transactional database operations
- Revision history for all changes
- Synchronization conflict resolution
Security
- Per-note encryption
- Protected sessions
- API authentication tokens
Development Workflow
-
Setup Development Environment
pnpm install pnpm run server:start -
Make Changes
- Backend changes in
apps/server/src/ - Frontend changes in
apps/client/src/ - Shared code in
packages/
- Backend changes in
-
Test Your Changes
pnpm test:all pnpm nx run <project>:lint -
Build for Production
pnpm nx build server pnpm nx build client