How harshvardhansalve/cse_department_rag works
This is a document-grounded department assistant with an admin upload interface. Staff upload and manage documents; ingestion parses and chunks files, embeds them, and stores them. Users chat with the assistant, whose API retrieves relevant chunks and uses an LLM to answer; the UI presents answers and source/download links. A separate API generates downloadable DOCX files from prompts and supplied context. The excerpts show these main calls, but not all routing between UI and generation/download endpoints.
Main entry points: supabase.ts Supabase access · chat/route.ts Chat API · generate-file/route.ts File generation API · page.tsx Home and tabs
Components 18
User interface
- Home and tabs
app/page.tsx - Chat interface
components/ChatUI.tsx - Answer and downloads
components/Message.tsx - Upload manager
components/FileUpload.tsx
API workflows
- Chat API
app/api/chat/route.ts - Ingest API
app/api/ingest/route.ts - File generation API
app/api/generate-file/route.ts - Download API
app/api/download/route.ts
Document intelligence
- Parse and index
lib/ingest.ts - Text embeddings
lib/embeddings.ts - Hybrid retrieval
lib/retriever.ts - DOCX builder
lib/fileGenerator.ts
Persistence and services
- Supabase access
lib/supabase.ts - Document records
supabase_schema.sql - File storage
Other components
- User or staff
- Groq LLM
- Hugging Face
Connections 24
- User or staff → Home and tabs: uses
- Home and tabs → Chat interface: loads
app/page.tsx - Home and tabs → Upload manager: loads
app/page.tsx - Chat interface → Chat API: sends chat
components/ChatUI.tsx - Chat interface → Answer and downloads: renders
components/ChatUI.tsx - Upload manager → Ingest API: uploads files
components/FileUpload.tsx - Upload manager → Ingest API: lists files
components/FileUpload.tsx - Ingest API → Parse and index: ingests or deletes
app/api/ingest/route.ts - Parse and index → Text embeddings: embeds chunks
lib/ingest.ts - Text embeddings → Hugging Face: requests vectors
lib/embeddings.ts - Parse and index → Supabase access: stores files and chunks
lib/ingest.ts - Chat API → Hybrid retrieval: retrieves context
app/api/chat/route.ts - Hybrid retrieval → Text embeddings: embeds queries
lib/retriever.ts - Hybrid retrieval → Supabase access: searches chunks
lib/retriever.ts - Chat API → Groq LLM: generates answers
app/api/chat/route.ts - Chat API → Supabase access: looks up download paths
app/api/chat/route.ts - Chat API → Answer and downloads: returns answer data
- File generation API → Groq LLM: generates content
app/api/generate-file/route.ts - File generation API → DOCX builder: builds DOCX
app/api/generate-file/route.ts - File generation API → Supabase access: uploads and signs
app/api/generate-file/route.ts - Download API → Supabase access: signs download
app/api/download/route.ts - Supabase access → Document records: reads and writes records
- Supabase access → File storage: stores files
- User or staff → File generation API: requests file