@hiai-gg/hiai-docs
v0.2.9
Published
The lightweight, AI-native self-hosted knowledge base — built-in RAG, hybrid semantic search, and a clean REST API for AI agents.
Maintainers
Readme
HiAi-Docs
A self-hosted, AI-native knowledge workspace for people, applications, and agents.
HiAi-Docs stores documents in a structured JSON editor model first. Markdown is the convenient second format for editing, importing, and exporting content. Automatic chunking, 1024-dimensional embeddings, multilingual hybrid search, and GraphRAG make the same knowledge base useful to people, applications, and agents through the web application, REST API, TypeScript SDK, CLI, and MCP server.
Why HiAi-Docs?
- Write naturally in a rich visual editor or raw Markdown.
- Find meaning, not only keywords with exact, lexical, fuzzy, vector, multilingual expansion, and graph retrieval fused through RRF.
- Keep retrieval current with automatic, incremental chunking and re-embedding after document or metadata changes.
- Connect agents directly through REST, a typed SDK, CLI, or MCP.
- Control access with global keys or category-scoped
read,edit, andwritepermissions. - Own the full stack: application data, vectors, graph, queue, and files run on infrastructure you control.
Fastest installation: give this prompt to your agent
If you are installing HiAi-Docs through an AI coding agent, use this path first. It keeps the setup to Docker plus one provider choice and avoids unnecessary source-code changes.
Install HiAi-Docs from https://github.com/HiAi-gg/hiai-docs.
Verify Docker and Docker Compose v2, clone the repository, and run
`bash scripts/quickstart.sh`. Do not print or commit .env. Ask me to enter only
an OpenRouter key or select Ollama, then run quickstart again. Verify
http://localhost:50701, http://localhost:50700/api/health, and
`docker compose ps`. Do not replace Bun, rewrite migrations, disable GraphRAG,
or delete volumes.After startup, open http://localhost:50701 and create the first account. For manual installation, use the Docker quickstart below.
Quickstart
Requirements
- Docker Engine or Docker Desktop
- Docker Compose v2
- One of:
- an OpenRouter API key; or
- a local Ollama instance
Start with Docker
git clone https://github.com/HiAi-gg/hiai-docs.git
cd hiai-docs
bash scripts/quickstart.shOn its first run, the script creates an ignored root .env, generates the
database, authentication, and storage secrets, builds the PostgreSQL image,
applies migrations, and starts the complete application.
For OpenRouter, add one value to .env and run the script again:
OPENROUTER_API_KEY=sk-or-your-keyFor Ollama, select the local provider instead:
AI_PROVIDER=ollama
OLLAMA_PORT=11434Then make sure the configured local models are available:
ollama pull bge-m3
ollama pull qwen3:8b
bash scripts/quickstart.shOpen http://localhost:50701. The API health endpoint is http://localhost:50700/api/health.
First use
- Create your account in the web application.
- Create a category or folder and add or import a document.
- Wait for the document pipeline to finish chunking and embedding.
- Search using an exact phrase, a related concept, an alternate language, or a misspelling.
- Open Settings → API when you want to connect a CLI, MCP client, or external application.
The canonical local ports are:
| Service | Port |
|---|---:|
| Web application | 50701 |
| REST API | 50700 |
| PostgreSQL | 5437 |
| Redis | 6384 |
| SeaweedFS S3 gateway | 50702 |
| SeaweedFS filer UI | 50703 |
See Deployment for domains, TLS, provider tuning, backups, and production operation.
Use HiAi-Docs from the terminal
The published package includes the CLI. It connects to an already running HiAi-Docs server; installing it does not deploy the server.
bunx --package @hiai-gg/hiai-docs hiai-docs init \
--url http://localhost:50700 \
--key 'your-global-or-category-key'
bunx --package @hiai-gg/hiai-docs hiai-docs search "project architecture"
bunx --package @hiai-gg/hiai-docs hiai-docs list
bunx --package @hiai-gg/hiai-docs hiai-docs read <document-id>
bunx --package @hiai-gg/hiai-docs hiai-docs create \
--title "Release notes" --content "# Version 0.2.9"Credentials can also be supplied through HIAI_DOCS_URL and
HIAI_DOCS_API_KEY. See the CLI guide for every
command and configuration precedence.
Connect an MCP client
HiAi-Docs exposes document search, reading, creation, updates, folders, snapshots, history, and export as MCP tools.
{
"mcpServers": {
"hiai-docs": {
"command": "bunx",
"args": ["--package", "@hiai-gg/hiai-docs", "hiai-docs-mcp"],
"env": {
"HIAI_DOCS_URL": "http://localhost:50700",
"HIAI_DOCS_API_KEY": "your-global-or-category-key"
}
}
}
}Run the server directly to verify the installation:
bunx --package @hiai-gg/hiai-docs hiai-docs-mcpThe server uses stdio and works with MCP-capable clients such as Claude Desktop, Cursor, and coding agents that accept standard MCP configuration. See the MCP guide for its ten tools and routes.
Agent skills after installation
The MCP tools are the recommended portable agent skills. A category-bound agent can receive only the knowledge and operations it needs; a trusted personal agent can use a global key. Agents do not need database or filesystem access. After startup, create an API key in Settings → API and add the MCP block above to the agent client. For custom agent workflows, use the same key through the CLI, SDK, or REST API.
TypeScript SDK
bun add @hiai-gg/hiai-docsimport { DocsClient } from "@hiai-gg/hiai-docs";
const docs = new DocsClient({
baseUrl: "http://localhost:50700",
apiKey: process.env.HIAI_DOCS_API_KEY,
});
const created = await docs.createDoc({
title: "Meeting notes",
content: "# Agenda",
});
const results = await docs.search("what did we decide?");
console.log(created.id, results.items);The SDK is a typed fetch client with retries for transient failures. See the
SDK reference and REST API.
API keys and integrations
Create and revoke integration keys from Settings → API.
| Credential | Intended use | Access |
|---|---|---|
| Global API key | Trusted owner-wide CLI, MCP, SDK, or service | All owner content |
| Category key | Least-privilege agent or product integration | One category with selected permissions |
| Operator key | Administration and reindex operations | /api/admin/* only |
Category permissions are explicit and non-hierarchical:
readpermits list, read, search, and export;editpermits updates to existing content, attachments, and versions;writepermits create, move, delete, share, and publish operations.
Combine permissions when an integration needs more than one capability.
API-key lifecycle operations require the owning browser session; an API key
cannot create or elevate another key. Server-to-server integrations are not
affected by browser CORS. Browser integrations must add their exact origin to
CORS_ORIGINS.
What is included?
frontend/ SvelteKit workspace and TipTap editor
backend/ Elysia REST API, search, workers, and authentication
packages/db/ Drizzle schema and migrations
packages/sdk/ Typed API client
packages/cli/ Terminal client
packages/mcp-server/ MCP stdio server
postgres/ PostgreSQL image with vector and graph extensionsThe Docker deployment runs:
- Web — document editor, folders, categories, sharing, settings, and search;
- API — documents, attachments, versions, keys, search, and administration;
- PostgreSQL 18 — relational data, pgvector/pgvectorscale vectors, and the Apache AGE graph in one database;
- Redis 8 — BullMQ queues, caching, retries, and job recovery;
- SeaweedFS — S3-compatible attachment storage.
How search works
Every document save schedules background work. Content is chunked, changed chunks are embedded, and the completed generation is activated atomically. The previous valid generation remains searchable if a provider call fails.
Search combines exact title matches, multilingual lexical search, typo-tolerant fuzzy matching, semantic vectors, adaptive query expansion, and Apache AGE graph neighbors. Reciprocal rank fusion combines the channels without allowing one weak provider result to dominate. Authorization is applied before retrieval and again before results are returned.
GraphRAG is part of the normal search path in the reference configuration. It extracts entities after embeddings are ready and finds related documents beyond direct keyword or vector similarity. It degrades gracefully when an external model is unavailable.
For pipeline internals and tuning, see Architecture and Deployment.
Stack
- Bun, TypeScript, Elysia, Zod, and Pino
- Svelte 5, SvelteKit, Tailwind CSS, and TipTap
- Better Auth and Drizzle ORM
- PostgreSQL 18, pgvector, pgvectorscale, and Apache AGE
- Redis 8 and BullMQ
- SeaweedFS with its S3-compatible API
- OpenAI-compatible providers through OpenRouter or local Ollama
Comparison
HiAi-Docs overlaps with several excellent open-source knowledge tools, but its focus is a compact knowledge runtime shared equally by humans and agents.
| Project | Primary strength | Difference from HiAi-Docs | |---|---|---| | Outline | Polished team wiki and collaboration | HiAi-Docs emphasizes built-in retrieval, GraphRAG, scoped agent access, CLI, and MCP | | Docmost | Collaborative wiki and real-time editing | HiAi-Docs centers automatic embeddings and agent-facing integration surfaces | | AppFlowy | Broad local-first productivity workspace | HiAi-Docs is narrower: a self-hosted document and retrieval service | | AnythingLLM | Chat-oriented RAG over imported sources | HiAi-Docs starts with the editable knowledge base and exposes it to many clients | | Danswer / Onyx | Enterprise search across external connectors | HiAi-Docs owns and edits its native corpus rather than primarily indexing other systems |
This is a product-positioning summary, not a claim that every listed project lacks a feature. Check each project's current documentation when choosing a deployment.
Documentation
- Documentation index
- Product usage
- REST API and OpenAPI JSON
- Architecture
- Deployment and operations
- Extension points
- Maintainer release flow
- Security policy
- Changelog
Development
bun install
bun run lint
bun run typecheck
bun run test
bun run buildRead CONTRIBUTING.md before opening a pull request. Please report vulnerabilities through SECURITY.md, not a public issue.
License
HiAi-Docs is released under the MIT License.
Part of the HiAi open-source ecosystem.
