AI assistant on Moroccan law
A prototype assistant that answers legal questions from the texts of the law, designed so it can later run fully local.
How it flows
Preparing the texts
- Legal textsimported and split (Built)
- Numerical representationscomputed locally with Ollama (Built)
- Vector databaseChromaDB, on the machine (Built)
Answering a question
- Questionasked from a command-line client (Built)
- FastAPI serverreceives the question (Built)
- Passage searchthe closest ones, in ChromaDB (Built)
- Language modelonline by default (Gemini or OpenAI), Ollama possible locally (External service)
- Answeror "I do not have the information" (Built)
The need
In law, an answer is only worth something if it rests on the texts. A language model alone answers from memory; this project answers from the documents.
What I built
A complete pipeline: documents are split, turned into numerical representations (embeddings) computed locally with Ollama, then stored in ChromaDB. A FastAPI server exposes the engine. For each question, the assistant retrieves the relevant passages and answers from them. The language model is configurable: online by default (Gemini or OpenAI, which then receives the question and the retrieved passages), or Ollama locally. The model's instructions are tuned for legally precise answers.
Why this approach
Answering from the documents limits made-up answers. This is a prototype: the language model is online by default, but the application is designed to run fully local one day, which matters for confidential documents.
Demo
Screens
Architecture and flows
The prototype's components
Time given back
Illustrative scenario
This is not a measured result: it is what the project could give back, given the assumptions below.
For a firm, the time given back would come from looking up a text or an answer in its documentation, done by the assistant instead of searched by hand.
What it rests on
- The current search time for each question: to be measured with the firm.
- The number of questions asked each week: to be confirmed.
- The firm's documents to include: to be defined together.
Technologies
- Python
- FastAPI
- Ollama
- LangChain
- ChromaDB
Other projects
- Smart patient recordA patient record platform for a neonatal department: step-by-step entry, secure images, PDF reports and an AI assistant.
- School Net, an online course platformAn online course platform with sign-up, subscription payment and videos. A personal project built to learn.
- Real-time data trackingA background service watches transactions live and historically, and computes the results for you.
A task like this one?
Describe it in a few words. I reply with precise questions.



