# dociere/docierepro architecture

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

- Interactive diagram: https://gitdiagram.com/dociere/docierepro
- Repository: https://github.com/dociere/docierepro

## Overview

1. **Overall shape**
Docière Pro is a desktop-first LaTeX writing environment built as an **Electron shell** around a **React/Vite renderer**. The app is optimized for offline project editing, template-driven document creation, and live document preview rather than as a pure web app.

2. **Primary UI/runtime boundary**
The repository is split into:
- **Electron main process** (`electron/main.cjs`) for app lifecycle, windows, and OS integration
- **Preload bridge** (`electron/preload.js`) for safe IPC exposure to the renderer
- **Renderer app** (`src/`) for all editing, navigation, and document management UI  
This boundary is important because file access, native dialogs, and any OS-level operations must cross Electron IPC rather than being done directly from React.

3. **Renderer application structure**
`src/` is organized as a single-page application with clear feature areas:
- **Pages** (`src/pages`) for major screens like editor, template browsing/selection, settings, account flow, and startup
- **Components** (`src/components`) for reusable editors, toolbars, side panels, modals, citation tools, PDF viewing, and collaboration UI
- **Context providers** (`src/context`) for auth, project state, and settings
- **Hooks** (`src/hooks`) for shared behavior like toast notifications and Monaco/Yjs integration  
This suggests a central app shell with route-level views and many modular editor panels.

4. **Document editing subsystem**
The app supports multiple editing modes:
- structured text/section editing
- rich text editing
- Monaco-based source/code editing
- Slate-based editor surfaces
- math/equation insertion and table/image modals  
The editing experience is not just a text area; it is a multi-editor system where different representations of the same document can be shown or edited depending on context.

5. **LaTeX generation and document model**
The `src/utils` folder is the core transformation layer:
- `latexGenerator.js`
- `latexAstEngine.jsx`
- `latexBlots.jsx`
- `latexUtility.jsx`
- `latexMonarchLanguage.jsx`
- `layoutSchema.js`
- `componentRegistry.js`  
These files indicate that Docière maintains a structured document model and converts it into LaTeX, while also providing language syntax support and component/layout metadata. The architecture likely flows from editor state -> document schema/AST -> LaTeX output -> preview/export.

6. **PDF preview and document rendering**
The UI includes a dedicated `pdfViewer` component plus CSS for PDF and SyncTeX styles. That implies a tight edit/preview loop where the generated LaTeX project is compiled to PDF and then displayed inside the app. The `CrossRefPanel`, `FootnotePanel`, and `versionManager` components show that the preview/editor ecosystem includes navigation and document-structure tooling, not only raw text editing.

7. **Template and project system**
The `templates/` and `user-templates/` directories are first-class architecture elements. They contain complete LaTeX project skeletons for:
- ACM manuscript
- IEEE conference/journal
- MLA format
- resume
- user-created custom templates  
Each template is a filesystem-backed LaTeX project with main files, section files, class definitions, references, and supporting assets. The template browser/select/preview/builder pages form the user-facing layer over these project blueprints.

8. **Project and account workflow**
The app includes auth-related pages (`login`, `signup`, `forgotPassword`, `changePassword`) and project-management contexts. That indicates Docière supports a user/session layer in addition to local document editing. The presence of `shareProject`, `leaveSession`, and collaboration-related hooks suggests a project can be shared or collaboratively edited, with some state managed locally and some likely synchronized remotely.

9. **External/service boundary**
The README links to **Docière Server**, so this repository appears to be the desktop client while a separate backend handles features such as collaboration, account/session management, or sync. The repo itself is still heavily offline-capable, but a diagram should show an optional/required remote service boundary for collaborative and account-based features.

10. **Native helper sidecar**
The `sidecar/` directory is a separate **C++ native component** built with CMake, including `qpdf.cpp` and bundling scripts. This strongly suggests native PDF-related work such as PDF manipulation, packaging, or invoking lower-level document tooling that is awkward to do purely in JS. It is an important architecture boundary because it sits outside the Electron/React runtime.

