This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
customer-support-rag is a production-ready RAG (Retrieval-Augmented Generation) system that serves API endpoints for a frontend to answer customer queries. It uses a knowledge base of FAQs, product docs, and help center articles as context, with Claude as the LLM and a pure Go TF-IDF engine for embeddings with an in-memory vector store for semantic search.
- Repository: https://github.com/gyaan/knowledge-pipeline.git
- License: MIT
- Language: Go 1.25.6 (macOS ARM64)
- External dependencies: None (pure standard library)
go build ./... # build all packages
go test ./... # run all tests
go test -run TestName ./path/to/package # run a single test
go vet ./... # static analysis
# Dry-run ingestion (loads KB, chunks, builds TF-IDF, prints stats)
go run cmd/ingest/main.go
# Run the API server (ingests KB on startup, serves on :8080)
go run cmd/server/main.goStartup: Load docs → Split → Build TF-IDF vocab → Embed chunks → Store in vector DB
Request: POST /api/chat → Embed query → Vector search → Build context → Claude LLM → Response
- cmd/ingest/ — Dry-run CLI: loads knowledge base, chunks, builds TF-IDF vocab, prints stats (no server)
- cmd/server/ — Ingests KB at startup, then serves HTTP API with graceful shutdown (SIGINT/SIGTERM)
- config/ — Loads .env: API key, server port, KB path, chunk settings, model, session TTL
- documents/ —
loader.goreads .txt files with category/filename metadata, skips empty;splitter.gochunks with overlap - embeddings/ —
client.godefinesEmbedderinterface;server.goimplements pure Go TF-IDF engine - vectordb/ —
memory.goin-memory store (no disk persistence);search.gocosine similarity - llm/ —
client.godefinesLLMClientinterface;claude.goAnthropic client;openai.goOpenAI client - rag/ —
chain.goorchestrates: query → embed → vector search → build prompt → call LLM → return - session/ —
manager.gomanages conversation history with configurable TTL, crypto/rand IDs, stoppable cleanup - api/ —
server.goHTTP router with graceful shutdown;handlers.godefines ChatHandler + HealthHandler
- pkg/models/ —
types.godefines shared structs (Document, ChatRequest/Response, Session, Claude/OpenAI API types)
POST /api/chat—{"query": "...", "session_id": "..."}→{"session_id": "...", "answer": "...", "sources": [...]}GET /api/health—{"status": "healthy", "active_sessions": N, "documents": N}
- faq/ — general, billing, technical, account FAQs
- product_docs/ — getting started, features, API docs, integrations
- help_center/ — troubleshooting, best practices, tutorials
ANTHROPIC_API_KEY= # Claude API key (required when LLM_PROVIDER=anthropic)
SERVER_PORT=8080 # HTTP server port
KNOWLEDGE_BASE_PATH=./knowledge_base
CHUNK_SIZE=500
CHUNK_OVERLAP=50
TOP_K=5
CLAUDE_MODEL=claude-sonnet-4-5-20250929
SESSION_TTL_HOURS=24
LLM_PROVIDER=anthropic # anthropic or openai
OPENAI_API_KEY= # OpenAI API key (required when LLM_PROVIDER=openai)
OPENAI_MODEL=gpt-4o # OpenAI model name
- Zero external dependencies — pure
net/http+ standard library only - In-memory vector store (no external DB, no disk persistence)
- Pure Go TF-IDF embeddings (no Python, no external embedding service)
- Standard Go project layout:
cmd/,internal/,pkg/ - Configuration via
.envfile (gitignored) - Graceful shutdown with signal handling