How devflowinc/trieve works
Main components
• Frontend Clients: There are several user interfaces (e.g., the “chat”, “dashboard”, “search” apps under the frontends folder, along with shared UI utilities). These components are implemented mostly in JavaScript/Typescript (React, Vite, Tailwind, etc.).
• Backend API Server: The “server” directory (Rust-based) is the core API service. It handles routes such as authentication, data ingestion, analytics, search, messaging, file handling, and more.
• Worker Services: Several binaries exist inside the server (and the “batch-etl” folder) such as ingestion-worker, file-worker, delete-worker, crawl-worker, reindex-worker, etc. These execute asynchronous and background tasks and are deployed in separate Docker containers.
• Data Storage & Databases: There are migration files and configuration for Postgres (and Diesel migrations), ClickHouse (for analytics and fast querying), and other databases. The presence of Qdrant in charts and integration instructions signals a dedicated vector database used in the dense vector (embedding) search flow.
• External Integrations: The system integrates with external services such as OpenAI (LLM API keys), embedding providers, Stripe (for subscription management), and Keycloak for authentication, as well as using third-party embeddings and reranking models.
• Additional Services: The project includes specialized components like “pdf2md” (a service for PDF-to-markdown conversion) and “hallucination-detection” (another Rust project for quality control). There are also multiple client SDKs (python, typescript) and search components.
• Infrastructure & Deployment: The presence of Dockerfiles, docker-compose configurations, Helm charts (in the “charts” directory), Terraform scripts, and various CI/CD configurations (under .github/workflows) indicate that the deployment architecture is containerized and orchestrated (potentially via Kubernetes or docker-compose).
Relationships and data flows
• Users interact with the Frontend UI and dashboards, which in turn make API calls (e.g., via REST) to the Backend API Server.
• The API server handles incoming requests, interacts with databases (Postgres for transactional data, ClickHouse for analytics, Qdrant for vector search), and communicates with worker services by enqueuing tasks (or through service calls).
• Worker processes (ingestion, file, crawl, delete, etc.) perform background jobs and update the databases.
• For search and recommendation queries, the server may first retrieve candidate chunks from full-text or vector search (leveraging systems like Qdrant or Redis caches) and then trigger cross-encoder re-ranking.
• External services (LLM APIs, embedding model services, Stripe for payments) are called either synchronously (on-demand via API routes) or asynchronously via worker processes.
• The infrastructure is deployed using container orchestration and Helm charts (with separate configurations for cloud providers like AWS, GCP, and on-prem solutions) as indicated by the “charts” and “terraform” directories.
Architectural patterns and design principles
• Microservices Architecture: Although all the code lives in one monorepo, there is a clear separation between the API server, various worker processes, and the client frontends. Each service has its own Dockerfile and deployment configuration.
• Layered Structure: The system is organized into presentation (frontends), business logic/API (server), background processing (workers), and data storage layers.
• Extensibility & Plug-In Points: The configuration for user-provided models (for embeddings, re-ranking, etc.), the integration with third-party services (like OpenAI, Stripe, Keycloak), and SDK clients for multiple languages show a focus on modularity and extensibility.
• Infrastructure-as-Code: The presence of various Helm charts, Terraform configuration files, and Docker Compose manifests emphasizes reproducible and self-contained deployments.
• Self-hosting Design: Clear instructions in the README and multiple “.env” files for different services illustrate that self-hosting and deployment in a VPC or on-premise environment is central to the project’s design.