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.
The frontend is a workspace shell: Write, Graph, Timeline and Canvas are four places you switch between, sharing one editor session. See "Workspaces" below.
Orientation for developers and coding agents: read the code; CLAUDE.md holds only what the code cannot tell you. docs/superpowers/OPEN-FINDINGS.md lists the open decisions. docs/PIPELINES.md documents every scheduled job and ingestion path end to end (what runs, how often, and where the code is).
- Docker & Docker Compose
- OpenAI API key
- 4 GB+ RAM
cp .env.example .env
# Edit .env and set OPENAI_API_KEY
docker-compose up -d
# Follow logs
docker-compose logs -f api
docker-compose logs -f frontend
The database initializes automatically from tables.sql on first run.
| Service | URL | |---|---| | Frontend | http://localhost:5173 | | API docs | http://localhost:8000/docs | | DB admin | http://localhost:8080 (Adminer) |
| Service | Description | Port(s) | |---|---|---| | api | FastAPI backend | 8000 | | frontend | Production build served by nginx | 5173 | | postgres | PostgreSQL 15 + pgvector | 5432 | | adminer | Database admin UI | 8080 | | pg_backup | Automated PostgreSQL backup every 6 hours | — |
Four places, listed in frontend/src/workspaces/registry.js. Only the editor is on the boot path; the other three load via import() on first visit and keep their state (camera, zoom, filters) when you leave and come back.
| Workspace | What it is | Lives in | |---|---|---| | Write | The Tiptap editor — the default place | src/components/focus-writer.js | | Graph | d3 SVG force graph of the knowledge graph | src/components/graph-view.js | | Timeline | d3 histogram + brush over notes by date | src/components/timeline-view.js | | Canvas | Spatial note board with typed connections | src/components/canvas-view.js |
Kontext is not a workspace but a panel — an instrument laid over whichever place you are in (a rail on desktop, full-screen on phone).
A spatial board of note cards on a zoomable plane, with drawn connections between them.
- A saved board is a conversation (
session_id = "canvas_<uuid>"), with the
arrangement inconversations.meta . No separate table.
- Cards cross the wire as
{ message_id, x, y, z }— ids and geometry only,
never note content.
- A connection means "these two notes are related*in this thinking
context* ". Connections live inside the board's own document and arenever knowledge-graph edges — deleting a board deletes its interpretations and touches neither the notes norkb_edge .
- Dragging a connector into empty space paints a ghost card; the note is created only once you type a title.
The full design, including the deliberately-open copy-vs-reference question, is in api/apps/canvas_membership.py.
Tiptap-based markdown editor with:
- Autosave on change +
Ctrl+Smanual save Ctrl+N— new sessionCtrl+K— command palette / link insert- "Neue Session" button (file-circle-plus icon) — starts a fresh session in localStorage without leaving the page
- Drag-and-drop support for images, video, audio, and PDF files (stored in
media_storagevolume) - Dark mode
After 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:
GET /api/kb/{id}/related— pre-computed KB edgesGET /api/analytics/search— semantic/hybrid searchGET /api/kb/{id}/ego-graph— local graph neighborhood
Edges between KB entries are computed with blended weights and cached in the kb_edge table:
- 70% cosine similarity (pgvector)
- 20% IDF-weighted tag overlap
- 10% same-conversation bonus
Clustering 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.
After every message save, a background task calls OpenAI to extract intent and tags. Results are stored and used for search ranking and graph weighting.
Embeddings are generated with text-embedding-3-small (or a local model if configured). Automatic backfill runs for any messages missing embeddings.
Multi-modal search via GET /api/analytics/search:
| search_type | Description | |---|---| | hybrid | pgvector + lexical, merged ranking | | quick | Fast approximate vector search | | lexical | Full-text search only |
/app/external_media is a read-only bind mount for an existing TiddlyWiki images folder, so old [img[...]] references in imported notes keep resolving. Optional — set EXTERNAL_MEDIA_DIR in .env to your folder, or leave it unset to mount an empty local directory. See api/routes/media.py and api/scripts/tiddlywiki_image_migration.py.
Bulk import from a ChatGPT JSON export:
POST /api/bulk-import/chatgpt-production
Timestamps 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).
# Create a message
POST /api/messages
# AI conversation turn
POST /api/messages/chat
# Get a conversation
GET /api/conversations/{id}
# Semantic search
GET /api/analytics/search?query=...&limit=5&search_type=hybrid
# Get cluster info (feeds graph node colors)
GET /api/analytics/clusters
# System health
GET /health
# ChatGPT bulk import
POST /api/bulk-import/chatgpt-production
# Related messages via KB edges
GET /api/kb/{message_id}/related
# Ego-graph subgraph
GET /api/kb/{message_id}/ego-graph
# Canvas boards (a board is a conversation; DELETE never deletes the notes)
POST /api/canvas
GET /api/canvas
GET /api/canvas/{canvas_id}
PUT /api/canvas/{canvas_id}
DELETE /api/canvas/{canvas_id}
The live interactive reference is http://localhost:8000/docs.
api/scripts/fix_chatgpt_timestamps.py
Retroactively corrects created_at timestamps for previously imported ChatGPT conversations by reading the original create_time values from a JSON export.
# Dry run — shows what would change
python api/scripts/fix_chatgpt_timestamps.py conversations.json
# Apply changes
python api/scripts/fix_chatgpt_timestamps.py conversations.json --execute
┌──────────────────┐ ┌───────────────────┐ ┌──────────────────┐
│ Frontend │◄───►│ FastAPI (Python) │◄───►│ PostgreSQL 15 │
│ Vite + Vanilla │ │ SQLAlchemy + │ │ + pgvector │
│ JavaScript │ │ asyncpg │ └──────────────────┘
└──────────────────┘ └───────────────────┘
│
▼
┌──────────────────┐
│ OpenAI API │
│ GPT-4o + embeds │
└──────────────────┘
- Backend : FastAPI, SQLAlchemy — fat route controllers calling procedural
service modules (api/routes/ →api/apps/ ) over a single synchronous engine. Deliberatelynot Clean Architecture: that layering was built, judged over-engineered, and removed. Do not reintroduce it. An incremental async-DB migration is in progress (infrastructure/db_async.py )
- Frontend : Vite + Vanilla JavaScript (no framework)
- Vector store : PostgreSQL + pgvector (
text-embedding-3-small) - AI : OpenAI GPT-4o for chat,
text-embedding-3-smallfor embeddings
# Restart all services
docker-compose restart
# Rebuild the API container
docker-compose build api && docker-compose up -d api
# Check container status
docker-compose ps
# Connect to the database
docker-compose exec postgres psql -U agent -d agentic
# Inspect tables
\dt
SELECT COUNT(*) FROM messages;
SELECT COUNT(*) FROM kb_edge;
原文来源:github.com