Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 2.63 KB

development.md

File metadata and controls

60 lines (46 loc) · 2.63 KB

Development

Requires Node 26 (see .nvmrc) and pnpm (npm install -g corepack && corepack enable).

pnpm install
cp src/backend/.env.example src/backend/.env   # optional
pnpm dev          # web app on http://localhost:5173, server on :3000 (Vite proxies /api and /sync)

pnpm dev runs the server with DEV_MODE=true: no setup token and no two-factor, just a username and password. Never set DEV_MODE on a server others can reach. Data is stored in src/backend/data/; delete it to start over.

Without it (production), the server prints a setup token in its log on first start. Open the app, enter the token and create the first account. Two-factor is set up at the first sign-in.

Checks

pnpm lint
pnpm format:check   # or `pnpm format` to fix
pnpm typecheck
pnpm test           # unit and API tests (Vitest)
pnpm build          # builds web app + service worker, then the server
pnpm test:e2e       # Playwright tests against the production build (iPhone and Pixel sizes)

To run the production build locally (setup token and two-factor on):

pnpm build
WEB_ROOT=../frontend/dist/client pnpm start   # http://localhost:3000

Layout

Path What
src/frontend TanStack Start app (React, TSX, Vite) in SPA mode. scripts/generate-sw.js builds the service worker after the Vite build
src/frontend/src/lib Sync (Yjs documents, IndexedDB, one shared WebSocket), auth state, workspace helpers
src/frontend/src/components/Editor.tsx TipTap editor bound to the page's Yjs document
src/backend/src Fastify server: /api (auth, files, search, export), /sync (Hocuspocus), static web app
packages/shared Document model (page tree, pins), content helpers (text, tasks, Markdown), API schemas

How data flows

  • The workspace document (one Yjs doc) holds the page tree: titles, parents, order, archived, pins and each page's count of open checklist items.
  • Each page document holds the page content (content, a ProseMirror fragment written by TipTap).
  • Devices keep a copy of every opened document in IndexedDB and sync over /sync when online. Pinned pages are kept downloaded so lists work without signal.
  • The server stores documents in SQLite and derives the pages table and the full-text index (search_fts, trigram tokenizer) from them. Those can always be rebuilt from the documents.
  • Photos and files are uploaded over HTTP, stored by content hash in DATA_DIR/files, and referenced from the page content by id. Photos are resized and stripped of EXIF (location) data.

Running in production

See deployment.md: Docker, Nginx and backups.