How aymane-ait-arab/moroccan-legal-chatbot works
This repository is a bilingual Moroccan-law chatbot built around a legal-document preparation and retrieval-augmented answering workflow. Official PDFs are extracted to text, parsed into articles, indexed, then intended to support guarded retrieval and cited answers; the Streamlit chat and evaluation dashboard are user-facing surfaces. The sampled chat is still a placeholder and does not call the RAG pipeline, and the main app imports page paths that do not match the tree’s app/views paths. Accordingly, UI-to-RAG wiring is not asserted; the RAG stages follow the README and sampled pipeline code.
Main entry points: pipeline.py RAG pipeline · indexer.py Vector indexer · txt Extracted text · processed Processed law articles
Components 17
Legal corpus preparation
- PDF text extraction
src/parsing/extract_text.py - Law article parser
src/parsing/parse_laws.py - Regex article parser
src/parsing/parser.py
Retrieval and answering
- Vector indexer
src/embedding/indexer.py - BGE-M3 model
- Scope detector
src/guardrails/detector.py - RAG pipeline
src/rag/pipeline.py - Gemini LLM
- Groq LLM option
Chat and evaluation UI
- Streamlit entry
app/main.py - Bilingual chat view
app/views/chat.py - Metrics dashboard
app/views/dashboard.py
Legal data
- Official law PDFs
data/raw - Extracted text
data/processed/txt - Processed law articles
data/processed - ChromaDB collection
Other components
- Legal questioner
Connections 18
- Official law PDFs → PDF text extraction: extracts text
src/parsing/extract_text.py - PDF text extraction → Extracted text: writes text
src/parsing/extract_text.py - Extracted text → Law article parser: reads text
src/parsing/parse_laws.py - Law article parser → Processed law articles: writes articles
src/parsing/parse_laws.py - Extracted text → Regex article parser: parses text
- Regex article parser → Processed law articles: saves JSON
src/parsing/parser.py - Processed law articles → Vector indexer: loads articles
src/embedding/indexer.py - Vector indexer → BGE-M3 model: embeds articles
src/embedding/indexer.py - Vector indexer → ChromaDB collection: upserts vectors
src/embedding/indexer.py - Legal questioner → Bilingual chat view: asks question
app/views/chat.py - Legal questioner → Scope detector: submits query
README.md - Scope detector → RAG pipeline: allows in-scope
README.md - RAG pipeline → BGE-M3 model: embeds query
src/rag/pipeline.py - RAG pipeline → ChromaDB collection: queries articles
src/rag/pipeline.py - RAG pipeline → Gemini LLM: generates answer
src/rag/pipeline.py - RAG pipeline → Groq LLM option: may generate
README.md - Streamlit entry → Bilingual chat view: dispatches chat
- Streamlit entry → Metrics dashboard: dispatches dashboard