Skip to content

Architecture Overview

GitHub Copilot edited this page May 12, 2026 · 1 revision

Architecture Overview

mdedit.io is a server-rendered web application with a browser-based editor and a Node.js backend.

Stack

Layer Technology
Runtime Node.js 20, Fastify
Database SQLite (via db.js)
PDF export Pandoc + XeLaTeX / paged.js
DOCX export Pandoc
Citations Pandoc Citeproc (CSL/JSON)
Diagrams Mermaid.js
Math KaTeX
Frontend Vanilla JS, no framework
Containerization Docker, Docker Compose

Key Components

server.js        — Fastify server, all HTTP routes and API endpoints
db.js            — SQLite database layer (documents, sessions, sharing)
public/
  app.js         — Client-side editor application
  index.html     — App shell
  styles.css     — Stylesheet
  modules/       — Feature modules (AI, citations, outline, etc.)
  vendor/        — Bundled third-party libraries (no external CDN dependency)
scripts/         — CI/validation scripts (visual-smoke, i18n-validate, etc.)
docs/            — Operational and product documentation

Request Flow

Browser → Fastify (server.js) → SQLite (db.js)
                             → Pandoc (PDF/DOCX export)
                             → External AI API (chat completion)

Data Model

  • Documents (pastes): stored in SQLite with UUID, Markdown content, title, shared flag
  • Sessions: HttpOnly cookie (sid), server-side session in SQLite
  • Assets: stored in data/assets/

Export Pipeline

  1. Client sends Markdown + front matter + bibliography to /api/export/pdf
  2. Server writes temp files, calls Pandoc with the appropriate filters
  3. Pandoc runs Citeproc (citations), XeLaTeX or paged.js (layout), Mermaid/KaTeX
  4. Server returns the PDF blob, temp files are cleaned up in finally

Frontend Architecture

  • Single-page app loaded from public/index.html
  • No build step required — all assets are pre-bundled in public/vendor/
  • AI panel, Outline panel, and Preview panel share a single tab container
  • Live preview updates debounced on each keystroke

See Also

Clone this wiki locally