How pgedge/pgedge-rag-server works
pgEdge RAG Server exposes a multi-pipeline HTTP API that retrieves PostgreSQL content and uses configurable language-model providers to generate answers, with optional streaming. Requests pass through identity checks before the selected pipeline performs hybrid vector/BM25 retrieval, optional reranking, context budgeting, and generation. Configuration, health, stats, and hot reload support the service lifecycle. The sampled source confirms the main request path and key components; some documented provider and API details are represented at subsystem level where implementation excerpts were not available.
Main entry points: orchestrator.go RAG orchestrator · manager.go Pipeline manager · main.go Server startup · handlers.go Request handlers
Components 17
Service runtime
- Server startup
cmd/pgedge-rag-server/main.go - HTTP server
internal/server/server.go - API routes
internal/server/routes.go - Request handlers
internal/server/handlers.go
RAG query path
- Pipeline manager
internal/pipeline/manager.go - RAG orchestrator
internal/pipeline/orchestrator.go - BM25 index
internal/bm25/index.go - Prompt context
internal/llm/rag.go
Corpus access
- Database pool
internal/database/pool.go - Corpus search
internal/database/search.go
External systems
- PostgreSQL + pgvector
- Provider factory
internal/llm/factory.go - Embedding and LLM providers
Configuration and identity
- Config loader
internal/config/loader.go - Config watcher
internal/watch/watcher.go - Caller identity
internal/identity/identity.go
Other components
- API client
Connections 23
- API client → HTTP server: sends requests
- Server startup → Config loader: loads config
- Server startup → Pipeline manager: creates pipelines
- Server startup → HTTP server: starts server
- Server startup → Config watcher: watches config
- Config watcher → Config loader: triggers reload
- HTTP server → API routes: registers routes
- API routes → Request handlers: dispatches requests
- Request handlers → Caller identity: extracts identity
- Request handlers → Pipeline manager: selects pipeline
- Request handlers → RAG orchestrator: executes query
- Pipeline manager → Database pool: creates pools
- Pipeline manager → Provider factory: creates clients
- Pipeline manager → RAG orchestrator: configures pipeline
- RAG orchestrator → Corpus search: searches corpus
- RAG orchestrator → Corpus search: fetches BM25 docs
- Corpus search → Database pool: uses pool
- Database pool → PostgreSQL + pgvector: queries
- RAG orchestrator → BM25 index: ranks text
- RAG orchestrator → Prompt context: formats context
- RAG orchestrator → Embedding and LLM providers: embeds and generates
- Provider factory → Embedding and LLM providers: constructs clients
- RAG orchestrator → Embedding and LLM providers: reranks optionally