How prafullpatel-dev/collegeordinancechatbot-miniproject works
Purpose and entry points
This is a local Streamlit Retrieval-Augmented Generation (RAG) chatbot for querying uploaded DMPC ordinance PDFs. The runtime entry point is app.py, launched with streamlit run app.py. RAG orchestration is separated into rag_backend.py.
Presentation and session controller
app.py owns the browser-facing Streamlit interface: multi-PDF upload, explicit document processing, chat input/output, and controls to clear chat or reset the session. It maintains per-browser-session conversational state and the currently built retrieval pipeline rather than exposing an HTTP API or persistent multi-user service.
Paths: app.py
Document ingestion boundary
Uploaded PDF content enters through the UI and is handed to the backend for text extraction. The documented loader is LangChain PyPDFLoader; PDFs must contain extractable text, as no OCR service or preprocessing stage is present. This is the key boundary between untrusted user documents and the in-memory RAG corpus.
Paths: app.py, rag_backend.py
Chunking and embedding stage
The backend splits extracted ordinance text into overlapping chunks before indexing. Its architecture-level parameters are a chunk size of 1,000 characters and 200-character overlap. Each chunk is embedded with HuggingFace’s sentence-transformers/all-MiniLM-L6-v2, typically requiring model download/cache availability in the execution environment.
Paths: rag_backend.py, requirements.txt
Retrieval index
Embeddings are stored in a FAISS vector store created from the uploaded documents. At question time, the backend turns the store into a retriever configured to return the top three relevant chunks. The index is derived from the active upload/session rather than described as durable storage, so reprocessing or reset rebuilds/removes the available knowledge base.
Paths: rag_backend.py, app.py
Answer-generation chain
For each chat question, the application combines retrieved ordinance chunks with conversational history and submits the resulting context to a LangChain-managed LLM chain. The generation provider is Groq, using llama-3.3-70b-versatile (Llama 3.3 70B). The answer returns to app.py for rendering and addition to chat history.
Paths: rag_backend.py, app.py
Runtime dependencies and external services
The application is Python-based, with Streamlit, LangChain, FAISS, PDF loading, and HuggingFace embedding dependencies declared in requirements.txt. Groq is the material external inference service; its credential is supplied via GROQ_API_KEY in a root .env file. Local container development support exists in .devcontainer/devcontainer.json, but no deployment, database, object store, or server-side persistence is represented.
Paths: requirements.txt, .devcontainer/devcontainer.json, app.py
Main entry points: app.py Streamlit UI · rag_backend.py RAG orchestrator · requirements.txt Python dependencies · devcontainer.json Dev container
Components 14
Streamlit session
Browser-facing local application state.
- Streamlit UI · Handles uploads, processing controls, chat, and reset actions.
app.py - Session state · Stores chat history and the active retrieval pipeline per browser session.
app.py - Uploaded ordinance PDFs · PDFs require extractable text because OCR is absent.
app.py
RAG pipeline
In-memory document processing and question answering.
- RAG orchestrator
rag_backend.py - PyPDFLoader
rag_backend.py - Text chunker · Creates 1,000-character chunks with 200-character overlap.
rag_backend.py - MiniLM embeddings · Uses sentence-transformers/all-MiniLM-L6-v2.
rag_backend.py - FAISS vector store · Derived from the active upload and rebuilt or removed on reset.
rag_backend.py - Top-3 retriever
rag_backend.py - Answer chain · Combines retrieved chunks and conversational history.
rag_backend.py
Runtime services
Model and local runtime dependencies.
- Groq Llama 3.3 70B · llama-3.3-70b-versatile, authenticated with GROQ_API_KEY.
- Python dependencies · Declares Streamlit, LangChain, FAISS, PDF, and embedding packages.
requirements.txt - Dev container
.devcontainer/devcontainer.json
Other components
- Local user
Connections 17
- Local user → Streamlit UI: uses
- Streamlit UI → Uploaded ordinance PDFs: accepts
- Streamlit UI → Session state: maintains
- Streamlit UI → RAG orchestrator: processes and queries
- Uploaded ordinance PDFs → RAG orchestrator: submitted for indexing
- RAG orchestrator → PyPDFLoader: extracts text
- PyPDFLoader → Text chunker: text
- Text chunker → MiniLM embeddings: chunks
- MiniLM embeddings → FAISS vector store: indexes vectors
- FAISS vector store → Top-3 retriever: searches
- Top-3 retriever → Answer chain: relevant chunks
- Session state → Answer chain: chat history
- Answer chain → Groq Llama 3.3 70B: generates answer
- Answer chain → Streamlit UI: answer
- RAG orchestrator → Session state: active pipeline
- Python dependencies → Streamlit UI: supports runtime
- Dev container → Streamlit UI: local development