What it is

KB/ is a standalone Bun + React subproject inside the DBPOC monorepo: an AI-powered legal knowledgebase for Swedish B2B data enrichment compliance (GDPR, Dataskyddslagen, IMY decisions, B2B practice).

Source root: ./KB/. Self-contained — its own package.json, tsconfig.json, tailwind.config.js. Not imported by the main DBPOC pipeline.

Why it exists

Reference reading and Q&A surface for compliance questions that arise while building the enrichment pipeline. Articles are hand-authored TypeScript modules covering legitimate interest, Article 14 notification, RoPA, IMY enforcement, etc. Chat panel lets the user ask Claude follow-up questions, with optional Serper-backed web search for current sources.

Stack

  • Bun runtime (bun --hot server.ts for dev). See KB/package.json:6–9.
  • Single-file backend: KB/server.ts (~350 lines). Uses Bun.serve().
  • Frontend: React 18 + Tailwind 3, no Vite. HTML imports via KB/public/index.html.
  • Anthropic SDK @anthropic-ai/sdk@^0.36.0 for chat (server-side, agentic loop).
  • Fuse.js ^7.0.0 for client-side fuzzy search (KB/src/hooks/useSearch.ts).
  • No database. No persistence beyond localStorage for API keys + theme.

Run

cd KB
bun install
bun run dev    # serves on http://localhost:3001 (KB_PORT env var)

Default port 3001 from KB/server.ts:5. No .env required to load the UI; API keys are entered via the in-app Settings modal (stored in localStorage).

Routes

  • GET / and any other path → static SPA (KB/server.ts:330–342)
  • POST /api/chat → SSE stream from Claude with optional search_web tool (KB/server.ts:100–237)
  • POST /api/search-web → Serper.dev passthrough (KB/server.ts:239–262)
  • GET /api/health{ ok: true, version: "1.0.0" }

Components

See KB Architecture for the call graph and KB Content Index for the article registry.

Gotchas

  • Bun serves .tsx directly via the static handler (KB/server.ts:282–283) by remapping the MIME to application/javascript. Bun’s bundler handles transpilation when the browser fetches /src/frontend.tsx.
  • API keys live in localStorage only — no server-side secret. Each request carries X-Anthropic-Key and X-Serper-Key headers.
  • KB/ is not part of the main pipeline. It does not read from PostgreSQL and does not enrich anything.

See also

KB Architecture, KB Content Index, KB Chat Flow, KB Settings, KB Legal Disclaimer.

See also