11. **Tooling and build pipeline**
The project uses:
- **Vite** for the renderer build
- **Tailwind/PostCSS** for styling
- **ESLint** for linting
- GitHub Actions (`.github/workflows/build.yml`) for CI
- scripts for icon generation, installer setup, and TinyTeX initialization  
This indicates the desktop app is packaged with its TeX toolchain and native helpers in mind, not deployed as a hosted web frontend.

12. **End-to-end data flow**
A typical flow is:
user selects or opens a template/project -> React context loads project state -> editor components modify structured content -> LaTeX utilities generate or update source files -> native/Electron boundaries handle filesystem and preview compilation -> PDF viewer renders the result -> optional remote services handle auth, collaboration, or sharing.  
That flow is the core architecture to reflect in a diagram.

Main entry points: [`src/pages/editorPage.jsx`](https://github.com/dociere/docierepro/blob/develop/src/pages/editorPage.jsx) (Editor workbench), [`src/utils/latexGenerator.js`](https://github.com/dociere/docierepro/blob/develop/src/utils/latexGenerator.js) (LaTeX pipeline), [`src/layout/pageLayout.jsx`](https://github.com/dociere/docierepro/blob/develop/src/layout/pageLayout.jsx) (Page layout), [`src/components/pdfViewer.jsx`](https://github.com/dociere/docierepro/blob/develop/src/components/pdfViewer.jsx) (Doc panels)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop_runtime["Desktop runtime"]
  node_electron_main["Electron main<br/>runtime host<br/>[main.cjs]"]
  node_electron_preload["Preload bridge<br/>ipc bridge<br/>[preload.js]"]
end

subgraph group_renderer_app["Renderer app"]
  node_app_shell["App shell<br/>react entry<br/>[main.jsx]"]
  node_page_layout["Page layout<br/>ui shell<br/>[pageLayout.jsx]"]
  node_start_and_docs["Start & docs<br/>screens<br/>[startingPage.jsx]"]
  node_editor_workbench["Editor workbench<br/>screens<br/>[editorPage.jsx]"]
  node_account_flow["Account flow<br/>screens<br/>[login.jsx]"]
  node_editor_components["Editor panels<br/>ui components<br/>[monacoEditor.jsx]"]
  node_doc_panels["Doc panels<br/>navigation tools<br/>[pdfViewer.jsx]"]
  node_project_state["Project state<br/>react context<br/>[useProject.jsx]"]
  node_project_api["Project API<br/>client api"]
  node_template_pages["Template screens<br/>[templateBrowse.jsx]"]
  node_template_builder["Builder tools<br/>template editor"]
end

subgraph group_doc_engine["Document engine"]
  node_latex_pipeline["LaTeX pipeline<br/>transform layer<br/>[latexGenerator.js]"]
  node_component_registry["Registry<br/>schema metadata"]
  node_preview_assets["Preview assets<br/>styles<br/>[pdfViewer.css]"]
end

subgraph group_template_system["Template system"]
  node_built_in_templates["Built-in templates<br/>latex templates<br/>[main.tex]"]
  node_user_templates["User templates<br/>[main.tex]"]
end

subgraph group_native_sidecar["Native sidecar"]
  node_sidecar_cpp["C++ sidecar<br/>native helper<br/>[main.cpp]"]
  node_sidecar_qpdf["QPDF bridge<br/>native pdf tool<br/>[qpdf.cpp]"]
end

subgraph group_external_services["Remote services"]
  node_dociere_server[("Docière Server<br/>remote backend")]
end

subgraph group_tooling["Tooling"]
  node_build_ci["Build & CI<br/>tooling<br/>[build.yml]"]
  node_packaging_scripts["Packaging scripts<br/>tooling scripts<br/>[setup-tinytex.js]"]
end

node_electron_main -->|"exposes"| node_electron_preload
node_electron_preload -->|"bridges"| node_app_shell
node_app_shell -->|"uses"| node_page_layout
node_page_layout -->|"hosts"| node_start_and_docs
node_page_layout -->|"hosts"| node_editor_workbench
node_page_layout -->|"hosts"| node_account_flow
node_editor_workbench -->|"composes"| node_editor_components
node_editor_workbench -->|"composes"| node_doc_panels
node_editor_workbench -->|"composes"| node_template_builder
node_project_state -->|"loads"| node_project_api
node_project_state -->|"feeds"| node_editor_workbench
node_project_api -->|"requests"| node_electron_preload
node_editor_components -->|"edits"| node_latex_pipeline
node_latex_pipeline -->|"consults"| node_component_registry
node_latex_pipeline -->|"writes"| node_built_in_templates
node_latex_pipeline -->|"writes"| node_user_templates
node_doc_panels -->|"renders with"| node_preview_assets
node_doc_panels -->|"observes"| node_latex_pipeline
node_template_pages -->|"browses"| node_built_in_templates
node_template_pages -->|"browses"| node_user_templates
node_template_pages -->|"opens"| node_template_builder
node_sidecar_cpp -->|"includes"| node_sidecar_qpdf
node_electron_main -->|"launches"| node_sidecar_cpp
node_account_flow -.->|"auths against"| node_dociere_server
node_project_state -.->|"syncs with"| node_dociere_server
node_doc_panels -.->|"compiles via"| node_sidecar_cpp
node_build_ci -->|"runs"| node_packaging_scripts
node_build_ci -->|"builds"| node_sidecar_cpp
node_build_ci -->|"bundles"| node_app_shell

click node_electron_main "https://github.com/dociere/docierepro/blob/develop/electron/main.cjs"
click node_electron_preload "https://github.com/dociere/docierepro/blob/develop/electron/preload.js"
click node_app_shell "https://github.com/dociere/docierepro/blob/develop/src/main.jsx"
click node_page_layout "https://github.com/dociere/docierepro/blob/develop/src/layout/pageLayout.jsx"
click node_start_and_docs "https://github.com/dociere/docierepro/blob/develop/src/pages/startingPage.jsx"
click node_editor_workbench "https://github.com/dociere/docierepro/blob/develop/src/pages/editorPage.jsx"
click node_account_flow "https://github.com/dociere/docierepro/blob/develop/src/pages/User_Account/login.jsx"
click node_editor_components "https://github.com/dociere/docierepro/blob/develop/src/components/monacoEditor.jsx"
click node_doc_panels "https://github.com/dociere/docierepro/blob/develop/src/components/pdfViewer.jsx"
click node_project_state "https://github.com/dociere/docierepro/blob/develop/src/context/useProject.jsx"
click node_project_api "https://github.com/dociere/docierepro/blob/develop/src/api/projectHandling.jsx"
click node_latex_pipeline "https://github.com/dociere/docierepro/blob/develop/src/utils/latexGenerator.js"
click node_component_registry "https://github.com/dociere/docierepro/blob/develop/src/utils/componentRegistry.js"
click node_preview_assets "https://github.com/dociere/docierepro/blob/develop/src/assets/styles/pdfViewer.css"
click node_built_in_templates "https://github.com/dociere/docierepro/blob/develop/templates/ACM Manuscript/main.tex"
click node_user_templates "https://github.com/dociere/docierepro/blob/develop/user-templates/Founders Agreement (India)/main.tex"
click node_template_pages "https://github.com/dociere/docierepro/blob/develop/src/pages/templateBrowse.jsx"
click node_template_builder "https://github.com/dociere/docierepro/blob/develop/src/components/templateBuilder/ComponentRenderer.jsx"
click node_sidecar_cpp "https://github.com/dociere/docierepro/blob/develop/sidecar/main.cpp"
click node_sidecar_qpdf "https://github.com/dociere/docierepro/blob/develop/sidecar/qpdf.cpp"
click node_build_ci "https://github.com/dociere/docierepro/blob/develop/.github/workflows/build.yml"
click node_packaging_scripts "https://github.com/dociere/docierepro/blob/develop/scripts/setup-tinytex.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_electron_main,node_electron_preload,node_build_ci,node_packaging_scripts toneBlue
class node_app_shell,node_page_layout,node_start_and_docs,node_editor_workbench,node_account_flow,node_editor_components,node_doc_panels,node_project_state,node_project_api,node_template_pages,node_template_builder toneAmber
class node_latex_pipeline,node_component_registry,node_preview_assets toneMint
class node_built_in_templates,node_user_templates toneRose
class node_sidecar_cpp,node_sidecar_qpdf toneIndigo
class node_dociere_server toneTeal
```

## Components

### Desktop runtime

Electron main/preload boundary for app lifecycle and safe native access.

- [Electron main](https://github.com/dociere/docierepro/blob/develop/electron/main.cjs): runtime host · App lifecycle, windows, and OS integration. · `electron/main.cjs`
- [Preload bridge](https://github.com/dociere/docierepro/blob/develop/electron/preload.js): ipc bridge · Safe IPC surface exposed to the renderer. · `electron/preload.js`

### Renderer app

React/Vite UI for editing, navigation, and project management.

- [App shell](https://github.com/dociere/docierepro/blob/develop/src/main.jsx): react entry · Root renderer bootstrap and routing entry. · `src/main.jsx`
- [Page layout](https://github.com/dociere/docierepro/blob/develop/src/layout/pageLayout.jsx): ui shell · Shared page framing and navigation layout. · `src/layout/pageLayout.jsx`
- [Start & docs](https://github.com/dociere/docierepro/blob/develop/src/pages/startingPage.jsx): screens · Startup, template browsing, preview, and details screens. · `src/pages/startingPage.jsx`
- [Editor workbench](https://github.com/dociere/docierepro/blob/develop/src/pages/editorPage.jsx): screens · Main editor, canvas, settings, and template builder screens. · `src/pages/editorPage.jsx`
- [Account flow](https://github.com/dociere/docierepro/blob/develop/src/pages/User_Account/login.jsx): screens · Login, signup, and password recovery screens. · `src/pages/User_Account/login.jsx`
- [Editor panels](https://github.com/dociere/docierepro/blob/develop/src/components/monacoEditor.jsx): ui components · Monaco, Slate, rich text, section, toolbar, and sidebar surfaces. · `src/components/monacoEditor.jsx`
- [Doc panels](https://github.com/dociere/docierepro/blob/develop/src/components/pdfViewer.jsx): navigation tools · Cross-references, footnotes, citations, versioning, and PDF view. · `src/components/pdfViewer.jsx`
- [Project state](https://github.com/dociere/docierepro/blob/develop/src/context/useProject.jsx): react context · Auth, project, and settings state providers. · `src/context/useProject.jsx`
- [Project API](https://github.com/dociere/docierepro/blob/develop/src/api/projectHandling.jsx): client api · Project handling and file/workspace operations. · `src/api/projectHandling.jsx`
- [Template screens](https://github.com/dociere/docierepro/blob/develop/src/pages/templateBrowse.jsx): screens · Template browse, select, preview, and builder screens. · `src/pages/templateBrowse.jsx`
- [Builder tools](https://github.com/dociere/docierepro/blob/develop/src/components/templateBuilder/ComponentRenderer.jsx): template editor · Component renderer and property panel for template authoring. · `src/components/templateBuilder/ComponentRenderer.jsx`

### Document engine

Structured content model, LaTeX generation, and preview pipeline.

- [LaTeX pipeline](https://github.com/dociere/docierepro/blob/develop/src/utils/latexGenerator.js): transform layer · AST, blots, generator, utilities, and schema metadata. · `src/utils/latexGenerator.js`
- [Registry](https://github.com/dociere/docierepro/blob/develop/src/utils/componentRegistry.js): schema metadata · Component and layout registry used by document assembly. · `src/utils/componentRegistry.js`
- [Preview assets](https://github.com/dociere/docierepro/blob/develop/src/assets/styles/pdfViewer.css): styles · PDF and SyncTeX styling for preview rendering. · `src/assets/styles/pdfViewer.css`

### Template system

Built-in and user-provided LaTeX project blueprints.

- [Built-in templates](https://github.com/dociere/docierepro/blob/HEAD/templates/ACM%20Manuscript/main.tex): latex templates · Packaged ACM, IEEE, MLA, and resume project skeletons. · `templates/ACM Manuscript/main.tex`
- [User templates](https://github.com/dociere/docierepro/blob/HEAD/user-templates/Founders%20Agreement%20(India)/main.tex): user templates · User-authored template projects and reusable LaTeX starting points. · `user-templates/Founders Agreement (India)/main.tex`

### Native sidecar

C++ helper for lower-level PDF/document tooling.

- [C++ sidecar](https://github.com/dociere/docierepro/blob/develop/sidecar/main.cpp): native helper · Native helper entrypoints and bundled document tooling. · `sidecar/main.cpp`
- [QPDF bridge](https://github.com/dociere/docierepro/blob/develop/sidecar/qpdf.cpp): native pdf tool · Native PDF-related implementation layer. · `sidecar/qpdf.cpp`

### Remote services

Optional backend for auth, sharing, and collaboration.

- **Docière Server**: remote backend · External service for auth, sharing, and collaboration.

### Tooling

Build, packaging, and CI support.

- [Build & CI](https://github.com/dociere/docierepro/blob/develop/.github/workflows/build.yml): tooling · Vite build, packaging scripts, and GitHub Actions. · `.github/workflows/build.yml`
- [Packaging scripts](https://github.com/dociere/docierepro/blob/develop/scripts/setup-tinytex.js): tooling scripts · Installer, icon generation, and TinyTeX setup scripts. · `scripts/setup-tinytex.js`

## Connections

- Electron main → Preload bridge: exposes · Main process publishes safe IPC to the renderer.
- Preload bridge → App shell: bridges · Renderer accesses OS capabilities through preload.
- App shell → Page layout: uses · Root app composes shared page framing.
- Page layout → Start & docs: hosts · Layout wraps startup and document browsing screens.
- Page layout → Editor workbench: hosts · Layout wraps the main editing workflow screens.
- Page layout → Account flow: hosts · Layout also supports account/session pages.
- Editor workbench → Editor panels: composes · Main editor screens are built from reusable editors and panels.
- Editor workbench → Doc panels: composes · Workbench includes document navigation and preview tools.
- Editor workbench → Builder tools: composes · Template authoring uses dedicated builder controls.
- Project state → Project API: loads · State providers coordinate project access and persistence.
- Project state → Editor workbench: feeds · Editor screens read from shared auth/project/settings state.
- Project API → Preload bridge: requests · Filesystem and native operations cross the IPC boundary.
- Editor panels → LaTeX pipeline: edits · Editors produce structured content consumed by the document engine.
- LaTeX pipeline → Registry: consults · Generation uses layout and component metadata.
- LaTeX pipeline → Built-in templates: writes · Structured document state becomes template-backed LaTeX source.
- LaTeX pipeline → User templates: writes · User project variants are also rendered to LaTeX files.
- Doc panels → Preview assets: renders with · PDF preview uses dedicated viewer and SyncTeX styling.
- Doc panels → LaTeX pipeline: observes · Preview tools stay aligned with generated document structure.
- Template screens → Built-in templates: browses · Template screens present packaged project blueprints.
- Template screens → User templates: browses · Template screens also present custom user templates.
- Template screens → Builder tools: opens · Template selection can lead into template authoring.
- C++ sidecar → QPDF bridge: includes · Native helper contains PDF-specific implementation.
- Electron main → C++ sidecar: launches · Desktop app can invoke the native sidecar for lower-level work.
- Account flow → Docière Server: auths against · Account pages depend on remote service capabilities.
- Project state → Docière Server: syncs with · Project and collaboration state may synchronize remotely.
- Doc panels → C++ sidecar: compiles via · PDF generation and preview may use native tooling.
- Build & CI → Packaging scripts: runs · CI and build tasks rely on packaging/setup scripts.
- Build & CI → C++ sidecar: builds · Release pipeline includes native component builds.
- Build & CI → App shell: bundles · Renderer is packaged through the Vite/Electron build.
