Docs
DocuMind
Project Overview
Students and professionals waste hours reading documents. DocuMind turns any PDF into a conversational AI assistant. Upload → Ask → Learn in seconds.
Project Structure
Directory Overview
nextjs/— Next.js UI placeholder (quick demo)rag/— Python RAG (Retrieval-Augmented Generation) building blocksutils/— Helper utilities (zipping assets, ensure directories, etc.)config/— Configuration files for modularity and DRY principlesRAG Modules
Core Components
loader.py
PDF loading utilities (uses `pypdf` by default). Extracts raw text from PDFs.
chunker.py
Naive text chunking function to split large documents into smaller chunks suitable for embeddings.
embedder.py
Wrapper around `sentence-transformers` to create vector embeddings for chunks and queries.
vectordb.py
FAISS-based in-memory vector store wrapper with simple add/search APIs.
qa.py
High-level flow that ties the components together: load PDF → chunk → embed → build/search index → return top contexts.
Runtime Flow
How the System Works
- 1.User uploads a PDF and submits a question via the Next.js UI.
- 2.Frontend sends the file and question to the backend (e.g., a FastAPI endpoint at `POST /ask`).
- 3.Backend uses `rag/loader.py` to extract text and `rag/chunker.py` to create chunks.
- 4.`rag/embedder.py` converts chunks to embeddings; `rag/vectordb.py` builds a FAISS index and performs similarity search using the question embedding.
- 5.`rag/qa.py` returns the top matching chunks and a `combined_context` string. Optionally the backend then calls an LLM (OpenAI / other) with the question + contexts to generate a polished answer.
- 6.The frontend displays the answer and optionally shows the supporting contexts.
Backend Setup
API Configuration
Location: backend/app.py (not scaffolded here to keep the skeleton minimal)
Endpoint: POST /ask
Expects: file, question (multipart form)
Next Steps
Development Roadmap
- 1.Add `backend/app.py` with a `POST /ask` endpoint that saves uploaded file to a temp folder, calls `rag.answer_question_from_pdf()`, and optionally calls an LLM (OpenAI) to synthesize an answer from the `combined_context`
- 2.Add a minimal `Dockerfile` or `Procfile` for easy deployment.
- 3.Add sample PDF(s) in `demo/` and a short demo GIF for presentation.
- 4.Add unit tests in `rag/tests/` for `chunker`, `embedder` (smoke), and `loader`.
Hackathon Tips
Best Practices
- •Keep prompts in a single file for quick iteration (e.g., `rag/prompts.py`).
- •Use `sentence-transformers` + `faiss-cpu` for fast local retrieval without needing a cloud setup.
- •If LLM quota or latency is a concern, prepare a fallback: pre-generate answers for a few sample PDFs and keep them in `demo/` for a smooth live demo.
Styling Configuration
Glassmorphism Theme
Theme: Glassmorphism
Framework: Tailwind CSS
Global Utilities:
.glass— Glass effect background.glass-border— Glass effect border.badge— Badge styling utilityGlassCard Props:
title— string - Card titlesubtitle— string - Card subtitleavatar— string - Avatar URL/iconchildren— ReactNode - Card contentPerformance Tips
From Configuration
- •Keep heavy images as optimized webp and serve with next/image for automatic optimization.
- •For animations, prefer CSS transitions over JS where possible.