Skip to content
LukaG712Public

About

Self-hosted, Markdown-first, AI-native personal knowledge management platform inspired by Obsidian, Notion, and NotebookLM

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CortexMD

Minimalist, monochrome AI writing studio & local-first Markdown knowledge platform.

Build & Release Latest Release Next.js 15 Node.js 22+ SQLite FTS5

CortexMD blends a calm, Zen-inspired monochrome AI writing canvas (Carbon Black & Pure White, OS-adaptive) with plain Markdown vaults, inline tracked-changes AI diffs, editorial margin critique, and a zero-key local AI studio — deployable on your homelab or as a native offline desktop app.

Zen Writing Studio  ·  Features  ·  Architecture  ·  AI Studio  ·  Quick Start  ·  Security


Tip

Zero API Keys Required: CortexMD ships with a built-in local-hybrid writing & RAG engine (offline proofreader, editorial critique analyzer, SQLite FTS5 BM25 + 384-dimension semantic embeddings). Your notes stay on your disk and never leave your machine unless you explicitly enable an external LLM provider.


Zen Writing Studio

Designed for deep, distraction-free writing with restrained Carbon Black (#0a0a0a / #111111) and Pure White (#ffffff / #fafafa) aesthetics:

  • Automatic Windows / OS Theme Sync: Defaults to Auto (prefers-color-scheme + Electron nativeTheme), switching live between Carbon Black and Pure White whenever you toggle OS dark/light mode — including the native frameless Windows titleBarOverlay.
  • 6 Self-Hosted Minimalist Brutalist & Editorial Fonts (bundled offline via next/font/google):
    • Space Grotesk (Neo-Brutalist Sans) · IBM Plex Sans (Swiss Editorial) · IBM Plex Mono (Technical Mono) · Space Mono (Architectural Brutalist) · JetBrains Mono (Crisp Code Mono) · Newsreader (Optical Literary Serif)
  • Live Markdown Typography While Typing: Headings, **bold**, *italic*, `code`, > quotes, links, [[WikiLinks]], and --- dividers style live in the editor with dimmed syntax markers and zero caret drift.
  • True Paragraph Focus & Typewriter Centering: Dim surrounding prose to 25% opacity while keeping your active paragraph razor-sharp, and optionally lock the cursor line vertically centered as you type.
  • Inline Tracked-Changes AI Diffing: Review streaming AI rewrites at word, sentence, or character granularity directly in prose with per-change Accept/Reject (Tab / Y / N), inline code/WikiLink/URL protection, and a quick AI Engine Switcher inside the AI Edit menu.
  • Editorial Critique / Margin Comments: Run an editorial pass (POST /api/ai/critique) to surface concise margin notes on wordiness, passive voice, repeated words, long sentences, and glossary violations — each with a 1-click Fix Inline button that opens directly into tracked diff review.
  • In-Note Find & Replace (Ctrl+F / Ctrl+H): Floating monochrome bar with live match highlights, counter, case sensitivity (Aa), regular expressions (.*), Replace, and Replace All.
  • Version History Visual Diff & Note Compare: Compare your live draft against any past snapshot or any other workspace note using the same word/sentence/char tracked-changes viewer to cherry-pick edits.
  • Writing Targets Hairline & Focus Sprint Timer: Set a word target (500 / 1000 / 2000) to display a razor-thin 2px monochrome progress hairline across the top of the canvas, paired with a discreet 15m / 25m sprint timer in the footer.
  • Open Any Local .md File Directly (Desktop): Open and save standalone .md / .markdown files anywhere on disk via Ctrl+Shift+O, sidebar button, or OS "Open with CortexMD" file association without importing into a vault.

Platform Pillars

Monochrome Zen Canvas

  • Carbon Black & Pure White: Live OS dark/light auto-switching with zero distracting color noise and native Electron frameless window chrome.
  • Brutalist Typography & Focus: 6 bundled fonts, adjustable size/leading/measure, Live Markdown styling, Paragraph Focus dimming, Typewriter Centering, and fullscreen Zen mode (Ctrl+Shift+Z).
  • Flow Utilities: Floating selection toolbar, in-note Find & Replace (Ctrl+F/Ctrl+H), 2px word target hairline, and 15m/25m writing sprint timer.

AI Editing, Critique & RAG Studio

  • Streaming Inline Tracked Diffs: Word, sentence, and character diff granularities with per-hunk Accept/Reject and instant provider switching inside AI Edit.
  • Editorial Margin Critique: Actionable margin comments with 1-click Fix Inline, plus custom pinned prompts, style guides, writing memory, and terminology glossaries.
  • Grounded Knowledge RAG: Streaming SSE answers with #Lstart-Lend citations, Study Guides, Two-Host Audio Briefings, and approval-gated Vault Gardener.

Plain-Text Vaults & Connected Knowledge

  • PARA-Ready Local Vaults: Standard .md files organized in Inbox/, Projects/, Areas/, Resources/, Archive/, Templates/, journals/, and assets/.
  • Graph, Canvas & Transclusions: [[WikiLinks]], backlink refactoring on rename, unlinked mention discovery, ![[Note#Heading]] transclusions, and JSON Canvas 1.0 boards (tucked cleanly under Tools).
  • Structured PKM Views: Live embedded cortex-query tables/lists, Kanban task boards, activity calendar heatmaps, and inline SM-2 flashcards.

Google Docs Sync, Export & Conflict Safety

  • Two-Way Google Docs / Drive Sync: Push polished Markdown to Google Docs, pull upstream edits back, or import existing Docs into your vault.
  • Rich Document Export: One-click export to clean Word (.docx), print-ready PDF, standalone styled HTML, and frontmatter-stripped Markdown.
  • Diffable History & Offline-First Sync: Visual diff on every version snapshot, Compare with Another Note, 3-way hunk conflict resolver, IndexedDB PWA mirror, and per-vault Git commits.

Why CortexMD?

Capability Local-First Sync Tools Cloud SaaS Editors CortexMD
Data Ownership Plain .md on disk Proprietary cloud DB Plain .md + direct local file opening
AI Editing UX Chat sidebar copy/paste Opaque full-doc rewrites Streaming inline word/sentence/char diffs + margin critique
AI & RAG Paid plugins & API keys Cloud-only Zero-key local-hybrid built-in + BYO LLM
AI Access Control Unrestricted file reads Vendor-managed Per-folder ACLs (allow/deny) + diff approval
Export & Collab Community plugins Locked formats Native .docx/PDF/HTML export + two-way Google Docs sync
Deployment Desktop only Hosted only Offline Desktop + Docker / Proxmox + PWA

Architecture

flowchart LR
    subgraph Clients["Clients & Capture"]
        Web["Web & Mobile PWA\n(Carbon/White · IndexedDB Mirror)"]
        Desktop["Electron Desktop App\n(Frameless Titlebar · Direct .md Open)"]
        Webhook["Quick Capture API\nPOST /api/capture"]
    end

    subgraph Core["CortexMD Monolith (Next.js 15 + Node 22/24)"]
        API["REST + SSE Layer\n(RBAC · CSRF · SHA-256 Sync)"]
        Zen["Zen Writing Engine\n(Prose Diff · Critique · Export · GDrive)"]
        Index["Indexer & Graph Engine\n(WikiLinks · Transclusions · Queries)"]
        AI["Grounded AI Studio\n(FTS5 BM25 + 384-dim Vectors + ACLs)"]
    end

    subgraph Storage["Local-First Storage"]
        Vaults["Plain Markdown Vaults\n(Inbox · Projects · Areas · Resources · Archive)"]
        SQLite["SQLite WAL Index\n(FTS5 · Embeddings · Versions · Prompts)"]
    end

    Clients --> API
    API --> Zen
    API --> Index
    API --> AI
    Index <--> Vaults
    Index <--> SQLite
    Zen <--> SQLite
    AI --> SQLite
Loading

Grounded AI Studio

Choose zero-key offline intelligence by default, or switch engines anytime right inside the AI Edit dropdown or Settings:

Provider Execution Requirements
local-hybrid (Default) Embedded proofreader, editorial critique, FTS5 + 384-dim vectors None — 100% offline, zero API keys
ollama Self-hosted local models OLLAMA_BASE_URL, OLLAMA_MODEL
gemini-cli Local CLI (Google OAuth 2.0) Local Gemini CLI login
github-copilot GitHub OAuth pass-through COPILOT_GITHUB_TOKEN
jetbrains-junie Headless CLI / BYOK JUNIE_API_KEY
gemini-api Google Gemini Cloud API GEMINI_API_KEY

Security & Privacy

Important

CortexMD is engineered with defense-in-depth for both self-hosted homelabs and agentic AI workflows.

  • Pre-Retrieval Folder ACLs: Restricted directories (such as Private/) are filtered before chunks ever enter RAG retrieval, inline rewrites, critique passes, or external LLM prompts.
  • Prompt Injection Isolation: Indexed note content is wrapped in <untrusted_note_data> boundaries before being forwarded to any external model.
  • Human-in-the-Loop Mutations: AI edits and agent proposals open as reviewable diffs — no file on disk is ever modified without explicit user approval.
  • Encrypted Credentials & Hardened Auth: Google Drive OAuth tokens and provider API keys are encrypted at rest with APP_SECRET; scrypt per-user salted password hashing, HttpOnly sessions, CSRF tokens, optional reverse-proxy SSO (TRUSTED_PROXY_AUTH_HEADER), and workspace admin / editor / viewer roles.

Quick Start

Option 1 — Standalone Desktop App (Windows · macOS · Linux)

Run CortexMD 100% offline with zero Docker, automatic single-user login, native Carbon/White window chrome, direct .md file opening, and vaults stored in Documents/CortexMD/vaults/.

  • Pre-built Installers: Download .exe / .zip (Windows), .dmg / .zip (macOS Apple Silicon & Intel), or .AppImage / .deb / .tar.gz (Linux) from GitHub Releases.
  • Run or package from source:
    git clone https://github.com/LukaG712/CortexMD.git
    cd CortexMD
    npm install
    
    npm run desktop      # Launch desktop app locally
    npm run dist:win     # Build Windows (.exe, .zip)
    npm run dist:mac     # Build macOS (.dmg, .zip x64 + arm64)
    npm run dist:linux   # Build Linux (.AppImage, .deb, .tar.gz)

Option 2 — Docker Compose (Homelab / Proxmox LXC)

git clone https://github.com/LukaG712/CortexMD.git
cd CortexMD
cp .env.example .env
# Edit .env to set strong ADMIN_PASSWORD and APP_SECRET (32+ chars)
docker compose -f docker/docker-compose.yml up -d --build

Open http://localhost:3000 (default .env.example credentials: admin / cortex-admin-change-me).
Persistent vaults and SQLite data live outside the container at ./data and ./backups.


Option 3 — Local Development (Node.js 22+ / 24+)

git clone https://github.com/LukaG712/CortexMD.git
cd CortexMD
cp .env.example .env
npm install
npm run dev
Verification Scripts & Mobile PWA Setup
npm run dev    # Start Next.js development server
npm run lint   # Run TypeScript compiler check (tsc --noEmit)
npm test       # Run Vitest end-to-end platform & Zen Studio suites (27 tests)
npm run build  # Build production Next.js bundle
npm start      # Serve production build

Mobile PWA: Open your CortexMD URL in Chrome/Firefox (Android) or Safari (iOS) and tap Install App / Add to Home Screen for full-screen offline access via IndexedDB and native Web Share Target support.


Reference & Configuration

Keyboard Shortcuts, Live Queries & Flashcard Syntax
Shortcut Action
Ctrl+K / Cmd+K Faceted Command Palette (Hybrid FTS5 + semantic search)
Ctrl+I / Cmd+I Inline AI Rewrite (opens streaming tracked-changes diff)
Ctrl+F / Cmd+F In-Note Find (highlights, case-sensitive Aa, regex .*)
Ctrl+H / Cmd+H In-Note Find & Replace
Ctrl+S / Cmd+S Save current vault note or standalone local .md file
Ctrl+Shift+Z / Cmd+Shift+Z Toggle distraction-free fullscreen Zen Mode
Tab / Y / N (In Inline Diff Review) Jump hunk / Accept / Reject
Ctrl+Shift+O / Cmd+Shift+O (Desktop) Open any local .md file directly from disk
Ctrl+O / Cmd+O (Desktop) Open Vault directory in OS File Explorer / Finder

Live Embedded Queries (cortex-query):

```cortex-query
tag: #homelab
status: active
sort: updated desc
view: table
limit: 10
```

SM-2 Flashcards:

Q: What isolates Proxmox LXC backups?
A: Separate HDD dataset and incremental snapshots.

SM-2 :: SuperMemo-2 spaced repetition algorithm.

### Default Hash Algorithm #card
scryptSync with per-user 16-byte random salt.
Quick Capture Webhook (POST /api/capture)

Set CORTEX_CAPTURE_TOKEN in .env to append notes from mobile shortcuts, Home Assistant, or cron jobs:

curl -X POST http://localhost:3000/api/capture \
  -H "Authorization: Bearer YOUR_CAPTURE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "workspaceSlug": "personal",
    "title": "Homelab Alert",
    "text": "Proxmox nightly backup completed.",
    "url": "https://pve.local:8006",
    "tags": ["homelab", "backup"],
    "target": "inbox"
  }'

Set "target": "daily" to append to journals/YYYY-MM-DD.md instead of Inbox/Quick Captures.md.

Environment Variables (.env)
Variable Description Default / Example
CORTEX_DATA_DIR Directory holding vaults & SQLite index ./data (/data in Docker)
ADMIN_USERNAME Initial administrator username admin
ADMIN_PASSWORD Initial administrator password cortex-admin-change-me
APP_SECRET Session signing & encrypted key secret (32+ chars) (set in .env)
CORTEX_CAPTURE_TOKEN Bearer token for POST /api/capture (empty = disabled)
GEMINI_API_KEY Optional Gemini API key (optional)
COPILOT_GITHUB_TOKEN Optional GitHub Copilot token (optional)
JUNIE_API_KEY Optional JetBrains Junie API key (optional)
OLLAMA_BASE_URL Ollama server endpoint http://127.0.0.1:11434
OLLAMA_MODEL Default Ollama model name llama3.2
TRUSTED_PROXY_AUTH_HEADER Reverse-proxy OAuth username header (empty = disabled)

Repository Structure

CortexMD/
├── .github/workflows/   # Automated Windows, macOS & Linux release builds
├── docker/              # Dockerfile & Docker Compose deployment config
├── docs/                # Architecture, Proxmox deployment, research & plans
├── electron/            # Electron desktop shell, frameless chrome & .md file associations
├── scripts/             # Standalone packaging helpers
├── src/
│   ├── app/             # Next.js App Router pages, fonts & REST/SSE API routes
│   ├── components/      # Zen Editor, Inline Diff, Critique, Export/GDrive & PKM views
│   └── lib/             # Prose diff, editor backdrop, DOCX/HTML export, GDrive, RAG & SQLite
└── tests/               # Vitest config & end-to-end platform + Zen Studio test suites (27 tests)

Documentation


Built for calm, local-first writers and thinkers. Plain Markdown forever.

About

Self-hosted, Markdown-first, AI-native personal knowledge management platform inspired by Obsidian, Notion, and NotebookLM

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages