{"slug": "nuul-self-hosted-personal-knowledge-base-with-an-auto-built-graph", "title": "Nuul – self-hosted personal knowledge base with an auto-built graph", "summary": "Nuul released a self-hosted personal knowledge base that embeds, classifies, clusters and links notes into an automatically maintained knowledge graph without manual tagging, running on Docker Compose with an OpenAI API key and 4 GB or more of RAM. The system pairs a Tiptap-based markdown editor with semantic search and a d3 force-graph view, and stores PostgreSQL 15 with pgvector behind a FastAPI backend, with automated backups every 6 hours. After each save, the system surfaces related notes using a query built from the first 200 characters of the current note with headings stripped, drawing on pre-computed KB edges, semantic/hybrid search and the local ego-graph.", "body_md": "A personal knowledge management system built around a Tiptap-based writing interface, semantic search, and an automatically maintained knowledge graph. Notes are embedded, classified, clustered, and linked — without manual tagging.\n\nThe frontend is a **workspace shell**: Write, Graph, Timeline and Canvas are four\n*places* you switch between, sharing one editor session. See \"Workspaces\" below.\n\n**Orientation for developers and coding agents:** read the code; `CLAUDE.md`\nholds only what the code cannot tell you. `docs/superpowers/OPEN-FINDINGS.md`\nlists the open decisions. `docs/PIPELINES.md` documents every scheduled job\nand ingestion path end to end (what runs, how often, and where the code is).\n\n- Docker & Docker Compose\n- OpenAI API key\n- 4 GB+ RAM\n\n```\ncp .env.example .env\n# Edit .env and set OPENAI_API_KEY\ndocker-compose up -d\n\n# Follow logs\ndocker-compose logs -f api\ndocker-compose logs -f frontend\n```\n\nThe database initializes automatically from `tables.sql` on first run.\n\n| Service | URL | \n|---|---|\n| Frontend | [http://localhost:5173](http://localhost:5173) | \n| API docs | [http://localhost:8000/docs](http://localhost:8000/docs) | \n| DB admin | [http://localhost:8080](http://localhost:8080) (Adminer) | \n\n| Service | Description | Port(s) | \n|---|---|---|\n| `api` | FastAPI backend | 8000 | \n| `frontend` | Production build served by nginx | 5173 | \n| `postgres` | PostgreSQL 15 + pgvector | 5432 | \n| `adminer` | Database admin UI | 8080 | \n| `pg_backup` | Automated PostgreSQL backup every 6 hours | — | \n\nFour places, listed in `frontend/src/workspaces/registry.js`. Only the editor is\non the boot path; the other three load via `import()` on first visit and keep\ntheir state (camera, zoom, filters) when you leave and come back.\n\n| Workspace | What it is | Lives in | \n|---|---|---|\n| Write | The Tiptap editor — the default place | `src/components/focus-writer.js` | \n| Graph | d3 SVG force graph of the knowledge graph | `src/components/graph-view.js` | \n| Timeline | d3 histogram + brush over notes by date | `src/components/timeline-view.js` | \n| Canvas | Spatial note board with typed connections | `src/components/canvas-view.js` | \n\n**Kontext** is not a workspace but a *panel* — an instrument laid over whichever\nplace you are in (a rail on desktop, full-screen on phone).\n\nA spatial board of note cards on a zoomable plane, with drawn connections between them.\n\n- A saved board **is a conversation** (`session_id = \"canvas_<uuid>\"` ), with the\narrangement in`conversations.meta` . No separate table.\n- Cards cross the wire as `{ message_id, x, y, z }` — ids and geometry only,\nnever note content.\n- A **connection** means \"these two notes are related*in this thinking\ncontext* \". Connections live inside the board's own document and are**never** knowledge-graph edges — deleting a board deletes its interpretations and\ntouches neither the notes nor`kb_edge` .\n- Dragging a connector into empty space paints a ghost card; the note is created only once you type a title.\n\nThe full design, including the deliberately-open copy-vs-reference question, is\nin `api/apps/canvas_membership.py`.\n\nTiptap-based markdown editor with:\n\n- Autosave on change + `Ctrl+S` manual save\n- `Ctrl+N` — new session\n- `Ctrl+K` — command palette / link insert\n- \"Neue Session\" button (file-circle-plus icon) — starts a fresh session in localStorage without leaving the page\n- Drag-and-drop support for images, video, audio, and PDF files (stored in `media_storage` volume)\n- Dark mode\n\nAfter each save, the panel surfaces semantically related notes. The query is derived from the first 200 characters of the current note with headings stripped — this prevents overly broad retrieval (the \"all dreams\" problem). Sources used per query:\n\n- `GET /api/kb/{id}/related` — pre-computed KB edges\n- `GET /api/analytics/search` — semantic/hybrid search\n- `GET /api/kb/{id}/ego-graph` — local graph neighborhood\n\nEdges between KB entries are computed with blended weights and cached in the `kb_edge` table:\n\n- 70% cosine similarity (pgvector)\n- 20% IDF-weighted tag overlap\n- 10% same-conversation bonus\n\nClustering runs as a batch job that feeds the graph view's node colors, not a standalone view. Trigger a rebuild via the palette command \"Clustering neu berechnen\" or `curl -X POST http://localhost:8000/api/analytics/clusters/refresh`.\n\nAfter every message save, a background task calls OpenAI to extract intent and tags. Results are stored and used for search ranking and graph weighting.\n\nEmbeddings are generated with `text-embedding-3-small` (or a local model if configured). Automatic backfill runs for any messages missing embeddings.\n\nMulti-modal search via `GET /api/analytics/search`:\n\n| `search_type` | Description | \n|---|---|\n| `hybrid` | pgvector + lexical, merged ranking | \n| `quick` | Fast approximate vector search | \n| `lexical` | Full-text search only | \n\n`/app/external_media` is a read-only bind mount for an existing TiddlyWiki\nimages folder, so old `[img[...]]` references in imported notes keep\nresolving. Optional — set `EXTERNAL_MEDIA_DIR` in `.env` to your folder, or\nleave it unset to mount an empty local directory. See `api/routes/media.py`\nand `api/scripts/tiddlywiki_image_migration.py`.\n\nBulk import from a ChatGPT JSON export:\n\n```\nPOST /api/bulk-import/chatgpt-production\n```\n\nTimestamps are read from the `create_time` field in the export. If you imported conversations before this fix was applied, use the retroactive fix script (see Scripts section below).\n\n```\n# Create a message\nPOST /api/messages\n\n# AI conversation turn\nPOST /api/messages/chat\n\n# Get a conversation\nGET /api/conversations/{id}\n\n# Semantic search\nGET /api/analytics/search?query=...&limit=5&search_type=hybrid\n\n# Get cluster info (feeds graph node colors)\nGET /api/analytics/clusters\n\n# System health\nGET /health\n\n# ChatGPT bulk import\nPOST /api/bulk-import/chatgpt-production\n\n# Related messages via KB edges\nGET /api/kb/{message_id}/related\n\n# Ego-graph subgraph\nGET /api/kb/{message_id}/ego-graph\n\n# Canvas boards (a board is a conversation; DELETE never deletes the notes)\nPOST   /api/canvas\nGET    /api/canvas\nGET    /api/canvas/{canvas_id}\nPUT    /api/canvas/{canvas_id}\nDELETE /api/canvas/{canvas_id}\n```\n\nThe live interactive reference is `http://localhost:8000/docs`.\n\n`api/scripts/fix_chatgpt_timestamps.py`\n\nRetroactively corrects `created_at` timestamps for previously imported ChatGPT conversations by reading the original `create_time` values from a JSON export.\n\n```\n# Dry run — shows what would change\npython api/scripts/fix_chatgpt_timestamps.py conversations.json\n\n# Apply changes\npython api/scripts/fix_chatgpt_timestamps.py conversations.json --execute\n┌──────────────────┐     ┌───────────────────┐     ┌──────────────────┐\n│  Frontend        │◄───►│  FastAPI (Python) │◄───►│  PostgreSQL 15   │\n│  Vite + Vanilla  │     │  SQLAlchemy +     │     │  + pgvector      │\n│  JavaScript      │     │  asyncpg          │     └──────────────────┘\n└──────────────────┘     └───────────────────┘\n                                  │\n                                  ▼\n                        ┌──────────────────┐\n                        │  OpenAI API      │\n                        │  GPT-4o + embeds │\n                        └──────────────────┘\n```\n\n- **Backend** : FastAPI, SQLAlchemy — fat route controllers calling procedural\nservice modules (`api/routes/` →`api/apps/` ) over a single synchronous\nengine. Deliberately**not** Clean Architecture: that layering was built, judged\nover-engineered, and removed. Do not reintroduce it.\nAn incremental async-DB migration is in progress (`infrastructure/db_async.py` )\n- **Frontend** : Vite + Vanilla JavaScript (no framework)\n- **Vector store** : PostgreSQL + pgvector (`text-embedding-3-small` )\n- **AI** : OpenAI GPT-4o for chat,`text-embedding-3-small` for embeddings\n\n```\n# Restart all services\ndocker-compose restart\n\n# Rebuild the API container\ndocker-compose build api && docker-compose up -d api\n\n# Check container status\ndocker-compose ps\n\n# Connect to the database\ndocker-compose exec postgres psql -U agent -d agentic\n\n# Inspect tables\n\\dt\nSELECT COUNT(*) FROM messages;\nSELECT COUNT(*) FROM kb_edge;\n```\n\n", "url": "https://wpnews.pro/news/nuul-self-hosted-personal-knowledge-base-with-an-auto-built-graph", "canonical_source": "https://github.com/scopalaffairs/nuul", "published_at": "2026-11-29 22:12:54+00:00", "updated_at": "2026-11-29 22:46:43.699392+00:00", "lang": "en", "topics": ["ai-tools", "ai-products", "developer-tools", "large-language-models", "ai-agents"], "entities": ["Nuul", "Tiptap", "OpenAI", "FastAPI", "PostgreSQL", "pgvector", "d3", "Adminer"], "also_reported_by": [], "takeaway": "Nuul derives its related-notes query from only the first 200 characters of a note with headings stripped to avoid overly broad retrieval, and serves it from three endpoints: pre-computed KB edges, semantic/hybrid search, and the ego-graph.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/nuul-self-hosted-personal-knowledge-base-with-an-auto-built-graph", "markdown": "https://wpnews.pro/news/nuul-self-hosted-personal-knowledge-base-with-an-auto-built-graph.md", "text": "https://wpnews.pro/news/nuul-self-hosted-personal-knowledge-base-with-an-auto-built-graph.txt", "jsonld": "https://wpnews.pro/news/nuul-self-hosted-personal-knowledge-base-with-an-auto-built-graph.jsonld"}}