@hiai-gg/hiai-docs 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.all-contributorsrc +18 -0
- package/.claude/settings.local.json +61 -0
- package/.dockerignore +113 -0
- package/.env.example +68 -0
- package/.github/FUNDING.yml +5 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +74 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +78 -0
- package/.github/dependabot.yml +136 -0
- package/.github/pull_request_template.md +96 -0
- package/.github/workflows/ci.yml +283 -0
- package/AGENTS.md +237 -0
- package/CODE_OF_CONDUCT.md +134 -0
- package/CONTRIBUTING.md +77 -0
- package/Caddyfile +50 -0
- package/Dockerfile.backend +60 -0
- package/LICENSE +21 -0
- package/README.md +284 -0
- package/RELEASE_CHECKLIST.md +34 -0
- package/SECURITY.md +60 -0
- package/backend/package.json +43 -0
- package/backend/src/__tests__/auth-helpers.test.ts +51 -0
- package/backend/src/__tests__/chunker.test.ts +65 -0
- package/backend/src/__tests__/config.test.ts +91 -0
- package/backend/src/__tests__/csrf.test.ts +91 -0
- package/backend/src/__tests__/embedding.test.ts +48 -0
- package/backend/src/__tests__/rate-limit.test.ts +46 -0
- package/backend/src/__tests__/routes.test.ts +38 -0
- package/backend/src/__tests__/schema.test.ts +31 -0
- package/backend/src/__tests__/validation.test.ts +556 -0
- package/backend/src/api/middleware/auth.ts +56 -0
- package/backend/src/api/middleware/csrf.ts +91 -0
- package/backend/src/api/middleware/rate-limit.ts +77 -0
- package/backend/src/api/middleware/webhook-verify.ts +22 -0
- package/backend/src/api/routes/attachments.ts +280 -0
- package/backend/src/api/routes/auth.ts +52 -0
- package/backend/src/api/routes/collaboration.ts +121 -0
- package/backend/src/api/routes/documents.ts +664 -0
- package/backend/src/api/routes/folders.ts +226 -0
- package/backend/src/api/routes/search.ts +354 -0
- package/backend/src/api/routes/share.ts +512 -0
- package/backend/src/api/routes/tags.ts +247 -0
- package/backend/src/api/routes/versions.ts +99 -0
- package/backend/src/api/routes/webhooks.ts +43 -0
- package/backend/src/embedding/chunker.ts +74 -0
- package/backend/src/embedding/index.ts +117 -0
- package/backend/src/embedding/providers/ollama.ts +63 -0
- package/backend/src/embedding/providers/openrouter.ts +71 -0
- package/backend/src/embedding/utils.ts +13 -0
- package/backend/src/embedding/worker.ts +89 -0
- package/backend/src/index.ts +147 -0
- package/backend/src/lib/auth-helpers.ts +27 -0
- package/backend/src/lib/auth.ts +35 -0
- package/backend/src/lib/config.ts +73 -0
- package/backend/src/lib/db.ts +7 -0
- package/backend/src/lib/embedding-queue.ts +12 -0
- package/backend/src/lib/logger.ts +18 -0
- package/backend/src/lib/markdown-to-doc.ts +45 -0
- package/backend/src/lib/minio.ts +46 -0
- package/backend/src/lib/redis.ts +19 -0
- package/backend/src/lib/yjs-provider.ts +182 -0
- package/backend/tests/integration/_harness.ts +754 -0
- package/backend/tests/integration/auth.test.ts +296 -0
- package/backend/tests/integration/routes.documents.test.ts +459 -0
- package/backend/tests/integration/routes.folders.test.ts +337 -0
- package/backend/tests/integration/routes.search.test.ts +322 -0
- package/backend/tests/integration/routes.share.test.ts +773 -0
- package/backend/tests/integration/routes.tags.test.ts +425 -0
- package/backend/tests/integration/routes.versions.test.ts +233 -0
- package/backend/tsconfig.json +18 -0
- package/docker-compose.yml +218 -0
- package/docs/API.md +328 -0
- package/docs/ARCHITECTURE.md +75 -0
- package/docs/DEPLOYMENT.md +113 -0
- package/docs/PRODUCTION_STATUS.md +61 -0
- package/docs/openapi.json +385 -0
- package/frontend/.svelte-kit.old/ambient.d.ts +230 -0
- package/frontend/.svelte-kit.old/env.d.ts +1 -0
- package/frontend/.svelte-kit.old/generated/client/app.js +46 -0
- package/frontend/.svelte-kit.old/generated/client/matchers.js +1 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/0.js +3 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/1.js +1 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/10.js +3 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/2.js +1 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/3.js +1 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/4.js +1 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/5.js +3 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/6.js +1 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/7.js +3 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/8.js +1 -0
- package/frontend/.svelte-kit.old/generated/client/nodes/9.js +3 -0
- package/frontend/.svelte-kit.old/generated/root.js +3 -0
- package/frontend/.svelte-kit.old/generated/root.svelte +80 -0
- package/frontend/.svelte-kit.old/generated/server/internal.js +55 -0
- package/frontend/.svelte-kit.old/non-ambient.d.ts +59 -0
- package/frontend/.svelte-kit.old/tsconfig.json +59 -0
- package/frontend/.svelte-kit.old/types/route_meta_data.json +40 -0
- package/frontend/.svelte-kit.old/types/src/routes/$types.d.ts +21 -0
- package/frontend/.svelte-kit.old/types/src/routes/(app)/$types.d.ts +30 -0
- package/frontend/.svelte-kit.old/types/src/routes/(app)/docs/[id]/$types.d.ts +27 -0
- package/frontend/.svelte-kit.old/types/src/routes/(app)/docs/[id]/proxy+page.ts +25 -0
- package/frontend/.svelte-kit.old/types/src/routes/api/[...path]/$types.d.ts +10 -0
- package/frontend/.svelte-kit.old/types/src/routes/folders/[id]/$types.d.ts +27 -0
- package/frontend/.svelte-kit.old/types/src/routes/folders/[id]/proxy+page.ts +15 -0
- package/frontend/.svelte-kit.old/types/src/routes/login/$types.d.ts +17 -0
- package/frontend/.svelte-kit.old/types/src/routes/register/$types.d.ts +17 -0
- package/frontend/.svelte-kit.old/types/src/routes/s/[token]/$types.d.ts +20 -0
- package/frontend/.svelte-kit.old/types/src/routes/s/[token]/proxy+page.ts +6 -0
- package/frontend/.svelte-kit.old/types/src/routes/search/$types.d.ts +19 -0
- package/frontend/.svelte-kit.old/types/src/routes/search/proxy+page.ts +26 -0
- package/frontend/.svelte-kit.old/types/src/routes/settings/$types.d.ts +17 -0
- package/frontend/Dockerfile +44 -0
- package/frontend/biome.json +40 -0
- package/frontend/components.json +18 -0
- package/frontend/messages/en.json +434 -0
- package/frontend/package.json +70 -0
- package/frontend/project.inlang/settings.json +12 -0
- package/frontend/src/app.css +6 -0
- package/frontend/src/app.d.ts +13 -0
- package/frontend/src/app.html +30 -0
- package/frontend/src/hooks.server.ts +10 -0
- package/frontend/src/hooks.ts +10 -0
- package/frontend/src/lib/api/attachments.ts +45 -0
- package/frontend/src/lib/api/client.test.ts +15 -0
- package/frontend/src/lib/api/client.ts +57 -0
- package/frontend/src/lib/api/documents.ts +83 -0
- package/frontend/src/lib/api/folders.ts +180 -0
- package/frontend/src/lib/api/search.test.ts +52 -0
- package/frontend/src/lib/api/search.ts +128 -0
- package/frontend/src/lib/api/settings.ts +95 -0
- package/frontend/src/lib/api/share.ts +71 -0
- package/frontend/src/lib/api/tags.test.ts +91 -0
- package/frontend/src/lib/api/tags.ts +87 -0
- package/frontend/src/lib/auth-client.ts +10 -0
- package/frontend/src/lib/collaboration.ts +63 -0
- package/frontend/src/lib/components/AttachmentUpload.svelte +110 -0
- package/frontend/src/lib/components/DatePicker.svelte +322 -0
- package/frontend/src/lib/components/DocumentCard.svelte +166 -0
- package/frontend/src/lib/components/EmptyState.svelte +49 -0
- package/frontend/src/lib/components/FolderCard.svelte +93 -0
- package/frontend/src/lib/components/ScrollToTop.svelte +72 -0
- package/frontend/src/lib/components/SearchBar.svelte +47 -0
- package/frontend/src/lib/components/SearchResult.svelte +115 -0
- package/frontend/src/lib/components/SettingsDialog.svelte +271 -0
- package/frontend/src/lib/components/ShareDialog.svelte +158 -0
- package/frontend/src/lib/components/ShareLink.svelte +98 -0
- package/frontend/src/lib/components/TagCreateDialog.svelte +284 -0
- package/frontend/src/lib/components/VersionDiff.svelte +55 -0
- package/frontend/src/lib/components/VersionHistory.svelte +96 -0
- package/frontend/src/lib/components/editor/DocumentTitle.svelte +87 -0
- package/frontend/src/lib/components/editor/EditorToolbar.svelte +1367 -0
- package/frontend/src/lib/components/editor/HiAiEditor.svelte +531 -0
- package/frontend/src/lib/components/editor/LinkDialog.svelte +134 -0
- package/frontend/src/lib/components/editor/MarkdownToggle.svelte +88 -0
- package/frontend/src/lib/components/editor/editorExtensions.ts +53 -0
- package/frontend/src/lib/components/editor/markdown.ts +38 -0
- package/frontend/src/lib/components/sidebar/FolderTree.svelte +731 -0
- package/frontend/src/lib/components/sidebar/RecentDocs.svelte +311 -0
- package/frontend/src/lib/components/sidebar/Sidebar.svelte +156 -0
- package/frontend/src/lib/components/sidebar/TagList.svelte +200 -0
- package/frontend/src/lib/components/ui/confirm-dialog/ConfirmDialog.svelte +76 -0
- package/frontend/src/lib/components/ui/confirm-dialog/index.ts +1 -0
- package/frontend/src/lib/stores/tag-store.svelte.ts +56 -0
- package/frontend/src/lib/stores/theme.svelte.ts +97 -0
- package/frontend/src/lib/svelte.d.ts +6 -0
- package/frontend/src/lib/types.ts +44 -0
- package/frontend/src/lib/utils/clipboard.ts +17 -0
- package/frontend/src/lib/utils/strip-markdown.ts +59 -0
- package/frontend/src/lib/utils.ts +33 -0
- package/frontend/src/routes/(app)/+layout.svelte +17 -0
- package/frontend/src/routes/(app)/+page.server.ts +10 -0
- package/frontend/src/routes/(app)/+page.svelte +303 -0
- package/frontend/src/routes/(app)/docs/[id]/+page.server.ts +10 -0
- package/frontend/src/routes/(app)/docs/[id]/+page.svelte +1108 -0
- package/frontend/src/routes/(app)/docs/[id]/+page.ts +24 -0
- package/frontend/src/routes/(app)/search/+page.svelte +593 -0
- package/frontend/src/routes/(app)/search/+page.ts +25 -0
- package/frontend/src/routes/+error.svelte +12 -0
- package/frontend/src/routes/+layout.svelte +18 -0
- package/frontend/src/routes/+layout.ts +2 -0
- package/frontend/src/routes/api/[...path]/+server.ts +111 -0
- package/frontend/src/routes/folders/[id]/+page.server.ts +10 -0
- package/frontend/src/routes/folders/[id]/+page.svelte +319 -0
- package/frontend/src/routes/folders/[id]/+page.ts +14 -0
- package/frontend/src/routes/login/+page.svelte +90 -0
- package/frontend/src/routes/register/+page.svelte +97 -0
- package/frontend/src/routes/s/[token]/+page.svelte +496 -0
- package/frontend/src/routes/s/[token]/+page.ts +5 -0
- package/frontend/src/routes/settings/+page.svelte +175 -0
- package/frontend/static/favicon.png +0 -0
- package/frontend/static/logo.png +0 -0
- package/frontend/svelte.config.js +15 -0
- package/frontend/tsconfig.json +15 -0
- package/frontend/vite.config.ts +25 -0
- package/init.sql +9 -0
- package/logo.png +0 -0
- package/package.json +39 -0
- package/package.public.json +39 -0
- package/packages/db/drizzle.config.ts +10 -0
- package/packages/db/package.json +30 -0
- package/packages/db/src/client.ts +9 -0
- package/packages/db/src/index.ts +2 -0
- package/packages/db/src/migrations/0000_nice_bedlam.sql +165 -0
- package/packages/db/src/migrations/0001_w2_3_test.sql +5 -0
- package/packages/db/src/migrations/0002_rename_content_json.sql +2 -0
- package/packages/db/src/migrations/meta/0000_snapshot.json +1331 -0
- package/packages/db/src/migrations/meta/0001_snapshot.json +1399 -0
- package/packages/db/src/migrations/meta/0002_snapshot.json +1399 -0
- package/packages/db/src/migrations/meta/_journal.json +27 -0
- package/packages/db/src/schema.ts +378 -0
- package/packages/db/tsconfig.json +17 -0
- package/scripts/export-openapi.ts +37 -0
- package/scripts/health-check.sh +75 -0
- package/scripts/migrate.sh +135 -0
- package/scripts/prework_backup.sh +25 -0
- package/scripts/release.sh +83 -0
- package/tsconfig.json +25 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Contributing to hiai-docs
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing!
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
1. Fork the repository
|
|
8
|
+
2. Clone your fork
|
|
9
|
+
3. Create a feature branch: `git checkout -b feature/my-change`
|
|
10
|
+
4. Make your changes
|
|
11
|
+
5. Run checks: `bun run lint && bun run typecheck`
|
|
12
|
+
6. Commit with a clear message
|
|
13
|
+
7. Push and open a Pull Request
|
|
14
|
+
|
|
15
|
+
## Branch Naming
|
|
16
|
+
|
|
17
|
+
- `feature/description` — new features
|
|
18
|
+
- `fix/description` — bug fixes
|
|
19
|
+
- `refactor/description` — code refactoring
|
|
20
|
+
- `docs/description` — documentation changes
|
|
21
|
+
|
|
22
|
+
## Commit Messages
|
|
23
|
+
|
|
24
|
+
Use [Conventional Commits](https://www.conventionalcommits.org/):
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
feat: add document version diff view
|
|
28
|
+
fix: resolve search pagination off-by-one
|
|
29
|
+
refactor: extract folder tree into separate component
|
|
30
|
+
docs: update API reference for share endpoints
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Code Style
|
|
34
|
+
|
|
35
|
+
- **Runtime**: Bun only (no npm/yarn)
|
|
36
|
+
- **Modules**: ESM only (`import`/`export`, no `require`)
|
|
37
|
+
- **TypeScript**: strict mode, no `any` types
|
|
38
|
+
- **Language**: English only — code, comments, docs, commit messages
|
|
39
|
+
- **Validation**: Zod for all API inputs
|
|
40
|
+
- **No Playwright**: use agent-browser for E2E tests
|
|
41
|
+
|
|
42
|
+
## Project Structure
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
hiai-docs/
|
|
46
|
+
├── backend/ # Elysia API (Bun)
|
|
47
|
+
├── frontend/ # SvelteKit (Svelte 5 + Tailwind v4)
|
|
48
|
+
├── packages/db/ # Drizzle ORM schema + migrations
|
|
49
|
+
├── docker-compose.yml
|
|
50
|
+
└── .env.example
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Testing
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Backend unit tests
|
|
57
|
+
cd backend && bun test
|
|
58
|
+
|
|
59
|
+
# Frontend tests
|
|
60
|
+
cd frontend && bun run test
|
|
61
|
+
|
|
62
|
+
# Type check everything
|
|
63
|
+
bun run typecheck
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Pull Request Checklist
|
|
67
|
+
|
|
68
|
+
- [ ] Code compiles without errors (`bun run typecheck`)
|
|
69
|
+
- [ ] Linting passes (`bun run lint`)
|
|
70
|
+
- [ ] Tests pass (`bun test`)
|
|
71
|
+
- [ ] No hardcoded secrets or paths
|
|
72
|
+
- [ ] Commit messages follow Conventional Commits
|
|
73
|
+
- [ ] Changes are focused — one feature/fix per PR
|
|
74
|
+
|
|
75
|
+
## Questions?
|
|
76
|
+
|
|
77
|
+
Open an issue or start a discussion on GitHub.
|
package/Caddyfile
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# hiai-docs Caddyfile
|
|
2
|
+
|
|
3
|
+
:80 {
|
|
4
|
+
# For local development / Docker internal
|
|
5
|
+
reverse_proxy /api/* api:50700
|
|
6
|
+
reverse_proxy web:50701
|
|
7
|
+
|
|
8
|
+
encode gzip
|
|
9
|
+
log
|
|
10
|
+
|
|
11
|
+
header {
|
|
12
|
+
# Restrictive CSP — allows same-origin + dev WebSocket
|
|
13
|
+
Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' http://localhost:50700 ws://localhost:50700; font-src 'self' data:; frame-ancestors 'none'; form-action 'self'"
|
|
14
|
+
# HSTS — harmless on plain HTTP, enforced once TLS is provisioned
|
|
15
|
+
Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
|
16
|
+
X-Content-Type-Options "nosniff"
|
|
17
|
+
X-Frame-Options "DENY"
|
|
18
|
+
Referrer-Policy "strict-origin-when-cross-origin"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
docs.{$DOMAIN:localhost} {
|
|
23
|
+
# For production — Caddy auto-provisions TLS
|
|
24
|
+
reverse_proxy /api/* api:50700
|
|
25
|
+
reverse_proxy web:50701
|
|
26
|
+
|
|
27
|
+
encode gzip
|
|
28
|
+
log
|
|
29
|
+
|
|
30
|
+
rate_limit {
|
|
31
|
+
zone dynamic {
|
|
32
|
+
key {remote_host}
|
|
33
|
+
events 100
|
|
34
|
+
window 1m
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
header {
|
|
39
|
+
# Restrictive CSP — SvelteKit requires 'unsafe-inline' in style-src
|
|
40
|
+
# because it injects styles at runtime and cannot use nonces.
|
|
41
|
+
# This is an accepted trade-off for SvelteKit SPAs.
|
|
42
|
+
Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' wss:// https://; font-src 'self' data:; frame-ancestors 'none'; form-action 'self'"
|
|
43
|
+
# HSTS — 1 year, include subdomains, preload-ready
|
|
44
|
+
Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
|
45
|
+
X-Content-Type-Options "nosniff"
|
|
46
|
+
X-Frame-Options "DENY"
|
|
47
|
+
Referrer-Policy "strict-origin-when-cross-origin"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
FROM oven/bun:1.3.14-alpine AS base
|
|
2
|
+
WORKDIR /app
|
|
3
|
+
|
|
4
|
+
# --- Install dependencies ---
|
|
5
|
+
# A root install creates /app/node_modules with hoisted deps. Then per-workspace
|
|
6
|
+
# installs populate each package's local node_modules. This is required because
|
|
7
|
+
# bun's resolver, when run from a workspace package, only looks in that
|
|
8
|
+
# package's own node_modules (not the parent's) — and the build runs from
|
|
9
|
+
# /app/backend/, so it needs backend/node_modules with workspace symlinks.
|
|
10
|
+
FROM base AS deps
|
|
11
|
+
COPY package.json bun.lock* ./
|
|
12
|
+
COPY backend/package.json ./backend/
|
|
13
|
+
COPY frontend/package.json ./frontend/
|
|
14
|
+
COPY packages/db/package.json ./packages/db/
|
|
15
|
+
COPY .packages/hiai-ui /packages/hiai-ui
|
|
16
|
+
ENV BUN_INSTALL_CONCURRENCY=1
|
|
17
|
+
RUN bun install --no-verify
|
|
18
|
+
RUN bun install --cwd backend --no-verify
|
|
19
|
+
RUN bun install --cwd packages/db --no-verify
|
|
20
|
+
|
|
21
|
+
# --- Build ---
|
|
22
|
+
# Carry node_modules (workspace symlinks) from the deps stage, then layer
|
|
23
|
+
# backend source and the workspace package source (packages/db) on top. We
|
|
24
|
+
# pull packages/db from the build context because the deps stage only has
|
|
25
|
+
# its package.json (just enough for `bun install` to discover it).
|
|
26
|
+
FROM base AS build
|
|
27
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
28
|
+
COPY --from=deps /app/backend/node_modules ./backend/node_modules
|
|
29
|
+
COPY --from=deps /app/packages/db/node_modules ./packages/db/node_modules
|
|
30
|
+
COPY --from=deps /packages/hiai-ui /packages/hiai-ui
|
|
31
|
+
COPY packages/db/ ./packages/db/
|
|
32
|
+
COPY backend/src ./backend/src
|
|
33
|
+
COPY backend/tsconfig.json ./backend/
|
|
34
|
+
COPY backend/package.json ./backend/
|
|
35
|
+
RUN cd backend && bun run build
|
|
36
|
+
|
|
37
|
+
# --- Runtime ---
|
|
38
|
+
# Slim image: only the compiled dist + the node_modules needed at runtime.
|
|
39
|
+
FROM base AS runtime
|
|
40
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
41
|
+
COPY --from=build /app/backend/dist ./backend/dist
|
|
42
|
+
COPY backend/package.json ./backend/
|
|
43
|
+
|
|
44
|
+
ENV NODE_ENV=production
|
|
45
|
+
ENV API_PORT=50700
|
|
46
|
+
WORKDIR /app/backend
|
|
47
|
+
|
|
48
|
+
# Create non-root user and give it ownership of the app directory.
|
|
49
|
+
# Files copied above are owned by root, so we chown to make them readable/writable
|
|
50
|
+
# by the unprivileged `app` user that runs the runtime stage.
|
|
51
|
+
RUN addgroup -S app && adduser -S app -G app \
|
|
52
|
+
&& chown -R app:app /app/backend /app/node_modules # COPY files are root-owned by default; chown is required for non-root USER
|
|
53
|
+
|
|
54
|
+
USER app
|
|
55
|
+
|
|
56
|
+
HEALTHCHECK --interval=30s CMD wget -qO- http://localhost:50700/api/health || exit 1
|
|
57
|
+
|
|
58
|
+
EXPOSE 50700
|
|
59
|
+
|
|
60
|
+
CMD ["bun", "run", "dist/index.js"]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hiai-gg
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# hiai-docs
|
|
2
|
+
|
|
3
|
+
**The lightest AI-native self-hosted knowledge vault.**
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://github.com/hiai-gg/hiai-docs/releases)
|
|
7
|
+
[](https://github.com/hiai-gg/hiai-docs/stargazers)
|
|
8
|
+
[](https://github.com/hiai-gg/hiai-docs/actions/workflows/ci.yml)
|
|
9
|
+
[](https://bun.sh)
|
|
10
|
+
[](https://www.typescriptlang.org)
|
|
11
|
+
[](https://svelte.dev)
|
|
12
|
+
[](https://elysiajs.com)
|
|
13
|
+
[](https://tailwindcss.com)
|
|
14
|
+
[](https://orm.drizzle.team)
|
|
15
|
+
[](CONTRIBUTING.md)
|
|
16
|
+
|
|
17
|
+
hiai-docs is a lightweight **self-hosted knowledge base** built for users who want speed, full data ownership, and strong AI capabilities without heavy enterprise overhead.
|
|
18
|
+
|
|
19
|
+
If you are looking for a **local LLM knowledge base** or a **lightweight Outline alternative** / **Docmost alternative** that runs fully offline with **Ollama self-hosted** embeddings, hiai-docs offers an elegant, **RAG-ready knowledge vault** that automatically generates vector embeddings on every save (via Ollama), supports hybrid semantic search, and provides a clean REST API for AI agent integration.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Table of Contents
|
|
24
|
+
|
|
25
|
+
- [Features](#features)
|
|
26
|
+
- [Screenshots](#screenshots)
|
|
27
|
+
- [Quick Start](#quick-start)
|
|
28
|
+
- [Stack](#stack)
|
|
29
|
+
- [Comparison](#comparison)
|
|
30
|
+
- [Project Structure](#project-structure)
|
|
31
|
+
- [Configuration](#configuration)
|
|
32
|
+
- [API Documentation](#api-documentation)
|
|
33
|
+
- [Contributing](#contributing)
|
|
34
|
+
- [License](#license)
|
|
35
|
+
- [Related Projects](#related-projects)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Rich WYSIWYG editor** — powerful visual editing with TipTap v3 + svelte-tiptap
|
|
42
|
+
- **AI-native** — automatic chunking + vector embeddings (Ollama) on every save
|
|
43
|
+
- **Semantic search** — hybrid full-text + pgvector search
|
|
44
|
+
- **Folder hierarchy** — nested folders to organize your documents
|
|
45
|
+
- **Sharing** — token-protected links with password, expiration, and guest access
|
|
46
|
+
- **Import / Export** — support for Markdown (.md) files
|
|
47
|
+
- **Agent-ready** — clean REST API for AI agents (Mastra compatible and others)
|
|
48
|
+
- **Self-hosted** — full data ownership with minimal resource usage
|
|
49
|
+
|
|
50
|
+
## Screenshots
|
|
51
|
+
|
|
52
|
+
<!--
|
|
53
|
+
TODO: Add screenshots of the dashboard, editor, search, and dark mode.
|
|
54
|
+
Use 1200x675 (16:9) PNGs.
|
|
55
|
+
<img src="docs/screenshots/dashboard.png" width="100%" alt="hiai-docs dashboard with document grid" />
|
|
56
|
+
-->
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
### Docker (Production-style)
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/hiai-gg/hiai-docs.git
|
|
66
|
+
cd hiai-docs
|
|
67
|
+
cp .env.example .env
|
|
68
|
+
# Edit .env with your settings
|
|
69
|
+
|
|
70
|
+
docker compose up -d
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Open http://localhost:50701
|
|
74
|
+
|
|
75
|
+
## Agentic Quickstart (AI-Powered Setup)
|
|
76
|
+
|
|
77
|
+
Don't want to run setup commands manually? Copy-paste this unified prompt into your AI assistant (OpenCode, Claude Code, Cursor, Copilot, etc.) and let it do the work:
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
Set up and launch the hiai-docs project on my local system:
|
|
81
|
+
1. Clone the repository at https://github.com/hiai-gg/hiai-docs (if not already cloned)
|
|
82
|
+
2. Copy .env.example to .env
|
|
83
|
+
3. Generate a secure random auth secret using openssl or a secure generator, and set it as BETTER_AUTH_SECRET in .env
|
|
84
|
+
4. Install all dependencies with "bun install"
|
|
85
|
+
5. Boot up the developer Docker container dependencies (Postgres, Redis, Ollama, MinIO) by running:
|
|
86
|
+
bun run docker:dev
|
|
87
|
+
6. Generate and apply database migrations to setup schemas by running:
|
|
88
|
+
bun run db:push
|
|
89
|
+
7. Spin up the application services (Elysia API and SvelteKit web) in development/watch mode:
|
|
90
|
+
bun run dev
|
|
91
|
+
8. Verify health status by checking:
|
|
92
|
+
- SvelteKit Web UI: http://localhost:50701
|
|
93
|
+
- Elysia API Health: http://localhost:50700/api/health
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Local Development (Recommended for hacking)
|
|
97
|
+
|
|
98
|
+
Two equivalent workflows — pick one. Both give you live-reload at http://localhost:50701.
|
|
99
|
+
|
|
100
|
+
#### Option A — Hybrid (infra in Docker, api+web on host)
|
|
101
|
+
|
|
102
|
+
This is the fastest dev loop. `bun run dev` runs `vite dev` (port 50701) and `bun --watch` for the api in parallel; both auto-reload on file changes.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# 1. Install JS deps once
|
|
106
|
+
bun install
|
|
107
|
+
|
|
108
|
+
# 2. Start infrastructure in Docker
|
|
109
|
+
bun run docker:dev # brings up postgres, redis, ollama, minio
|
|
110
|
+
|
|
111
|
+
# 3. Push DB schema (one-time, or after schema changes)
|
|
112
|
+
bun run db:push
|
|
113
|
+
|
|
114
|
+
# 4. Start api + web on the host, with live reload
|
|
115
|
+
bun run dev
|
|
116
|
+
# vite dev → http://localhost:50701
|
|
117
|
+
# api → http://localhost:50700
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Stop the infra when done: `bun run stop`
|
|
121
|
+
|
|
122
|
+
#### Option B — Full Docker with live-reload bind mounts
|
|
123
|
+
|
|
124
|
+
`docker-compose.dev.yml` mounts the source into the api/web containers, so editing a file on the host is picked up inside the container (vite HMR + bun --watch). Useful when you want everything isolated in Docker.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
bun run docker:dev
|
|
128
|
+
# Open http://localhost:50701
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> The `web` and `api` services in `docker-compose.dev.yml` bind `./:/app`, so any edit on the host is reflected inside the container without rebuilding.
|
|
132
|
+
|
|
133
|
+
### Why is port 50701 special?
|
|
134
|
+
|
|
135
|
+
The frontend dev server is pinned to port 50701 in `frontend/vite.config.ts` with `strictPort: true`. That last flag is important: if 50701 is already taken (e.g. a stale container from a previous run), vite will **fail loudly** instead of silently falling back to 5173 — which would leave you staring at an old build at http://localhost:50701. If you see "port 50701 in use", run `docker compose down` (or `bun run stop`) and retry.
|
|
136
|
+
|
|
137
|
+
### Troubleshooting
|
|
138
|
+
|
|
139
|
+
- **Port 50701 already in use** — `docker compose down` to stop stale containers, then retry `bun run dev` or `bun run docker:dev`.
|
|
140
|
+
- **Changes not showing up** — `bun run dev` already wires HMR. If running via Docker, confirm the bind mount is in `docker-compose.dev.yml` (not the prod `docker-compose.yml`, which builds an immutable image).
|
|
141
|
+
- **`bun install` complains about the lockfile** — ensure `bun.lock` is in sync: `bun install`.
|
|
142
|
+
- **Docker `web` build works without paraglide patches** — As of `@inlang/paraglide-js@2.x`, the `@inlang/sdk@2.x` rewrite no longer emits the `data:` URLs that triggered Bun's `NameTooLong` error. The old `sed` patch on `frontend/Dockerfile` was removed. i18n is now driven by `@inlang/paraglide-js@2.x` directly (the SvelteKit adapter is deprecated) via `paraglideVitePlugin` in `vite.config.ts` and `paraglideMiddleware` in `src/hooks.server.ts`.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Stack
|
|
147
|
+
|
|
148
|
+
| Layer | Technology |
|
|
149
|
+
|-------|-----------|
|
|
150
|
+
| Runtime | [Bun](https://bun.sh) 1.3.14+ |
|
|
151
|
+
| Backend | [Elysia](https://elysiajs.com) 1.4.28+ |
|
|
152
|
+
| ORM | [Drizzle ORM](https://orm.drizzle.team) 0.45.2+ |
|
|
153
|
+
| Database | [PostgreSQL](https://postgresql.org) 18 + [pgvector](https://github.com/pgvector/pgvector) |
|
|
154
|
+
| Cache | [Redis](https://redis.io) 8.6+ |
|
|
155
|
+
| Auth | [Better Auth](https://better-auth.com) |
|
|
156
|
+
| Frontend | [SvelteKit](https://kit.svelte.dev) 2.60+ |
|
|
157
|
+
| UI | [shadcn-svelte](https://shadcn-svelte.com) (new-york style) |
|
|
158
|
+
| Editor | [svelte-tiptap](https://github.com/sibiraj-s/svelte-tiptap) + [TipTap v3](https://tiptap.dev) |
|
|
159
|
+
| Embeddings | [Ollama](https://ollama.ai) (configurable) |
|
|
160
|
+
| Storage | [MinIO](https://min.io) (S3-compatible) |
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Comparison with other self-hosted solutions
|
|
165
|
+
|
|
166
|
+
| Project | Best For | hiai-docs vs them | License / Limitations |
|
|
167
|
+
|--------------------|---------------------------------------|------------------------------------------------|------------------------------------------------|
|
|
168
|
+
| **La Suite Docs** | Government & teams, strong block editor | Much lighter and faster | MIT (fully unrestricted) |
|
|
169
|
+
| **Outline** | Teams with integrations | Lighter + built-in RAG out of the box | BSL 1.1 – free for self-hosting, restrictions on offering as hosted service |
|
|
170
|
+
| **Docmost** | Confluence / Notion replacement | Simpler, faster, lower resource usage | AGPL-3.0 (Community) – fully open, Enterprise features extra |
|
|
171
|
+
| **Wiki.js** | Markdown + Git sync | Better AI & semantic search | AGPL-3.0 |
|
|
172
|
+
| **hiai-docs** | **Lightweight AI-first vault** | — | MIT (fully unrestricted) |
|
|
173
|
+
| **AFFiNE** | Notion + whiteboard experience | Much lighter, far lower overhead | MIT (frontend) + restrictive EE license (backend) – production limits (10 users / 100 GB on free tier) |
|
|
174
|
+
| **Trilium Notes** | Personal knowledge + scripting | Better sharing & semantic search | AGPL-3.0 |
|
|
175
|
+
| **SilverBullet** | Extensible Markdown notes | Better AI integration & sharing | MIT |
|
|
176
|
+
|
|
177
|
+
**hiai-docs** sits in the **lightweight AI-first** niche — ideal when you want built-in embeddings, fast performance, and minimal resource consumption rather than heavy collaboration features or enterprise complexity.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Project Structure
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
hiai-docs/
|
|
185
|
+
├── backend/ # Elysia REST API
|
|
186
|
+
│ ├── src/
|
|
187
|
+
│ │ ├── api/ # Routes + middleware
|
|
188
|
+
│ │ ├── lib/ # Shared utilities
|
|
189
|
+
│ │ ├── embedding/ # Embedding pipeline
|
|
190
|
+
│ │ └── index.ts # Entry point
|
|
191
|
+
│ ├── package.json
|
|
192
|
+
│ └── tsconfig.json
|
|
193
|
+
├── frontend/ # SvelteKit web UI
|
|
194
|
+
│ ├── src/
|
|
195
|
+
│ │ ├── routes/ # Pages
|
|
196
|
+
│ │ ├── lib/ # Components + utils
|
|
197
|
+
│ │ └── app.css # Tailwind + theme
|
|
198
|
+
│ ├── package.json
|
|
199
|
+
│ └── svelte.config.js
|
|
200
|
+
├── packages/db/ # Drizzle schema + migrations
|
|
201
|
+
│ ├── src/
|
|
202
|
+
│ │ ├── schema.ts # Table definitions
|
|
203
|
+
│ │ ├── migrations/ # SQL migrations
|
|
204
|
+
│ │ └── index.ts # DB client
|
|
205
|
+
│ └── package.json
|
|
206
|
+
├── docker-compose.yml # Production Docker setup
|
|
207
|
+
├── .env.example # Environment template
|
|
208
|
+
├── AGENTS.md # Agent instructions
|
|
209
|
+
├── README.md # This file
|
|
210
|
+
├── LICENSE # MIT
|
|
211
|
+
└── todo.md # Development roadmap
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Configuration
|
|
217
|
+
|
|
218
|
+
All configuration via environment variables. Copy `.env.example` to `.env` and configure:
|
|
219
|
+
|
|
220
|
+
| Variable | Default | Description |
|
|
221
|
+
|----------|---------|-------------|
|
|
222
|
+
| `DB_USER` | aiuser | PostgreSQL username |
|
|
223
|
+
| `DB_PASSWORD` | changeme | PostgreSQL password |
|
|
224
|
+
| `BETTER_AUTH_SECRET` | — | Auth secret (generate random) |
|
|
225
|
+
| `BETTER_AUTH_URL` | http://localhost:50700 | Auth base URL |
|
|
226
|
+
| `MINIO_ACCESS_KEY` | minioadmin | MinIO access key |
|
|
227
|
+
| `MINIO_SECRET_KEY` | minioadmin | MinIO secret key |
|
|
228
|
+
| `EMBEDDING_PROVIDER` | ollama | Embedding provider (ollama/openrouter/voyage) |
|
|
229
|
+
| `EMBEDDING_MODEL` | nomic-embed-text | Embedding model name |
|
|
230
|
+
| `OPENROUTER_API_KEY` | — | OpenRouter API key (fallback) |
|
|
231
|
+
|
|
232
|
+
See `.env.example` for full list.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## API Documentation
|
|
237
|
+
|
|
238
|
+
REST API available at `http://localhost:50700/api/`.
|
|
239
|
+
|
|
240
|
+
Key endpoints:
|
|
241
|
+
- `POST /api/documents` — Create document
|
|
242
|
+
- `GET /api/documents/:id` — Get document with tags
|
|
243
|
+
- `GET /api/search?q=query` — Hybrid full-text + semantic search
|
|
244
|
+
- `POST /api/share` — Create share link
|
|
245
|
+
- `GET /api/share/:token` — Access shared content (public)
|
|
246
|
+
- `POST /api/documents/:id/attachments` — Upload image
|
|
247
|
+
- `WS /ws/collab/:documentId` — Real-time collaborative editing
|
|
248
|
+
|
|
249
|
+
Full API documentation available in [docs/API.md](docs/API.md).
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Contributing
|
|
254
|
+
|
|
255
|
+
1. Fork the repository
|
|
256
|
+
2. Create a feature branch (`git checkout -b feature/amazing`)
|
|
257
|
+
3. Commit changes (`git commit -m 'feat: add amazing feature'`)
|
|
258
|
+
4. Push to branch (`git push origin feature/amazing`)
|
|
259
|
+
5. Open a Pull Request
|
|
260
|
+
|
|
261
|
+
### Development Rules
|
|
262
|
+
|
|
263
|
+
- **Bun only** — no npm/yarn
|
|
264
|
+
- **ESM only** — no CommonJS
|
|
265
|
+
- **TypeScript strict** — no `any`
|
|
266
|
+
- **English only** — code, comments, docs, commits
|
|
267
|
+
- **No Playwright** — use agent-browser for E2E
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
[MIT](LICENSE)
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Related Projects
|
|
278
|
+
|
|
279
|
+
Part of the [HiAi](https://hiai.gg) open-source ecosystem:
|
|
280
|
+
|
|
281
|
+
| Project | Description |
|
|
282
|
+
|---------|-------------|
|
|
283
|
+
| [hiai-opencode](https://github.com/hiai-gg/hiai-opencode) | AI coding agent |
|
|
284
|
+
| [hiai-observe](https://github.com/hiai-gg/hiai-observe) | Observability platform |
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Release Checklist - hiai-docs
|
|
2
|
+
|
|
3
|
+
> Use this checklist for every release. Tick items as they are completed.
|
|
4
|
+
|
|
5
|
+
## Pre-Release
|
|
6
|
+
|
|
7
|
+
- [ ] **Bump version** — Update version in `package.json`, `backend/package.json`, `frontend/package.json`, `packages/db/package.json`
|
|
8
|
+
- [ ] **Regenerate secrets** — Generate fresh values for `BETTER_AUTH_SECRET`, `CSRF_SECRET`, `WEBHOOK_SECRET`, `HIAI_DOCS_API_KEY`:
|
|
9
|
+
```bash
|
|
10
|
+
openssl rand -hex 32 # repeat for each secret
|
|
11
|
+
```
|
|
12
|
+
- [ ] **Update `.env.example`** if any new env vars were added
|
|
13
|
+
- [ ] **Run full typecheck** — `bun run typecheck` (0 errors)
|
|
14
|
+
- [ ] **Run full test suite** — `bun test` (all passing)
|
|
15
|
+
- [ ] **Run lint** — `bun run lint` in backend (0 errors)
|
|
16
|
+
|
|
17
|
+
## Build
|
|
18
|
+
|
|
19
|
+
- [ ] **Build Docker images** — `docker compose build` (both `api` and `web`)
|
|
20
|
+
- [ ] **Verify Docker health** — `docker compose up -d && curl -fsS http://localhost:50700/api/health`
|
|
21
|
+
- [ ] **Run DB migrations** — `docker compose exec api bun run db:migrate`
|
|
22
|
+
|
|
23
|
+
## Release
|
|
24
|
+
|
|
25
|
+
- [ ] **Commit and tag** — `git tag -a v<version> -m "v<version>"`
|
|
26
|
+
- [ ] **Push** — `git push origin dev --tags`
|
|
27
|
+
- [ ] **Create GitHub release** — Use the tag, include changelog summary
|
|
28
|
+
- [ ] **Verify CI** — Confirm CI pipeline passes on GitHub Actions
|
|
29
|
+
|
|
30
|
+
## Post-Release
|
|
31
|
+
|
|
32
|
+
- [ ] **Deploy to staging** — Pull latest on staging host
|
|
33
|
+
- [ ] **Smoke test** — Sign up, create doc, search, share, verify
|
|
34
|
+
- [ ] **Deploy to production** — Pull latest on production host
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | ------------------ |
|
|
7
|
+
| 0.1.x | :white_check_mark: |
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
If you discover a security vulnerability in hiai-docs, please report it responsibly.
|
|
12
|
+
|
|
13
|
+
**Do NOT open a public GitHub issue for security vulnerabilities.**
|
|
14
|
+
|
|
15
|
+
Instead, please email: **hiai@webs.cool**
|
|
16
|
+
|
|
17
|
+
### What to include
|
|
18
|
+
|
|
19
|
+
- Description of the vulnerability
|
|
20
|
+
- Steps to reproduce
|
|
21
|
+
- Potential impact
|
|
22
|
+
- Suggested fix (if any)
|
|
23
|
+
|
|
24
|
+
### Response timeline
|
|
25
|
+
|
|
26
|
+
- **Acknowledgment**: within 48 hours
|
|
27
|
+
- **Initial assessment**: within 5 business days
|
|
28
|
+
- **Fix or mitigation**: within 30 days for critical/high severity
|
|
29
|
+
|
|
30
|
+
### Scope
|
|
31
|
+
|
|
32
|
+
In-scope vulnerabilities include:
|
|
33
|
+
|
|
34
|
+
- Authentication/authorization bypass
|
|
35
|
+
- SQL injection or data leakage between users
|
|
36
|
+
- Cross-site scripting (XSS) in rendered content
|
|
37
|
+
- Remote code execution
|
|
38
|
+
- Path traversal or file upload abuse
|
|
39
|
+
- Rate limiting bypass on public endpoints
|
|
40
|
+
- Exposure of secrets or credentials
|
|
41
|
+
|
|
42
|
+
### Out of scope
|
|
43
|
+
|
|
44
|
+
- Social engineering attacks
|
|
45
|
+
- Denial of service (DoS)
|
|
46
|
+
- Issues in third-party dependencies (report upstream)
|
|
47
|
+
- Issues requiring physical access to the server
|
|
48
|
+
|
|
49
|
+
## Security Architecture
|
|
50
|
+
|
|
51
|
+
- **Data isolation**: All queries filter by `owner_id` — no cross-user data access
|
|
52
|
+
- **Auth**: Better Auth with session cookies (7-day expiry) + optional API key (Bearer token)
|
|
53
|
+
- **CSRF**: HMAC-signed double-submit cookie pattern on all unsafe methods
|
|
54
|
+
- **Rate limiting**: Redis-based sliding window rate limiters on all public endpoints (search, documents, sharing, health)
|
|
55
|
+
- **Sharing**: Token-based links with optional password + expiration
|
|
56
|
+
- **Validation**: Zod schemas on all API inputs
|
|
57
|
+
- **Secrets**: All configuration via environment variables, zero hardcoded secrets
|
|
58
|
+
- **Encryption**: Passwords hashed with Bun.password (bcrypt)
|
|
59
|
+
- **CSP**: Content Security Policy headers on all pages
|
|
60
|
+
- **Webhook verification**: HMAC-SHA256 signature verification for MinIO webhooks
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hiai-docs/backend",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "bun run --watch src/index.ts",
|
|
9
|
+
"build": "bun build src/index.ts --outdir dist --target bun",
|
|
10
|
+
"start": "bun run dist/index.js",
|
|
11
|
+
"lint": "biome check src/",
|
|
12
|
+
"lint:fix": "biome check --fix src/",
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"test": "bun test --path-ignore-patterns='*node_modules*' src/ tests/"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@elysiajs/cors": "^1.4.2",
|
|
18
|
+
"@elysiajs/swagger": "^1.3.1",
|
|
19
|
+
"@hiai-docs/db": "workspace:*",
|
|
20
|
+
"@tiptap/core": "^3.26.1",
|
|
21
|
+
"@tiptap/extension-highlight": "^3.26.1",
|
|
22
|
+
"@tiptap/extension-image": "^3.26.1",
|
|
23
|
+
"@tiptap/extension-link": "^3.26.1",
|
|
24
|
+
"@tiptap/html": "^3.26.1",
|
|
25
|
+
"@tiptap/starter-kit": "^3.26.1",
|
|
26
|
+
"better-auth": "^1.6.18",
|
|
27
|
+
"drizzle-orm": "^0.45.2",
|
|
28
|
+
"elysia": "^1.4.28",
|
|
29
|
+
"ioredis": "^5.11.1",
|
|
30
|
+
"marked": "^18.0.5",
|
|
31
|
+
"minio": "^8.0.7",
|
|
32
|
+
"nanoid": "^5.1.11",
|
|
33
|
+
"pino": "^10.3.1",
|
|
34
|
+
"postgres": "^3.4.9",
|
|
35
|
+
"yjs": "^13.6.31",
|
|
36
|
+
"zod": "^4.4.3"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@biomejs/biome": "^2.4.15",
|
|
40
|
+
"@types/bun": "^1.3.14",
|
|
41
|
+
"typescript": "^5.8.0"
|
|
42
|
+
}
|
|
43
|
+
}
|