How ahmedrabea0302/go-rag-based-chat-app works
This Go application ingests Markdown and text files into a pgvector-backed retrieval index, then uses retrieved context to support LLM chat through a terminal REPL. The runtime also exposes a web route that renders a chat page; the sampled server code does not show a web chat submission or response workflow. The graph separates ingestion, retrieval, chat, and storage. Some capabilities are represented only by their exact paths because their implementation was not sampled.
Main entry points: app.go Application runtime · retriever.go Retriever · ingest.go Content ingestion · repl.go Terminal chat
Components 20
Runtime and configuration
- CLI entry
cmd/rag/main.go - Configuration
config/config.go - Application runtime
app/app.go
Document ingestion
- Source documents
- Directory watcher
ingest/watcher.go - Content ingestion
ingest/ingest.go - Text chunker
ingest/chunk.go
Retrieval and prompts
- Embedding client
llm/embed.go - Retriever
rag/retriever.go - Query rewriter
rag/rewriter.go - Prompt formatting
rag/prompt.go
Chat interfaces
- Terminal chat
chat/repl.go - Web server
web/server.go - Chat page template
web/templates/chat.gohtml - Chat client
llm/client.go
Vector storage
- Vector store contract
vector/store.go - Pgvector adapter
vector/pgvector/pgvector.go
Other components
- User
- LLM service
- PostgreSQL
Connections 27
- User → CLI entry: starts
cmd/rag/main.go - CLI entry → Configuration: loads
cmd/rag/main.go - CLI entry → Application runtime: runs
cmd/rag/main.go - Application runtime → Configuration: uses settings
app/app.go - Application runtime → Embedding client: creates
app/app.go - Application runtime → Chat client: creates
app/app.go - Application runtime → Pgvector adapter: opens store
app/app.go - Application runtime → Directory watcher: starts
app/app.go - Application runtime → Retriever: creates
app/app.go - Application runtime → Query rewriter: creates
app/app.go - Application runtime → Terminal chat: starts
app/app.go - Application runtime → Web server: starts
app/app.go - User → Terminal chat: enters prompts
chat/repl.go - User → Web server: opens chat page
web/server.go - Directory watcher → Source documents: watches
ingest/watcher.go - Directory watcher → Content ingestion: processes files
ingest/watcher.go - Content ingestion → Text chunker: chunks text
ingest/ingest.go - Content ingestion → Embedding client: embeds chunks
ingest/ingest.go - Content ingestion → Vector store contract: deletes and upserts
ingest/ingest.go - Terminal chat → Retriever: retrieves context
chat/repl.go - Terminal chat → Chat client: requests reply
chat/repl.go - Retriever → Query rewriter: rewrites query
rag/retriever.go - Retriever → Embedding client: embeds query
rag/retriever.go - Retriever → Vector store contract: queries vectors
rag/retriever.go - Web server → Chat page template: renders page
web/server.go - Chat client → LLM service: streams completion
llm/client.go - Pgvector adapter → PostgreSQL: queries and writes
vector/pgvector/pgvector.go