Knowledge Base Overview
Purpose
The EnrichNode Knowledge Base (KB) is an AI-powered legal knowledgebase for Swedish B2B data enrichment compliance. It serves as an interactive reference for GDPR, Swedish data protection law, and B2B enrichment compliance — designed for both human readers and AI-assisted Q&A via Claude.
The KB is a self-contained React SPA with a built-in AI chat assistant, credibility-scored citations, and a searchable article library covering 29+ legal articles across five categories.
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Browser (React SPA) │
│ ┌──────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ Sidebar │ │ Article │ │ Chat Panel (Claude) │ │
│ │ (search) │ │ Viewer │ │ (SSE streaming) │ │
│ └──────────┘ └──────────────┘ └──────────────────────┘ │
└──────────────────────┬──────────────────────────────────────┘
│ HTTP / SSE
┌──────────────────────┴──────────────────────────────────────┐
│ Bun Server (server.ts) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ │
│ │ /api/chat │ │ /api/search │ │ /api/health │ │
│ │ (POST, SSE) │ │ -web (POST) │ │ (GET) │ │
│ └──────────────┘ └──────────────┘ └──────────────────┘ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Static file server (SPA fallback → public/index.html)│ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Data Flow
- Articles are TypeScript modules (
KB/src/kb/**/*.ts) exporting structuredKBArticleobjects with sections, citations, and legal references. - Frontend renders articles via
ArticleViewerwith a stickyTableOfContents,SourceBadgecredibility indicators, and inline legal reference tags. - Search uses Fuse.js for fuzzy full-text search across titles, summaries, and tags.
- Chat sends messages to
/api/chatas SSE; the server runs an agentic loop with Claude (Anthropic API) and optional web search via Serper.dev. - Web search results are credibility-scored via
scoreUrl()before being returned to the client.
Tech Stack
| Layer | Technology | Version |
|---|---|---|
| Runtime | Bun | >= 1.1.0 |
| Frontend | React | 18.3.1 |
| Bundling | Bun built-in (dev) / static serve (prod) | — |
| Styling | Tailwind CSS | 3.4.0 |
| Typography | @tailwindcss/typography | 0.5.15 |
| Search | Fuse.js | 7.0.0 |
| AI Backend | Anthropic SDK | 0.36.0 |
| Language | TypeScript | 5.6.0 |
Tailwind Custom Theme
The config extends Tailwind with:
- Credibility colors:
authoritative,official,practitioner,uncertain— each with DEFAULT, light, and dark variants. - Legal font family:
font-legal(Georgia, Times New Roman, serif). - Dark mode:
classstrategy (toggled viadarkclass on<html>).
Build Process
# Development (hot reload)
bun --hot server.ts
# Production
bun server.ts
# Type checking
bun run typecheck # tsc --noEmit
# Formatting
bun run format # prettier --write 'src/**/*.{ts,tsx}'The server (server.ts) is both the API backend and the static file server. It serves public/index.html as the SPA entry point, with Bun automatically resolving .tsx imports at runtime. No separate build step is required for deployment — Bun serves TypeScript directly.
Environment Variables
| Variable | Default | Description |
|---|---|---|
KB_PORT | 3001 | Server listen port |
Client-side API keys (Anthropic, Serper) are stored in localStorage and sent via request headers — they never touch the server filesystem.
Article Organization
Articles are organized into five categories, each with a distinct color scheme and icon:
| Category | Label | Icon | Description |
|---|---|---|---|
gdpr | GDPR Core | 🔒 | EU General Data Protection Regulation articles and interpretations |
swedish-law | Swedish Law | 🇸🇪 | Swedish-specific legislation and national data protection rules |
b2b-enrichment | B2B Enrichment Practice | 📊 | Practical compliance guides for data enrichment activities |
enforcement | Enforcement Cases | ⚖️ | Real enforcement decisions and regulatory precedents |
templates | Templates | 📝 | Ready-to-use legal documents and compliance templates |
Each article has:
- Applicability scope:
sweden,eu, orglobal(shown as emoji flags) - Tags: searchable keywords
- Summary: 2-3 sentence overview
- Content sections: hierarchical headings (levels 2–4) with markdown-like text
- Legal references: inline tags like
[GDPR Art. 6(1)(f)]rendered as styled badges - Citations: externally linked sources with credibility tiers (
authoritative,official,practitioner,uncertain) - Last updated: ISO date for freshness tracking
Article Index
See Article Index for the complete catalog of all KB articles.
Key Features
- AI Q&A with Claude: Natural language compliance questions with article-aware context
- Web research: Optional Serper.dev integration for current legal information
- Credibility scoring: All citations and web search results are scored by domain authority
- Dark mode: Full dark theme support with
class-based Tailwind strategy - Responsive search: Fuse.js-powered fuzzy search with keyboard-navigable results
- Accessibility: ARIA labels, focus-visible outlines, semantic HTML throughout
- Legal disclaimer: Dismissible banner reminding users that content is informational only
Source Location
- Repository:
./KB/ - Entry point:
server.ts(backend),src/frontend.tsx(frontend) - Articles:
src/kb/**/*.ts - Components:
src/components/*.tsx - Hooks:
src/hooks/*.ts - Types:
src/lib/types.ts - Credibility scoring:
src/lib/credibility.ts