How raveendra47/thetos-reader works
Purpose and Runtime
Thetos Reader is a privacy-first Windows PDF reader. Its UI runs as a React 18/TypeScript Vite application; Tauri 2 packages and hosts it as a native desktop application with a Rust backend. PDF rendering, search, annotation, and dictionary processing are local.
Entry points:
• Web/UI bootstrap: src/main.tsx
• Application composition: src/App.tsx
• Tauri executable/library: src-tauri/src/main.rs, src-tauri/src/lib.rs
Application Shell and Navigation
src/App.tsx coordinates the desktop reader shell: document tabs, viewer workspace, panels/dialogs, and application-level interactions. src/pages/Index.tsx is the primary route-level screen, while src/pages/NotFound.tsx handles unmatched routes. The top-level UI is composed from reader-specific controls such as src/components/TabBar.tsx, src/components/ViewerToolbar.tsx, and src/components/TitleBar.tsx.
Document Intake and Session Lifecycle
Documents enter through drag/drop and file-oriented UI, then become managed tabs and persisted session state.
• Intake: src/components/DropZone.tsx, src/lib/fileStore.ts
• Tab lifecycle: src/hooks/useTabManager.ts, src/components/TabBar.tsx
• Restore/persistence boundary: src/lib/sessionStore.ts, src/lib/pdfDocCache.ts
This boundary separates document metadata and reader state from active PDF.js document/rendering objects.
PDF Viewing and Rendering Pipeline
src/viewers/PdfViewer.tsx is the central document-viewing integration point. It consumes PDF state and coordinates page presentation, navigation, zoom/rotation/layout settings, status, and page interactions.
• Viewer: src/viewers/PdfViewer.tsx
• PDF state/cache: src/lib/usePdfStore.ts, src/lib/pdfDocCache.ts
• Rendering hooks/workers: src/hooks/usePdfRenderer.ts, src/workers/renderWorker.ts, src/workers/prerender.worker.ts
Rendering is explicitly offloaded to workers where possible, keeping page rasterization/prerender work outside the interactive React UI thread.
Search, Navigation, and PDF Services
Full-text search is a separate asynchronous pipeline with UI feedback and live matches.
• Search UI: src/components/PdfSearchBar.tsx
• Search orchestration/worker: src/hooks/useSearchWorker.ts, src/workers/searchWorker.ts
• PDF navigation services: src/lib/pdfLinkService.ts, src/components/DocumentTocSidebar.tsx
PDF links and table-of-contents navigation form a viewer-to-document-service boundary rather than being embedded solely in rendering components.
Reader State: Annotations, Bookmarks, and Settings
Persistent local reader data is organized into focused stores and surfaced through panels/popovers.
• Annotation history/storage: src/hooks/useAnnotationHistory.ts, src/lib/annotationStore.ts
• Bookmark UI: src/components/BookmarkPanel.tsx
• Preferences and protected documents: src/lib/appSettings.ts, src/lib/passwordStore.ts, src/components/PdfSettingsPanel.tsx
Selection actions originate in src/components/TextSelectionPopover.tsx; annotation/bookmark state is retained independently of transient viewer rendering.
Dictionary and Native Packaging
Dictionary lookup is local and supports MDX dictionary resources through a dedicated parser subsystem.
• Dictionary UX/core/store: src/components/DictionaryPopover.tsx, src/lib/dictionaryCore.ts, src/lib/dictionaryStore.ts
• MDX parsing: src/lib/mdict/index.ts
• Bundled resources: src-tauri/resources/dictionaries/EnglishDictionary.mdx, src-tauri/resources/dictionaries/Merriam-Webster.mdx
Tauri capability and packaging boundaries are defined in src-tauri/tauri.conf.json and src-tauri/capabilities/default.json; no remote backend or external service is indicated.
Main entry points: PdfViewer.tsx PDF viewer · App.tsx Application shell · useTabManager.ts Tab lifecycle · useSearchWorker.ts Search pipeline
Components 21
React UI
Desktop reader interface and route shell.
- UI bootstrap
src/main.tsx - Application shell · Coordinates tabs, workspace, panels, and dialogs.
src/App.tsx - Reader routes · Primary reader screen and unmatched-route fallback.
src/pages/Index.tsx - Reader controls · Title bar, toolbar, and tab bar.
src/components/TabBar.tsx - Search bar
src/components/PdfSearchBar.tsx
Document Lifecycle
Local document session, PDF state, and viewer services.
- Document intake · Drag-and-drop document entry.
src/components/DropZone.tsx - Tab lifecycle · Manages open document tabs.
src/hooks/useTabManager.ts - Session store · Persists document metadata and reader session state.
src/lib/sessionStore.ts - PDF document cache · Separates live PDF objects from persisted session data.
src/lib/pdfDocCache.ts - PDF state store
src/lib/usePdfStore.ts - PDF viewer · Coordinates pages, layout, navigation, and interactions.
src/viewers/PdfViewer.tsx - PDF navigation · Links and document outline navigation.
src/lib/pdfLinkService.ts
Background Processing
PDF work kept off the interactive UI thread.
- Render pipeline · Rasterization and prerendering run outside the UI thread.
src/hooks/usePdfRenderer.ts - Search pipeline · Asynchronous full-text search with live matches.
src/hooks/useSearchWorker.ts
Reader Data
Persistent local reader state and dictionary data.
- Annotations and bookmarks · Selection-driven annotations, history, and bookmarks.
src/lib/annotationStore.ts - Preferences and passwords · Reader settings and protected-document data.
src/lib/appSettings.ts - Dictionary subsystem · Lookup core and persisted dictionary selection/state.
src/lib/dictionaryCore.ts - MDX parser
src/lib/mdict/index.ts
Native Packaging
Tauri host, capabilities, and bundled resources.
- Bundled dictionaries · Local English and Merriam-Webster dictionary files.
src-tauri/resources/dictionaries/EnglishDictionary.mdx - Tauri host · Packages and hosts the React reader with a Rust backend.
src-tauri/src/main.rs - Tauri packaging policy
src-tauri/tauri.conf.json
Connections 22
- UI bootstrap → Application shell: mounts
- Application shell → Reader routes: renders
- Application shell → Reader controls: composes
- Application shell → Document intake: accepts documents
- Document intake → Tab lifecycle: opens
- Tab lifecycle → Session store: persists session
- Tab lifecycle → PDF document cache: manages active documents
- Application shell → PDF viewer: hosts
- PDF viewer → PDF state store: reads viewer state
- PDF state store → PDF document cache: uses documents
- PDF viewer → Render pipeline: requests rendering
- PDF viewer → PDF navigation: navigates links and TOC
- Search bar → Search pipeline: submits queries
- Search pipeline → PDF document cache: searches active document
- Search pipeline → PDF viewer: returns matches
- PDF viewer → Annotations and bookmarks: reads and updates
- Application shell → Preferences and passwords: loads settings
- PDF viewer → Dictionary subsystem: looks up selections
- Dictionary subsystem → MDX parser: parses MDX
- MDX parser → Bundled dictionaries: reads
- Tauri host → UI bootstrap: hosts web UI
- Tauri packaging policy → Tauri host: configures