How madhan-200/minelawhub works
MineLawHub is a chat application for answering questions about Indian mining law, combining document retrieval, web updates, and generated cited responses. The main workflow runs from the React chat interface to the FastAPI chat endpoint, which classifies intent, retrieves legal text and/or current web results, and asks Gemini to compose an answer. The README also documents PDF extraction, text cleaning, optional English-page splitting, and embedding creation. Some backend and frontend wiring is supported only by the README or source index; those limits are reflected in the evidence paths.
Main entry points: App.jsx Chat app · ChatWindow.jsx Chat display · main.py FastAPI endpoints · InputBox.jsx Query input
Components 24
Chat interface
- Chat app
frontend/src/App.jsx - Query input
frontend/src/components/InputBox.jsx - Chat display
frontend/src/components/ChatWindow.jsx - Answer and citations
frontend/src/components/MessageBubble.jsx - Assistant avatar
frontend/src/components/AnimatedAvatar.jsx - Welcome text
frontend/src/components/TypewriterText.jsx - Navigation and theme
frontend/src/components/Navbar.jsx - Suggested queries
frontend/src/components/Sidebar.jsx - Design theme
frontend/src/theme/theme.js
Chat and answer services
- FastAPI endpoints
backend/main.py - Intent and answer generation
backend/gemini_client.py
Legal and web sources
- Semantic retrieval
backend/search_engine.py - Law vector collection
embeddings/build_embeddings.py - Mining web search
backend/tavily_client.py
Document preparation
- Source law PDFs
data/pdfs - PDF text extraction
preprocessing/extract_text.py - Extracted text
data/text - Text cleaning
preprocessing/clean_text.py - Cleaned law text
data/cleaned - English-page splitting
preprocessing/split_english.py - Embedding builder
embeddings/build_embeddings.py
Other components
- User
- Tavily Search API
- Gemini API
Connections 25
- User → Query input: enters query
frontend/src/components/InputBox.jsx - Query input → Chat app: submits query
frontend/src/App.jsx - Chat app → FastAPI endpoints: posts chat
frontend/src/App.jsx - Chat app → Chat display: renders messages
frontend/src/App.jsx - Chat display → Answer and citations: renders answers
frontend/src/components/ChatWindow.jsx - Chat display → Assistant avatar: renders avatar
frontend/src/components/ChatWindow.jsx - Chat display → Welcome text: renders welcome
frontend/src/components/ChatWindow.jsx - Chat app → Query input: renders input
frontend/src/App.jsx - Chat app → Navigation and theme: renders navigation
frontend/src/App.jsx - Chat app → Suggested queries: renders sidebar
frontend/src/App.jsx - Chat app → Design theme: configures theme
frontend/src/App.jsx - Answer and citations → Assistant avatar: renders avatar
frontend/src/components/MessageBubble.jsx - FastAPI endpoints → Intent and answer generation: classifies and generates
backend/main.py - FastAPI endpoints → Semantic retrieval: retrieves law
backend/main.py - FastAPI endpoints → Mining web search: searches updates
backend/main.py - Semantic retrieval → Law vector collection: queries collection
backend/search_engine.py - Mining web search → Tavily Search API: searches
backend/tavily_client.py - Intent and answer generation → Gemini API: generates response
- Source law PDFs → PDF text extraction: extracts text
README.md - PDF text extraction → Extracted text: writes text
README.md - Extracted text → Text cleaning: normalizes text
README.md - Text cleaning → Cleaned law text: writes cleaned text
README.md - Source law PDFs → English-page splitting: splits pages
README.md - Cleaned law text → Embedding builder: builds embeddings
README.md - Embedding builder → Law vector collection: creates collection
README.md