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

  1. Articles are TypeScript modules (KB/src/kb/**/*.ts) exporting structured KBArticle objects with sections, citations, and legal references.
  2. Frontend renders articles via ArticleViewer with a sticky TableOfContents, SourceBadge credibility indicators, and inline legal reference tags.
  3. Search uses Fuse.js for fuzzy full-text search across titles, summaries, and tags.
  4. Chat sends messages to /api/chat as SSE; the server runs an agentic loop with Claude (Anthropic API) and optional web search via Serper.dev.
  5. Web search results are credibility-scored via scoreUrl() before being returned to the client.

Tech Stack

LayerTechnologyVersion
RuntimeBun>= 1.1.0
FrontendReact18.3.1
BundlingBun built-in (dev) / static serve (prod)
StylingTailwind CSS3.4.0
Typography@tailwindcss/typography0.5.15
SearchFuse.js7.0.0
AI BackendAnthropic SDK0.36.0
LanguageTypeScript5.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: class strategy (toggled via dark class 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

VariableDefaultDescription
KB_PORT3001Server 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:

CategoryLabelIconDescription
gdprGDPR Core🔒EU General Data Protection Regulation articles and interpretations
swedish-lawSwedish Law🇸🇪Swedish-specific legislation and national data protection rules
b2b-enrichmentB2B Enrichment Practice📊Practical compliance guides for data enrichment activities
enforcementEnforcement Cases⚖️Real enforcement decisions and regulatory precedents
templatesTemplates📝Ready-to-use legal documents and compliance templates

Each article has:

  • Applicability scope: sweden, eu, or global (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

See also