English · Русский · Español · Deutsch
Turn project documentation (DOCX / XLSX / PDF) and emails (EML / MSG) into a searchable knowledge base: an LLM splits documents into semantic concepts (Open Knowledge Format), a hybrid vector index stores them for retrieval, and an interactive chat answers questions grounded in your documents with clickable source citations.
Built to solve a real-world pain: a large body of accumulated functional and technical
specifications where plain full-text search cannot answer questions like "how was the
lnState field implemented in development 111" or "which e-sick-leave statuses do we
handle". Keyword search finds word matches; it does not find meaning. This service does —
and always points back to the exact place in the source document.
- Emails as knowledge sources. Upload EML and Outlook MSG files alongside documents. The service extracts the message body and available subject, sender, recipients and date, and processes supported attachments. Search can include emails, exclude them or use only email sources; email attachments follow the same filter.
- Attachments across all supported document types. Embedded files in DOCX, XLSX and PDF, as well as attachments in EML and MSG, are processed recursively, including supported nested documents, emails and archives. Extracted attachment content participates in search and answers, with its place in the source tree preserved. Processing respects supported formats, the selected attachment scope and limits on nesting depth, size and content volume; unavailable or excluded attachments are shown with their reasons.
- Attachment selection and editing. Preview attachments and choose which content enters the knowledge base. For example, if a specification is already uploaded separately, exclude its identical copy inside an email while keeping the email body searchable. Saving a draft does not change search results: apply the scope changes to update the published content.
- Semantic concept extraction (OKF). An LLM breaks documents into meaningful concepts
(a concept per message field, business rule, term definition) with YAML metadata
(
type,title,tags,relations) — not opaque full-text blobs. - Deterministic field-table extraction. Enumeration and XML-field tables are processed
programmatically (row-by-row concepts) with an optional LLM classifier — every row
(
lnState,snils, …) is guaranteed findable, even in 40+ row tables. - Reviewer comments as structured data.
.docxreviewer comments are parsed into question → answer threads, indexed and searchable under areviewtag. - Hybrid retrieval. Dual index over LLM concept summaries and raw chunk text; dense
embeddings + sparse BM25 fused with Reciprocal Rank Fusion, plus graph expansion over
concept relations. Tag-based pre-filtering. Three query modes:
dense,bm25,hybrid. - Grounded RAG chat. Answers are synthesized strictly from retrieved fragments and cite
sources as
[N]links, with source snippets shown in the UI. - PostgreSQL as the source of truth. Documents, tags, concepts, chunks and staging live in PostgreSQL; Qdrant keeps slim vector projections and full text is hydrated on read.
- Upload-time deduplication. File hash (level 1) plus content hash + MinHash/LSH (levels 2–3) warn about duplicate or near-duplicate documents.
- Authentication & RBAC. Pluggable auth providers, Keycloak/OIDC (Authorization Code)
SSO, roles
viewer/editor/admin/security, fail-closed by default. - Security operations. Append-only audit log (INSERT-only DB account on production), four-eyes approval and rate limits for bulk operations, user blocklist.
- Production niceties. Soft-delete trash with restore and retention-based purge, chat session history, document ↔ development/module registry for filtering and grouping.
- Resilient LLM pipeline. Streaming with idle timeouts, retry cascades, truncation
recovery (max-token bump → chunk split → salvage), per-chunk checkpointing with
resume. - Multilingual UI (RU/EN) with data-driven stop words, reference-data translations and runtime UI dictionaries.
| Search settings | Document upload | Search results and sources |
|---|---|---|
![]() |
![]() |
![]() |
The screenshots/ folder contains the same 10 Russian and 10 English screenshots used in the Russian and English user guides.
Upload (docx / xlsx / pdf / eml / msg)
│
▼
┌────────────────────────┐ ┌─────────────────────┐ ┌───────────────────┐
│ Document parser │──►│ OKF generator (LLM) │──►│ PostgreSQL │
│ docx/xlsx/pdf, tables, │ │ semantic chunking, │ │ documents, tags, │
│ reviewer comments, │ │ field-table rows, │ │ concepts, chunks │
│ embedded attachments │ │ comment threads │ │ (source of truth) │
└────────────────────────┘ └─────────────────────┘ └────┬──────────────┘
│ embed
▼
┌─────────────┐ ┌───────────────────────────────────────────────┐
│ Chat Web UI │◄──│ Qdrant: hybrid retrieval │
│ (Next.js) │ │ concept + chunk dual index, │
└─────────────┘ │ dense + BM25 + graph, RRF fusion, tag filters │
└───────────────────────────────────────────────┘
- Upload & API — Python FastAPI;
POST /api/documents, asynchronous processing. - Parsing — the standalone
doc-parserpackage:python-docx(text, reviewer comments, embedded OLE objects),openpyxl(sheets → Markdown),pypdf; recursive attachment extraction across all five upload formats, plus EML/MSG body and metadata parsing. - OKF generation — an LLM (local via Ollama/vLLM or cloud via LiteLLM/OpenRouter) splits text into concepts; enumeration and XML-field tables are extracted programmatically, per row.
- Storage — PostgreSQL is the canonical store for metadata, concepts and chunks;
Qdrant holds the vectors (dense + sparse BM25) for two point types:
concept(LLM summaries) andchunk(raw text, so details the LLM might have dropped — URLs, codes, configs — are still findable). - Search — query is embedded and run through dense / bm25 / hybrid branches (RRF fusion in Python); hits are merged/collapsed per source fragment and tag-filtered.
- Chat — the LLM writes an answer from the retrieved context and cites each fact
[N]; sources (title, snippet, score) are returned separately and rendered as clickable links.
| Layer | Technology |
|---|---|
| Backend | Python 3.12, FastAPI, SQLAlchemy 2.0, LiteLLM |
| Frontend | Next.js (App Router), JavaScript |
| Vector database | Qdrant (dense + sparse BM25 in one collection) |
| Metadata database | PostgreSQL (dev fallback: SQLite) |
| Parser | Custom doc-parser package (python-docx, openpyxl, pypdf) |
| LLM / embeddings | Any OpenAI-compatible endpoint (Ollama, vLLM, OpenRouter, …) |
The native Windows/macOS/Linux launch and the single-server Docker launch remain available. Kubernetes adds separate frontend, API and worker deployments when independent scaling is needed.
Metadata and durable work state live in PostgreSQL; search vectors live in Qdrant. Document originals, generated bundles and other binary artifacts use a separate artifact store. SQLite is a local development fallback, not a distributed database.
| Deployment | PostgreSQL / Qdrant | Artifact storage |
|---|---|---|
| Native local development | Local processes or configured existing services | Local filesystem |
Docker Compose bundled |
Included on the same server, with persistent volumes and no published database ports | Persistent local application volume |
Docker Compose external |
Existing customer services | Persistent local application volume |
| Kubernetes compact | Bundled services managed by the application chart | Local persistent volume |
| Kubernetes distributed, managed | Deployment-managed PostgreSQL and Qdrant | Platform-provided RWX volume or deployment-managed S3-compatible storage |
| Kubernetes distributed, external or mixed | Select managed or customer-owned providers independently for each component | Customer-owned or deployment-managed S3-compatible storage, or shared RWX filesystem (for example NFS through CSI) |
Compose supports exactly two storage modes: STORAGE_MODE=bundled with
COMPOSE_PROFILES=bundled, or STORAGE_MODE=external with the external overlay.
Pass the same selected env file through OKF_RUNTIME_ENV_FILE and
docker compose --env-file; use the
production deployment guide for configuration,
backup and restore commands.
For distributed Kubernetes, the separate storage chart provides basic single-instance PostgreSQL, Qdrant and S3-compatible RustFS recipes. External providers are the default; provisioning is explicit. Managed storage instances do not provide storage HA. See storage operations for provider selection, persistent volumes, credentials and backup ownership.
| Kubernetes mode | Application topology | Scaling scope |
|---|---|---|
compact |
One combined backend and frontend Pod | Single application instance |
frontend-split |
Separate frontend Deployment; one combined backend | Multiple frontend replicas |
distributed |
Separate frontend, API and worker Deployments | Independent replica counts for all three roles; the basic example uses 2 / 2 / 2 |
Distributed operation explicitly opts into OKF_DEPLOYMENT_SCHEMA=replicas-v1.
API and worker replicas share PostgreSQL, Qdrant, an RWX or S3 artifact store and
the installed runtime identity. Each backend Pod runs one process with private
temporary scratch. Increasing a replica count alone does not configure shared
state. The distributed example
keeps application workloads disabled until storage bootstrap and runtime identity
installation are complete. Follow the Kubernetes deployment guide
and platform requirements.
Selected basic configurations have passed training-cluster tests; basic permits
storage downtime. Application replicas do not establish physical host or storage
fault tolerance. Customer platform acceptance remains required, and the
resilient profile is planned and unqualified. Exact tested combinations and
remaining gates are recorded in the support matrix
and acceptance matrix.
Existing document storage requires an explicit migration and integrity checks; changing an endpoint alone does not move the corpus. Consult artifact migration and Kubernetes recovery procedures for the applicable offline migration, backup and cutover procedure.
cp deploy/production/bundled.env.example .docker.local.env
# Set a PostgreSQL password and the LLM/embedding endpoints. For a local UX
# smoke run set ENVIRONMENT=development and AUTH_PROVIDER=disabled.
export OKF_RUNTIME_ENV_FILE=.docker.local.env
docker compose --env-file "$OKF_RUNTIME_ENV_FILE" up -d --build- UI: http://localhost:8080
STORAGE_MODE=bundledstarts PostgreSQL and Qdrant in the singlebundledprofile without publishing their host ports. For customer-managed databases, usedeploy/production/external.env.exampletogether withdeploy/production/docker-compose.external.yml.
Supported on macOS, Linux and Windows; production always runs in Linux containers.
One-time setup (Python 3.12+, Node.js 20+):
cp .env.example .env # model endpoints, DATABASE_URL, QDRANT_URL
python3 -m venv backend/.venv # Windows: python -m venv backend\.venv
backend/.venv/bin/pip install --require-hashes -r backend/requirements.lock.txt
backend/.venv/bin/pip install --no-deps -e ./doc-parser
# Windows: backend\.venv\Scripts\pip install ...
(cd frontend && npm ci)Start and stop the whole stack — Qdrant, Ollama, PostgreSQL, backend (:18000) and frontend (:16300, UI at http://localhost:16300):
./scripts/start-all.sh # macOS / Linux
./scripts/stop-all.sh.\scripts\start-all.ps1 # Windows
.\scripts\stop-all.ps1On macOS/Linux start-all.sh takes service addresses from .env (the same settings the
backend reads) and waits for each service's health check:
- Qdrant — the v1.19.0 binary (
QDRANT_BINorqdrantonPATH); without it, theqdrant/qdrant:v1.19.0Docker image, published on 127.0.0.1 only. Data:~/.local/share/okf-knowledge/qdrant. - PostgreSQL — a server already listening on the
DATABASE_URLport is reused; otherwise a Homebrew cluster (orOKF_PG_DATA) is started withpg_ctl. On Linux, start the system service yourself (sudo systemctl start postgresql). The database fromDATABASE_URLis created if missing; withDATABASE_URLempty the backend uses SQLite. The Homebrew superuser is your macOS login, notpostgres. - Ollama — started only when embeddings or the LLM use
ollama/*on a local address; a running Ollama.app is reused.
stop-all.sh stops only what start-all.sh started; reused services keep running. Logs
and PID files: ~/.local/state/okf-knowledge.
To run the two app processes by hand instead:
cd backend && .venv/bin/python -m uvicorn app.main:app --reload --port 18000
cd frontend && npm run dev -- -p 16300Configure model endpoints and authentication in .env (see .env.example — all keys are
documented there; never commit real secrets). Set ENVIRONMENT=development for local runs.
- SECURITY.md — security policy: threat model, trust boundaries, authentication/RBAC, audit log, retention. (English)
- Production deployment checklist: PRODUCTION_DEPLOYMENT.md (Russian)
- Kubernetes deployment and replicas: deployment guide, storage operations, acceptance matrix
- Architecture & roadmap: OKF_Knowledge_Service_Roadmap.md (Russian)
- Database schema & migrations: MIGRATION_PLAN.md (Russian)
- Search reproduction & quality: SEARCH_REPRODUCTION.md (Russian)
- End-user guide: OKF_User_Guide.md / PDF (Russian)
- SSO / Keycloak OIDC: developer guide and testing guide (Russian)
- Adding a language / stop-words admin instructions: docs/ADD_LANGUAGE.md (Russian)
- AGENTS.md — engineering notes and operational quirks for AI coding agents (maintained in Russian; the deep engineering docs above are intentionally Russian — detailed developer documentation is kept in the author's working language).
MIT License. Releases published before this license change remain under their original AGPL-3.0 terms. The standard PDF provider is pypdf + pypdfium2; third-party notices are in THIRD_PARTY_NOTICES.md.
Choose DB-only (AUDIT_DB_ENABLED=true, AUDIT_STDOUT_MODE=disabled, default),
external-only (false, durable), or both (true, durable). Disabling both
is rejected. All modes include the same security events. External-only retains
the SQL delivery queue but creates no new permanent audit_log rows. JSON stdout
requires a collector; stdout_written is not an OpenSearch acknowledgement.
Upgrade stopped writers to schema 067b1c2d3e4f before starting the new binary.
Old history, queue bytes/states and functional import history are preserved;
old binaries cannot run on v2. No automatic queue cleanup or historical replay
is added. See audit delivery and migration for Helm,
permissions, switching modes, restore and rollback boundaries.


