$ show requarks/wiki
Wiki.js is a full-featured, open-source wiki platform designed for collaborative content management. It provides a rich editing experience with Markdown, AsciiDoc, and a visual editor (ProseMirror), supporting real-time collaborative editing via Yjs and WebSocket. The system is built as a monolith with a Fastify backend, Vue 3 frontend, and PostgreSQL database, with worker threads for background tasks like notifications and webhook delivery. It features a modular architecture with pluggable storage backends (disk, S3, Azure, GCS, Git), authentication strategies (local, OIDC, SAML, LDAP, WebAuthn), analytics providers, and comment systems. The block system allows custom content components (diagrams, maps, PDFs, etc.) as LitElement custom elements. Multi-site and multi-locale support, SCIM provisioning, audit logging, rate limiting, and a scheduler for periodic tasks round out the platform. The codebase is well-structured with extensive comments, but relies on a global `WIKI` object and has complex permission logic that spans multiple layers.
The LLM identified 5 files worth highlighting for reuse:
Implements a database-backed fixed-window rate limiter with configurable window size, max attempts, and ban duration. Uses PostgreSQL for shared state across instances, with atomic increment and ban expiry. The pattern is self-contained and can be extracted for any Node.js application needing distributed rate limiting without Redis.
Handles notification fan-out by claiming events with `UPDATE ... FROM ... SKIP LOCKED`, processing them per category with batch cursors, and writing results with `ON CONFLICT DO UPDATE`. This pattern ensures at-least-once delivery with minimal contention and is reusable for any event-driven system needing reliable, scalable fan-out over PostgreSQL.
Implements the `StorageModule` interface for local disk storage, with atomic writes via temporary files, path prefix generation, and automatic pruning of empty directories. The pattern demonstrates a clean abstraction for pluggable storage backends and can be reused as a template for implementing other storage targets (S3, Azure, etc.) with minimal adaptation.
Derives the ProseMirror editor schema directly from the markdown renderer's node types and marks, ensuring that any content produced by the visual editor can be serialized back to markdown without silent data loss. This pattern is critical for any WYSIWYG editor that must maintain round-trip fidelity with a source format, and the approach of deriving schema from renderer is non-obvious and highly reusable.
A LitElement custom element for rendering diagrams (Mermaid, PlantUML, etc.) with a static `definition` metadata object, shadow DOM, dark mode support via CSS custom properties, and content editing via a fenced code block. This component exemplifies the block system pattern used throughout Wiki.js: self-contained, declarative, and easily portable to other projects needing embeddable rich content components.