$ show khoj-ai/khoj
Khoj is an open-source personal AI assistant functioning as a 'second brain' for interacting with personal knowledge bases. It provides a chat interface allowing users to converse with various AI models about documents, notes, and connected data sources (local files, GitHub, Notion). The system supports multimodal capabilities including image generation, code execution, voice input/output, and computer operation through a modular agent architecture. Khoj features a Python/Django backend with FastAPI for API endpoints, a PostgreSQL database with pgvector for vector storage and search, and multiple frontends including a web application (React/Next.js), desktop client (Electron), mobile app (Android), and plugins for Obsidian and Emacs. The architecture emphasizes separation of concerns with distinct modules for file processing, embedding generation, conversation handling, tool integration, and user management.
The LLM identified 4 files worth highlighting for reuse:
Defines a base class for converting various document types (PDF, markdown, images, etc.) into a standardized Entry object format. Demonstrates the template method pattern where subclasses implement file-type specific extraction logic while sharing common processing steps. This component is highly reusable as it isolates document processing concerns and provides a consistent interface for downstream indexing and search.
Abstracts embedding generation across multiple backends (local sentence transformers, OpenAI, etc.) and includes cross-encoder reranking for improved search relevance. Shows the strategy pattern by allowing different embedding models to be swapped via configuration, and encapsulates the reranking logic. This component is reusable in any semantic search or RAG pipeline requiring flexible embedding generation.
Part of a reusable UI component library built with Radix UI primitives and styled with Tailwind CSS. This button component (and others in the directory) demonstrates composable, accessible UI primitives that are isolated from business logic. The library follows best practices for UI component design and can be extracted and used in other React/Tailwind applications.
Provides a unified interface for multiple web search engines (Google, Serper, Exa, Firecrawl, SearXNG) and includes webpage reading and content extraction. Implements the facade pattern by abstracting the differences between search APIs and normalizing results. Includes deduplication and error handling. This component is reusable as a standalone tool for web search in agent-based applications or any system requiring automated web search capabilities.