# rayfengleixing/tsflowy architecture

> Architecture diagram of the GitHub repository rayfengleixing/tsflowy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rayfengleixing/tsflowy
- Repository: https://github.com/rayfengleixing/tsflowy

## Overview

TsFlowy is a local-first desktop notes and knowledge-management app. The main workflow starts in the workspace page tree, opens a document editor or a database view, and persists content through frontend APIs, Tauri IPC, Rust commands, and SQLite. Search, trash, settings, and workspace import/export are additional product branches documented in the README. The tree and sampled excerpts support the application entry point, database flow, and persistence boundary; links for unsampled feature internals are limited to documented capabilities.

Main entry points: [`src-tauri/src/lib.rs`](https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/lib.rs) (Tauri command bridge), [`src/App.tsx`](https://github.com/rayfengleixing/tsflowy/blob/main/src/App.tsx) (Application shell), [`src/stores/database.ts`](https://github.com/rayfengleixing/tsflowy/blob/main/src/stores/database.ts) (Database state), [`src/stores/workspace.ts`](https://github.com/rayfengleixing/tsflowy/blob/main/src/stores/workspace.ts) (Workspace state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["Workspace navigation"]
  node_app["Application shell<br/>[App.tsx]"]
  node_workspace["Workspace state<br/>[workspace.ts]"]
  node_sidebar["Page tree<br/>[Sidebar.tsx]"]
end

subgraph group_documents["Document editing"]
  node_editor["Document editor<br/>[EditorPage.tsx]"]
  node_editorstate["Editor state<br/>[editor.ts]"]
  node_documentsapi["Document API<br/>[documents.ts]"]
end

subgraph group_databases["Database views"]
  node_dbpage["Database page<br/>[DatabasePage.tsx]"]
  node_views["Grid board calendar<br/>[GridView.tsx]"]
  node_dbstate["Database state<br/>[database.ts]"]
  node_query["Filter and sort logic<br/>[database-query.ts]"]
  node_formula["Formula evaluation"]
  node_aggregate["Column summaries"]
end

subgraph group_backend["Local persistence"]
  node_frontenddb["Database API<br/>[database.ts]"]
  node_ipc["Tauri command bridge<br/>[lib.rs]"]
  node_commands["Persistence commands<br/>[db.rs]"]
  node_rustdb["Database operations<br/>[database.rs]"]
  node_sqlite[("Local SQLite store<br/>[database.rs]")]
  node_files["Asset commands<br/>[files.rs]"]
end

subgraph group_operations["Search and operations"]
  node_searchui["Global search"]
  node_searchlib["Search service<br/>[search.ts]"]
  node_trash["Recycle bin<br/>[TrashPage.tsx]"]
  node_settings["Settings and backup<br/>[SettingsPage.tsx]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"initializes"| node_workspace
node_app -->|"renders"| node_sidebar
node_workspace -->|"provides tree"| node_sidebar
node_app -->|"routes to"| node_editor
node_app -->|"routes to"| node_dbpage
node_editor -->|"edits through"| node_editorstate
node_editorstate -->|"persists via"| node_documentsapi
node_documentsapi -->|"invokes"| node_ipc
node_dbpage -->|"selects view"| node_views
node_views -->|"loads and edits"| node_dbstate
node_dbstate -->|"filters and sorts"| node_query
node_dbstate -->|"computes values"| node_formula
node_dbstate -->|"summarizes"| node_aggregate
node_dbstate -->|"persists via"| node_frontenddb
node_frontenddb -->|"invokes"| node_ipc
node_ipc -->|"dispatches"| node_commands
node_commands -->|"calls"| node_rustdb
node_rustdb -->|"reads and writes"| node_sqlite
node_searchui -->|"searches through"| node_searchlib
node_searchlib -->|"invokes"| node_ipc
node_trash -->|"manages deleted pages"| node_ipc
node_settings -->|"configures"| node_workspace
node_settings -->|"imports and exports"| node_files
node_files -->|"registered with"| node_ipc

click node_app "https://github.com/rayfengleixing/tsflowy/blob/main/src/App.tsx"
click node_workspace "https://github.com/rayfengleixing/tsflowy/blob/main/src/stores/workspace.ts"
click node_sidebar "https://github.com/rayfengleixing/tsflowy/blob/main/src/features/sidebar/Sidebar.tsx"
click node_editor "https://github.com/rayfengleixing/tsflowy/blob/main/src/features/editor/EditorPage.tsx"
click node_editorstate "https://github.com/rayfengleixing/tsflowy/blob/main/src/stores/editor.ts"
click node_documentsapi "https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/documents.ts"
click node_dbpage "https://github.com/rayfengleixing/tsflowy/blob/main/src/features/database/DatabasePage.tsx"
click node_views "https://github.com/rayfengleixing/tsflowy/blob/main/src/features/database/GridView.tsx"
click node_dbstate "https://github.com/rayfengleixing/tsflowy/blob/main/src/stores/database.ts"
click node_query "https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/database-query.ts"
click node_formula "https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/database-formula.ts"
click node_aggregate "https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/database-aggregate.ts"
click node_frontenddb "https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/database.ts"
click node_ipc "https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/lib.rs"
click node_commands "https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/commands/db.rs"
click node_rustdb "https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/db/database.rs"
click node_sqlite "https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/db/database.rs"
click node_searchui "https://github.com/rayfengleixing/tsflowy/blob/main/src/features/search/SearchResultsPage.tsx"
click node_searchlib "https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/search.ts"
click node_trash "https://github.com/rayfengleixing/tsflowy/blob/main/src/features/trash/TrashPage.tsx"
click node_settings "https://github.com/rayfengleixing/tsflowy/blob/main/src/features/settings/SettingsPage.tsx"
click node_files "https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/commands/files.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_workspace,node_sidebar,node_user toneBlue
class node_editor,node_editorstate,node_documentsapi toneAmber
class node_dbpage,node_views,node_dbstate,node_query,node_formula,node_aggregate toneMint
class node_frontenddb,node_ipc,node_commands,node_rustdb,node_sqlite,node_files toneRose
class node_searchui,node_searchlib,node_trash,node_settings toneIndigo
```

## Components

### Workspace navigation

- [Application shell](https://github.com/rayfengleixing/tsflowy/blob/main/src/App.tsx): `src/App.tsx`
- [Workspace state](https://github.com/rayfengleixing/tsflowy/blob/main/src/stores/workspace.ts): `src/stores/workspace.ts`
- [Page tree](https://github.com/rayfengleixing/tsflowy/blob/main/src/features/sidebar/Sidebar.tsx): `src/features/sidebar/Sidebar.tsx`

### Document editing

- [Document editor](https://github.com/rayfengleixing/tsflowy/blob/main/src/features/editor/EditorPage.tsx): `src/features/editor/EditorPage.tsx`
- [Editor state](https://github.com/rayfengleixing/tsflowy/blob/main/src/stores/editor.ts): `src/stores/editor.ts`
- [Document API](https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/documents.ts): `src/lib/documents.ts`

### Database views

- [Database page](https://github.com/rayfengleixing/tsflowy/blob/main/src/features/database/DatabasePage.tsx): `src/features/database/DatabasePage.tsx`
- [Grid board calendar](https://github.com/rayfengleixing/tsflowy/blob/main/src/features/database/GridView.tsx): `src/features/database/GridView.tsx`
- [Database state](https://github.com/rayfengleixing/tsflowy/blob/main/src/stores/database.ts): `src/stores/database.ts`
- [Filter and sort logic](https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/database-query.ts): `src/lib/database-query.ts`
- [Formula evaluation](https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/database-formula.ts): `src/lib/database-formula.ts`
- [Column summaries](https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/database-aggregate.ts): `src/lib/database-aggregate.ts`

### Local persistence

- [Database API](https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/database.ts): `src/lib/database.ts`
- [Tauri command bridge](https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [Persistence commands](https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/commands/db.rs): `src-tauri/src/commands/db.rs`
- [Database operations](https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/db/database.rs): `src-tauri/src/db/database.rs`
- [Local SQLite store](https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/db/database.rs): `src-tauri/src/db/database.rs`
- [Asset commands](https://github.com/rayfengleixing/tsflowy/blob/main/src-tauri/src/commands/files.rs): `src-tauri/src/commands/files.rs`

### Search and operations

- [Global search](https://github.com/rayfengleixing/tsflowy/blob/main/src/features/search/SearchResultsPage.tsx): `src/features/search/SearchResultsPage.tsx`
- [Search service](https://github.com/rayfengleixing/tsflowy/blob/main/src/lib/search.ts): `src/lib/search.ts`
- [Recycle bin](https://github.com/rayfengleixing/tsflowy/blob/main/src/features/trash/TrashPage.tsx): `src/features/trash/TrashPage.tsx`
- [Settings and backup](https://github.com/rayfengleixing/tsflowy/blob/main/src/features/settings/SettingsPage.tsx): `src/features/settings/SettingsPage.tsx`

### Other components

- **User**

## Connections

- User → Application shell: uses
- Application shell → Workspace state: initializes
- Application shell → Page tree: renders
- Workspace state → Page tree: provides tree
- Application shell → Document editor: routes to
- Application shell → Database page: routes to
- Document editor → Editor state: edits through
- Editor state → Document API: persists via
- Document API → Tauri command bridge: invokes
- Database page → Grid board calendar: selects view
- Grid board calendar → Database state: loads and edits
- Database state → Filter and sort logic: filters and sorts
- Database state → Formula evaluation: computes values
- Database state → Column summaries: summarizes
- Database state → Database API: persists via
- Database API → Tauri command bridge: invokes
- Tauri command bridge → Persistence commands: dispatches
- Persistence commands → Database operations: calls
- Database operations → Local SQLite store: reads and writes
- Global search → Search service: searches through
- Search service → Tauri command bridge: invokes
- Recycle bin → Tauri command bridge: manages deleted pages
- Settings and backup → Workspace state: configures
- Settings and backup → Asset commands: imports and exports
- Asset commands → Tauri command bridge: registered with
