$ show ItzCrazyKns/Vane
Vane is a privacy-focused, self-hosted AI answering engine that combines web search with large language models (LLMs) to produce cited, real-time answers. The system is built as a Next.js 16 application with a React frontend and a set of API routes that orchestrate a multi-step research pipeline: classification of user queries, parallel execution of search actions (web, academic, social, scrape, upload-based retrieval), widget generation (weather, stock, calculation), and final answer synthesis via an LLM. It supports multiple LLM providers (OpenAI, Anthropic, Gemini, Groq, Ollama, LM Studio, etc.) through a clean provider abstraction, and stores chat history in a local SQLite database managed by Drizzle ORM. The architecture is a monolith with clear separation of concerns: a model registry for LLM/embedding providers, a search agent with an action registry pattern, a widget system for structured data display, and a configuration manager that persists user settings to a JSON file. The frontend uses client-side streaming via EventSource to display research progress and final answers in real-time. Deployment is Docker-first, bundling a SearXNG instance for privacy-respecting web search, with multi-arch images and a slim variant. Key entry points include the main chat page (`/`), individual chat pages (`/c/[chatId]`), a news discovery page (`/discover`), and a library for uploaded documents. The primary API endpoints are `POST /api/chat` (streaming chat), `POST /api/search` (non-streaming search), and various CRUD routes for providers, config, and uploads. External dependencies include SearXNG (self-hosted), Open-Meteo (weather), Yahoo Finance (stocks), and the LLM provider APIs. The codebase demonstrates strong engineering practices with well-defined abstractions, a modular agent architecture, and a focus on privacy and local-first operation. It is actively maintained with a large community, though some areas (custom migration runner, large chat hook) show room for refinement.
The LLM identified 4 files worth highlighting for reuse:
Defines the base classes for LLM and embedding providers (BaseModelProvider, BaseLLM, BaseEmbedding). This abstraction allows adding new LLM backends by implementing a small interface, making the system extensible and testable. The pattern is cleanly separated from business logic and could be extracted to build a multi-provider LLM client library.
Implements an action registry for research tools (web search, academic search, scrape, etc.). Each action is a self-contained module with a name, schema, execute function, and enabled flag. The registry dynamically loads and runs actions in parallel, emitting progress events. This pattern enables easy addition of new research capabilities without modifying the core agent loop.
Provides a widget executor that runs multiple widget handlers (weather, stock, calculation) in parallel alongside research actions. Each widget implements a typed interface with shouldExecute, execute, and schema. The executor collects results and returns them as structured data for UI rendering. This pattern is reusable for any application needing parallel, schema-driven data fetching.
A server-side configuration manager that loads settings from a JSON file and environment variables, with client/server scoping. It manages model provider configurations, UI preferences, and search settings. The design separates sensitive server-only config from client-safe config, and provides a clean API for reading/writing settings. This pattern is applicable to any self-hosted application needing persistent user configuration.