# markmental/eternalibre-notes architecture

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

- Interactive diagram: https://gitdiagram.com/markmental/eternalibre-notes
- Repository: https://github.com/markmental/eternalibre-notes

## Overview

EternaLibre Notes is a self-hosted, SSR Markdown notebook. Users authenticate with TOTP, then browse, search, create, edit, move, and export notes; notes and virtual-folder membership are persisted as Markdown files. The graph includes the documented theme, preview, and browser interaction capabilities. Source excerpts establish the main rendering and authentication links, while some route handlers and note operations are unsampled, so their links are documented or left unverified rather than inferred from co-location.

Main entry points: [`src/routes.rs`](https://github.com/markmental/eternalibre-notes/blob/main/src/routes.rs) (HTTP routes), [`src/pages.rs`](https://github.com/markmental/eternalibre-notes/blob/main/src/pages.rs) (SSR pages and exports), [`src/main.rs`](https://github.com/markmental/eternalibre-notes/blob/main/src/main.rs) (Server startup), [`src/markdown.rs`](https://github.com/markmental/eternalibre-notes/blob/main/src/markdown.rs) (Markdown rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Startup and HTTP"]
  node_main["Server startup<br/>[main.rs]"]
  node_routes["HTTP routes<br/>[routes.rs]"]
end

subgraph group_identity["Authentication"]
  node_setup["Terminal enrollment<br/>[setup.rs]"]
  node_auth["TOTP and sessions<br/>[auth.rs]"]
  node_secret_file[("TOTP secret file")]
end

subgraph group_notes["Notes and folders"]
  node_note_ops["Note and folder operations<br/>[notes.rs]"]
  node_markdown_files[("Markdown note files")]
end

subgraph group_presentation["Rendering and themes"]
  node_page_templates["SSR pages and exports<br/>[pages.rs]"]
  node_markdown["Markdown rendering<br/>[markdown.rs]"]
  node_syntax["Code highlighting<br/>[syntax.rs]"]
  node_themes["Theme catalog<br/>[themes.rs]"]
end

subgraph group_browser["Browser interface"]
  node_browser_js["Menus and interactions<br/>[app.js]"]
end

node_operator(("Self-hosting user"))
node_browser_user(("Notes user"))
node_browser(("Web browser"))

node_operator -->|"starts server"| node_main
node_main -->|"runs enrollment"| node_setup
node_setup -->|"provisions TOTP"| node_auth
node_auth -->|"reads and writes"| node_secret_file
node_main -.->|"starts HTTP service"| node_routes
node_browser_user -->|"uses notes"| node_browser
node_browser -->|"sends requests"| node_routes
node_routes -->|"checks sessions"| node_auth
node_routes -.->|"handles note actions"| node_note_ops
node_note_ops -->|"persists notes"| node_markdown_files
node_routes -->|"renders responses"| node_page_templates
node_page_templates -->|"renders note content"| node_markdown
node_markdown -->|"highlights code"| node_syntax
node_markdown -->|"uses theme"| node_themes
node_page_templates -->|"renders themed pages"| node_themes
node_page_templates -.->|"loads interactions"| node_browser_js
node_browser_js -->|"posts preview and moves"| node_routes

click node_main "https://github.com/markmental/eternalibre-notes/blob/main/src/main.rs"
click node_routes "https://github.com/markmental/eternalibre-notes/blob/main/src/routes.rs"
click node_setup "https://github.com/markmental/eternalibre-notes/blob/main/src/setup.rs"
click node_auth "https://github.com/markmental/eternalibre-notes/blob/main/src/auth.rs"
click node_note_ops "https://github.com/markmental/eternalibre-notes/blob/main/src/notes.rs"
click node_page_templates "https://github.com/markmental/eternalibre-notes/blob/main/src/pages.rs"
click node_markdown "https://github.com/markmental/eternalibre-notes/blob/main/src/markdown.rs"
click node_syntax "https://github.com/markmental/eternalibre-notes/blob/main/src/syntax.rs"
click node_themes "https://github.com/markmental/eternalibre-notes/blob/main/src/themes.rs"
click node_browser_js "https://github.com/markmental/eternalibre-notes/blob/main/static/app.js"

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_main,node_routes,node_operator,node_browser_user,node_browser toneBlue
class node_setup,node_auth,node_secret_file toneAmber
class node_note_ops,node_markdown_files toneMint
class node_page_templates,node_markdown,node_syntax,node_themes toneRose
class node_browser_js toneIndigo
```

## Components

### Startup and HTTP

- [Server startup](https://github.com/markmental/eternalibre-notes/blob/main/src/main.rs): `src/main.rs`
- [HTTP routes](https://github.com/markmental/eternalibre-notes/blob/main/src/routes.rs): `src/routes.rs`

### Authentication

- [Terminal enrollment](https://github.com/markmental/eternalibre-notes/blob/main/src/setup.rs): `src/setup.rs`
- [TOTP and sessions](https://github.com/markmental/eternalibre-notes/blob/main/src/auth.rs): `src/auth.rs`
- **TOTP secret file**

### Notes and folders

- [Note and folder operations](https://github.com/markmental/eternalibre-notes/blob/main/src/notes.rs): `src/notes.rs`
- **Markdown note files**

### Rendering and themes

- [SSR pages and exports](https://github.com/markmental/eternalibre-notes/blob/main/src/pages.rs): `src/pages.rs`
- [Markdown rendering](https://github.com/markmental/eternalibre-notes/blob/main/src/markdown.rs): `src/markdown.rs`
- [Code highlighting](https://github.com/markmental/eternalibre-notes/blob/main/src/syntax.rs): `src/syntax.rs`
- [Theme catalog](https://github.com/markmental/eternalibre-notes/blob/main/src/themes.rs): `src/themes.rs`

### Browser interface

- [Menus and interactions](https://github.com/markmental/eternalibre-notes/blob/main/static/app.js): `static/app.js`

### Other components

- **Self-hosting user**
- **Notes user**
- **Web browser**

## Connections

- Self-hosting user → Server startup: starts server (evidence: `README.md`)
- Server startup → Terminal enrollment: runs enrollment (evidence: `README.md`)
- Terminal enrollment → TOTP and sessions: provisions TOTP (evidence: `src/setup.rs`)
- TOTP and sessions → TOTP secret file: reads and writes (evidence: `README.md`)
- Server startup → HTTP routes: starts HTTP service
- Notes user → Web browser: uses notes (evidence: `README.md`)
- Web browser → HTTP routes: sends requests (evidence: `src/routes.rs`)
- HTTP routes → TOTP and sessions: checks sessions (evidence: `src/routes.rs`)
- HTTP routes → Note and folder operations: handles note actions (evidence: `src/routes.rs`)
- Note and folder operations → Markdown note files: persists notes (evidence: `README.md`)
- HTTP routes → SSR pages and exports: renders responses (evidence: `src/pages.rs`)
- SSR pages and exports → Markdown rendering: renders note content (evidence: `src/pages.rs`)
- Markdown rendering → Code highlighting: highlights code (evidence: `src/markdown.rs`)
- Markdown rendering → Theme catalog: uses theme (evidence: `src/markdown.rs`)
- SSR pages and exports → Theme catalog: renders themed pages (evidence: `src/pages.rs`)
- SSR pages and exports → Menus and interactions: loads interactions
- Menus and interactions → HTTP routes: posts preview and moves (evidence: `static/app.js`)
