How hasnainraza2004/venturedive-rag-assessment works
1. This repository is a two-tier RAG application centered on a single Wikipedia article at a time. The backend owns ingestion, retrieval, and generation; the frontend is a thin React UI for submitting a URL, viewing the article summary, and chatting against the ingested content.
2. The runtime boundary is split into:
- Frontend: React + Vite, served in production through nginx on port 3000.
- Backend: Node.js + Express on port 4000.
- External local AI services: Ollama on 11434 and ChromaDB on 8000.
Docker Compose wires these together and sets the service URLs used by the backend.
3. The backend API is organized around three routes:
- POST /api/ingest starts the article pipeline.
- POST /api/chat answers questions using retrieval-augmented generation.
- GET /api/health provides basic service health.
These are the main architecture entry points for the diagram.
4. Ingestion is a staged pipeline implemented in ingestService:
1) validate the provided Wikipedia URL,
2) scrape and parse the article content in-process with Cheerio,
3) summarize the article through Ollama,
4) normalize and chunk the text,
5) embed chunks through Ollama,
6) upsert vectors into ChromaDB.
This creates the searchable corpus for later chat requests.
5. Chat is a separate query-time pipeline implemented in ragService:
1) embed the user query,
2) retrieve top-k similar chunks from Chroma with a minimum score filter,
3) build a RAG prompt using the retrieved context,
4) call Ollama to generate the final answer.
The architecture depends on retrieval quality from Chroma and generation quality from the local model.
6. ChromaDB is used as the vector store and is treated as the persistence layer for retrieved article chunks. The README notes a per-article collection model and cosine similarity retrieval, which means the backend effectively isolates content by article rather than maintaining a shared global corpus.
7. Ollama is the unified model runtime for both summarization/chat completion and embeddings. The repository uses local models only: llama3.2:3b for summarize/chat and nomic-embed-text for embeddings. This is an important architectural constraint because the system does not depend on hosted LLM APIs.
8. The backend keeps a small in-memory articleState object. The README indicates one URL per process, so the app is intentionally stateful only within the running backend instance. That makes the diagram simpler: the source of truth for the currently ingested article is ephemeral process memory, while the searchable chunks live in Chroma.
9. The backend is layered into clearly separated concerns:
- routes for HTTP surface area,
- services for business workflows,
- clients for external service adapters,
- scraper for article extraction,
- text for normalization and chunking,
- prompts for LLM prompt templates,
- middleware for logging and error handling.
This separation is useful for diagramming because the HTTP layer is not directly coupled to Chroma or Ollama; it goes through service and client boundaries.
10. The frontend’s role is presentation and API orchestration. Components like UrlForm, SummaryPanel, and ChatBox map naturally to the ingest-and-chat workflow: submit a Wikipedia URL, show the generated summary, then issue chat queries against the backend. src/api/client.js is the only obvious frontend boundary to the backend.
11. Testing is split along the same boundaries. Unit tests mock the Ollama and Chroma clients, while an integration suite exercises the real RAG path end-to-end with Wikipedia HTTP traffic nocked. That confirms the architecture is designed around replacing external dependencies with mocks at the client boundary.
12. Operationally, the whole system is containerized. The Ollama entrypoint script pulls required models on startup, and the compose setup expects enough disk for model storage. The main deployment picture is therefore a local, self-hosted AI stack: browser/UI → Express API → scraper / Ollama / Chroma, all running under Docker Compose.
Main entry points: ingestService.js Ingest Service · client.js API Client · docker-compose.yml Compose · App.jsx React App
Components 24
Frontend
React UI served through nginx
- User · Human interacting with the app
- React App · Vite-powered presentation layer
frontend/src/App.jsx - API Client · Frontend boundary for backend requests
frontend/src/api/client.js - URL Form · Submits a Wikipedia URL
frontend/src/components/UrlForm.jsx - Summary Panel · Displays article summary
frontend/src/components/SummaryPanel.jsx - Chat Box · Collects and shows chat messages
frontend/src/components/ChatBox.jsx
Backend
Express API and RAG workflow
- Express App · Backend HTTP runtime
backend/src/app.js - Ingest API · POST /api/ingest entrypoint
backend/src/routes/ingest.js - Chat API · POST /api/chat entrypoint
backend/src/routes/chat.js - Health API · GET /api/health entrypoint
backend/src/routes/health.js - Ingest Service · Validates, scrapes, summarizes, chunks, and stores article content
backend/src/services/ingestService.js - RAG Service · Retrieval and answer generation workflow
backend/src/services/ragService.js - Wikipedia Scraper · Fetches and parses article HTML
backend/src/scraper/wikipediaScraper.js - Text Chunker · Normalizes and chunks article text
backend/src/text/chunker.js - Article State · Current article URL and summary within the process
backend/src/state/articleState.js - Ollama Client · Calls local LLM and embedding endpoints
backend/src/clients/ollamaClient.js - Chroma Client · Stores and retrieves article chunks
backend/src/clients/chromaClient.js - Summarize Prompt · Template for article summarization
backend/src/prompts/summarize.js - RAG Prompt · Template for context-grounded answering
backend/src/prompts/ragAnswer.js
External services
Local model and vector services plus Wikipedia
- Wikipedia · External article source
- Ollama · Runs llama3.2 and embedding models
- ChromaDB · Per-article collection storage and retrieval
Connections 29
- User → nginx: loads UI · User opens the production frontend
- nginx → React App: serves · nginx delivers the built React app
- React App → URL Form: renders · App composes the main UI areas
- React App → Summary Panel: renders · Shows generated article summary
- React App → Chat Box: renders · Shows the chat experience
- URL Form → API Client: submits URL · Starts ingestion through the backend
- Chat Box → API Client: asks question · Sends chat requests to the backend
- API Client → Ingest API: POST /api/ingest · Backend ingestion entrypoint
- API Client → Chat API: POST /api/chat · Backend chat entrypoint
- API Client → Health API: GET /api/health · Backend health check entrypoint
- Ingest API → Ingest Service: starts pipeline · Route delegates to ingestion workflow
- Chat API → RAG Service: starts pipeline · Route delegates to RAG workflow
- Health API → Express App: reports status · Simple service health surface
- Ingest Service → Wikipedia Scraper: scrapes · Extracts article content in-process
- Wikipedia Scraper → Wikipedia: fetches article · Reads the source page
- Ingest Service → Summarize Prompt: builds prompt · Prepares summarization input
- Ingest Service → Ollama Client: summarizes · Uses local model for summary generation
- Ingest Service → Text Chunker: normalizes chunks · Creates searchable text chunks
- Ingest Service → Article State: updates · Keeps current article in process memory
- Ingest Service → Chroma Client: upserts chunks · Persists vectors for the article
- RAG Service → Ollama Client: embeds and answers · Uses local model runtime for query embedding and completion
- RAG Service → Chroma Client: retrieves context · Fetches top-k similar chunks
- RAG Service → RAG Prompt: builds prompt · Combines question with retrieved context
- Ollama Client → Ollama: HTTP API · Calls local Ollama service
- Chroma Client → ChromaDB: HTTP API · Calls local ChromaDB service
- Compose → nginx: starts · Compose wires the frontend runtime
- Compose → Express App: starts · Compose wires the backend runtime
- Compose → Ollama: starts · Compose wires the model runtime
- Compose → ChromaDB: starts · Compose wires the vector store