Inspiration
We are living in an era defined by Artificial Intelligence, yet our academic institutions still rely heavily on manual, fragmented intelligence. In our polytechnic institute, essential information—such as BTEB Probidhan regulations, dynamic class routines, examination schedules, fee structures, teacher directories, hostel accommodations, and 8th-semester industrial attachment guidelines—was scattered across physical notice boards, blurred social media photos, and multi-page PDFs.
Students frequently spent hours queuing up at administrative offices or asking in peer groups just to confirm simple queries like class timings or CGPA weightages. This disconnect inspired us to build RGPIGPT (CampusGPT): a production-grade, 24/7 AI-powered campus assistant designed to deliver instant, grounded, and verified answers in native Bengali, Banglish (phonetic Bengali in Latin script), and English.
What it does
RGPIGPT is a college information chatbot built with retrieval-augmented generation (RAG) that prioritizes factual verification over fluent speculation.
- Verified Academic Answers: Accurately answers questions on admissions, departmental seats, teacher contacts, lab facilities, campus hostels, stipends, and BTEB Diploma-in-Engineering academic regulations (Probidhan 2016 & 2022).
- Multilingual Understanding: Native support for Bengali (বাংলা), Banglish (e.g., "ajke cse 4th sem er routine ki?"), and English.
- Strict Evidence Grounding & Zero-Hallucination Policy: Every college fact is retrieved from approved institutional documents inside PostgreSQL via
hybrid_search. If an inquiry involves unverified campus rumors or unindexed topics, the assistant reliably abstains with an honest "not in approved documents" response rather than inventing answers. - Dual Portal Experience:
- Student Interface: A distraction-free, mobile-optimized experience featuring a cosmic-nebula aesthetic, progressive streaming responses, and authenticated student profiles.
- Admin Knowledge Hub: A role-protected management dashboard with document ingestion (PDF, DOCX, TXT, images with Gemini OCR), chunk inspection, retrieval playgrounds, audit logs, and provider health telemetry.
- Sub-Second Caching: Two-tier caching combining exact-match and semantic similarity ($S_{\text{cos}} \ge 0.96$) to bypass model latency entirely on popular student queries.
How we built it
We designed RGPIGPT with a modern edge-first, multi-tier architecture:
Frontend & Edge Runtime:
- Built with Next.js 16 (App Router), React 19, TypeScript, and Tailwind CSS 4.
- Deployed at the edge using Cloudflare Workers via
@opennextjs/cloudflarefor ultra-low latency.
Database & Hybrid Retrieval Engine:
- Supabase PostgreSQL with
pgvectorstoring 768-dimensional embeddings (gemini-embedding-001). - Hybrid search combines dense vector retrieval (semantic understanding) with sparse full-text search (PostgreSQL
simpleconfiguration for course codes and dates) using Reciprocal Rank Fusion: $$\text{RRF}(d) = \sum_{m \in M} \frac{1}{k + r_m(d)}$$ - Optional cross-encoder reranking powered by NVIDIA NIM (
nvidia/nemotron-3.5-rerank-8b) for high-precision chunk reordering.
- Supabase PostgreSQL with
Quota-Aware Model Routing & Circuit Breakers:
- Primary Model: Google Gemini (
gemini-3.5-flash-lite/gemini-3.5-flash). - High-Speed Fallback: Groq (
openai/gpt-oss-120b,gpt-oss-20b,qwen/qwen3.8-27b). - Designed a database-backed circuit breaker that tracks provider quota scopes and rate limits (HTTP 429) across serverless instances, triggering immediate failover without burning request deadlines.
- Bounded exponential backoff with jitter for transient errors: $$t_{\text{backoff}} = \min(t_{\text{ceiling}}, t_{\text{base}} \times 2^{\text{attempt}}) \pm \text{jitter}$$
- Primary Model: Google Gemini (
Deterministic BTEB Academic Calculations:
- To avoid LLM arithmetic drift on grading rules, we built dedicated rule-based evaluators for BTEB Probidhan 2016/2022 8-semester credit weight distributions: $$\text{CGPA} = \sum_{i=1}^{8} \left( \text{GPA}_i \times W_i \right)$$ where $W = [0.05, 0.05, 0.05, 0.10, 0.15, 0.20, 0.25, 0.15]$.
Intelligent Ingestion Pipeline:
- Ingests institutional PDFs, Word documents, and scanned circulars using Gemini OCR.
- Structured JSON schema normalization preserves markdown table schemas and temporal headings before ingestion.
Challenges we ran into
Table Structure Destruction During Chunking:
- Problem: Standard chunking sliced multi-column class routines, teacher directories, and fee tables mid-row. A chunk retrieved without its column headers became unusable, leading to truncated or garbled answers.
- Solution: We engineered a header-preserving chunker (
withTableHeader) inlib/rag/chunk.tsthat tracks the active table header and automatically re-injects the column names and separators into every slice that begins mid-table.
Phonetic Banglish & Temporal Query Discrepancies:
- Problem: Students rarely type formal Bengali keywords; they ask "shonibar 2nd shift er class kobe?" or "ajke lab ache kina". PostgreSQL lacks native Bengali lemmatizers.
- Solution: We built a phonetic translation and query normalization module along with a temporal parser (
temporal.ts) that maps colloquial terms ("ajke", "agamikal", day names) to academic calendar dates and shifts before retrieval.
Hallucinated Citations & Fabricated Details:
- Problem: LLMs frequently paraphrased official phone numbers, room codes, or syllabus codes inaccurately to sound confident.
- Solution: We introduced strict citation mapping where the model returns integer evidence indices rather than free-form URLs or claims. In addition, deterministic response builders directly output verified contact cards and routines without letting the model retype sensitive figures.
Edge Runtime & Free-Tier Quota Constraints:
- Problem: Serverless edge functions lack persistent memory to track rate limits across invocations, risking cascading failures under burst traffic.
- Solution: We persisted circuit breaker states, token policies, and quota cooldowns directly inside Supabase SQL tables, ensuring seamless state recovery across worker cold starts.
Accomplishments that we're proud of
- 100% Pass Rate on Benchmark Evaluation: Validated the entire RAG pipeline against a 34-case live golden dataset using DeepEval and GEval, boosting accuracy from 76.5% to a perfect 100% (34/34) and achieving an answer accuracy score of 0.974.
- Latency Cut by Over 60%: Optimized retrieval pipelines and prompt budgets to decrease average live query latency from 12,720 ms down to 4,648 ms (and sub-200 ms on semantic cache hits), completely eliminating response truncation.
- Zero Forbidden Claim Hits: Successfully passed all adversarial rumor tests and out-of-scope probes with 0 false claims and 100% correct abstentions.
- Robust Codebase: Over 480 unit and integration tests passing with complete end-to-end TypeScript type safety.
- Real-World Impact: Running live at the edge on Cloudflare Workers, serving genuine students and faculty with zero infrastructure hosting cost.
What we learned
- Data Chunking Trumps Model Size: Prompt engineering cannot rescue corrupted retrieval context. Preserving tabular hierarchy and semantic context during ingestion improved generation quality far more than switching to heavier models.
- Evaluation-Driven Development (EDD): Utilizing synthetic and golden test suites with automated LLM judges (DeepEval) transformed ambiguous UX feedback into measurable, reproducible engineering benchmarks.
- Determinism Where Precision Matters: While LLMs excel at language synthesis and summarization, deterministic code paths are essential for mathematical grading scales, official contacts, and exact schedules.
What's next for College Chatbot Assistant
- Automated Notice Board Synchronization: Building automated webhooks and scheduled scrapers to pull and index circulars directly from official college portals and the BTEB notice board as soon as they are published.
- Bengali Voice Interface: Integrating speech-to-text and text-to-speech for hands-free, voice-based interactions for students on the move.
- Personalized Student Timetables: Expanding student profiles to allow one-click personalized schedule filtering based on the student's department, semester, roll number, and shift.
- Multi-Campus Open Source Deployment: Packaging our RAG pipeline and quota-routing architecture into an open-source template to empower other polytechnic and vocational institutes nationwide.
Built With
- bengali
- css
- deepeval
- events
- gemini
- groq
- hybrid
- next.js
- nim
- node.js
- nvidia
- ocr
- opennext
- pgvector
- postgresql
- rag
- react
- search
- semantic
- server-sent
- supabase
- tailwind
- typescript
- vector
- vitest