How mostafahikal/uniguide works
Purpose and entry points
UniGuide is a Python university-assistant chatbot for college-document questions and timetable queries. Its interactive entry point is app/ui.py; application orchestration is centered in app/main.py. The UI requires the user to select a query mode, making routing an explicit user-controlled boundary rather than an inferred classifier.
Presentation and chat orchestration
The Gradio layer collects a question and mode, invokes the chat pipeline, and displays the generated answer. app/ui.py is the runtime-facing interface; app/main.py coordinates request handling across routing, retrieval, and response generation. This is an application service, not a web/API server architecture.
Mode router
app/router.py dispatches requests into one of two retrieval paths:
• Structured retrieval for lectures, exams, and other tabular schedules.
• RAG retrieval for college information and PDF-backed general questions.
The selected mode controls which persistence system is accessed, isolating schedule data from unstructured document search.
Structured schedule path
For schedule/exam questions, the system extracts searchable constraints from the question and queries normalized JSON records. app/retrieval.py implements retrieval behavior, while data/tables.json is the structured data store and data/Tables/exams is source material for timetable content. Retrieved records are passed as grounding context to response generation rather than sent directly to the UI.
Document RAG path
For college-information questions, the system semantically searches a FAISS vector store built from institutional PDFs such as data/College/General_Bsc.pdf. app/retrieval.py owns the retrieval boundary; embeddings use the multilingual paraphrase-multilingual-MiniLM-L12-v2 model, supporting Arabic and other multilingual queries. The README describes a vector_store/ artifact, but it is not present in the supplied tree and must be generated/provided at deployment.
Ingestion and normalization
app/ingestion.py contains distinct source-to-store pipelines:
• PDF ingestion applies Tesseract OCR, normalization, chunking, embeddings, and FAISS indexing.
• Image/table ingestion uses Groq Vision to extract schedule records, then writes structured JSON.
app/normalizer.py standardizes extracted schedule records before storage, protecting structured retrieval from OCR/vision format variability. Raw data lives beneath data/; normalized structured output is data/tables.json.
Answer generation and external dependencies
app/responder.py turns retrieved context into the final natural-language response using Groq LLM inference, with templates/instructions centralized in app/prompts.py. Groq is therefore an external generation dependency on both retrieval paths; Groq Vision is additionally required during image ingestion. Runtime configuration, including API key, chat model, vision model, and embedding model, is centralized in app/config.py and sourced through .env conventions shown by .env.example.
Key runtime boundaries
Core infrastructure is local Python + Gradio, FAISS for vector persistence/search, JSON for schedules, and Tesseract for PDF OCR. Sensitive remote access is limited to Groq services via GROQ_API_KEY; model names are configurable. The principal flow is: UI mode/question → app/main.py/app/router.py → appropriate retrieval store → app/responder.py → UI answer.
Main entry points: retrieval.py Retrieval Service · config.py Runtime Configuration · ingestion.py PDF Ingestion · responder.py Response Generator
Components 19
Chat Runtime
- Gradio UI · Collects question and user-selected mode, then displays the answer.
app/ui.py - Chat Orchestrator · Coordinates routing, retrieval, and response generation.
app/main.py - Mode Router · Selects schedule or document retrieval from the explicit UI mode.
app/router.py - Response Generator · Builds grounded natural-language answers from retrieved context.
app/responder.py - Prompt Templates
app/prompts.py - Runtime Configuration · Centralizes model settings and API-key configuration.
app/config.py - Environment Contract · Documents required environment variables including GROQ_API_KEY.
.env.example
Retrieval Stores
- Retrieval Service · Implements both structured and semantic retrieval.
app/retrieval.py - Normalized Schedules · Normalized timetable and exam records.
data/tables.json - FAISS Vector Store · Deployment-generated index for institutional document chunks.
- College PDFs · Institutional source documents for RAG.
data/College/General_Bsc.pdf
Ingestion Pipelines
- PDF Ingestion · OCRs, normalizes, chunks, embeds, and indexes PDFs.
app/ingestion.py - Table Image Ingestion · Extracts schedule records from timetable images.
app/ingestion.py - Schedule Normalizer · Standardizes extracted records before JSON storage.
app/normalizer.py - Exam Source Tables · Raw timetable content used for schedule ingestion.
data/Tables/exams
External Services
- Tesseract OCR
- Multilingual Embeddings · paraphrase-multilingual-MiniLM-L12-v2 supports multilingual semantic search.
- Groq LLM · Remote inference for final answers.
- Groq Vision · Remote extraction for timetable images.
Connections 25
- Gradio UI → Chat Orchestrator: question + mode
- Chat Orchestrator → Mode Router: dispatch request
- Mode Router → Retrieval Service: selected retrieval path
- Retrieval Service → Normalized Schedules: structured schedule lookup
- Retrieval Service → FAISS Vector Store: semantic document search
- FAISS Vector Store → Retrieval Service: relevant chunks
- Normalized Schedules → Retrieval Service: matching records
- Retrieval Service → Chat Orchestrator: grounding context
- Chat Orchestrator → Response Generator: question + context
- Prompt Templates → Response Generator: instructions
- Response Generator → Groq LLM: generate answer
- Response Generator → Gradio UI: final answer
- College PDFs → PDF Ingestion: source PDFs
- PDF Ingestion → Tesseract OCR: OCR
- PDF Ingestion → Multilingual Embeddings: embed chunks
- PDF Ingestion → FAISS Vector Store: build index
- Exam Source Tables → Table Image Ingestion: source tables
- Table Image Ingestion → Groq Vision: extract records
- Table Image Ingestion → Schedule Normalizer: extracted records
- Schedule Normalizer → Normalized Schedules: normalized JSON
- Environment Contract → Runtime Configuration: documents variables
- Runtime Configuration → Retrieval Service: embedding settings
- Runtime Configuration → Response Generator: LLM settings
- Runtime Configuration → PDF Ingestion: embedding settings
- Runtime Configuration → Table Image Ingestion: vision settings