Arabic/Darija Patient Chatbot API
# Arabic/Darija Patient Assistance Chatbot API
A local FastAPI MVP that structures medication-related requests written in Arabic, Moroccan Darija, French, or mixed language.
The project is intentionally simple: it does not train a machine learning model, does not use a database, and does not require a paid API. It uses clear rule-based NLP plus RapidFuzz medicine matching so the behavior is easy to explain during a Master IT demo.
## Problem Context
In Morocco, patients often describe pharmacy needs using a mix of Moroccan Darija, Arabic, and French. A useful assistant should understand messages such as `bghit 2 boites doliprane`, `avez-vous amoxicilline 500mg ?`, or `بغيت دواء للسخانة` and convert them into structured information.
This project focuses only on request understanding. It does not diagnose, prescribe, recommend dosage, or replace a healthcare professional.
## Objectives
- Accept Arabic, Darija, French, and mixed-language text.
- Detect the request intent.
- Extract medicine name, quantity, unit, dosage, medicine form, and simple symptom when available.
- Match medicine names using local aliases and fuzzy matching.
- Return clean JSON for a future chatbot, pharmacy interface, or mobile app.
- Keep the solution local, explainable, testable, and easy to present.
## Features
- FastAPI backend with automatic Swagger documentation.
- Rule-based normalization, language detection, intent detection, and entity extraction.
- RapidFuzz medicine matching from `data/medicines.json`.
- Single-text and batch analysis endpoints.
- Optional local voice endpoint using Whisper when voice dependencies are installed.
- Streamlit demo interface for a quick visual presentation.
- Pytest coverage for API endpoints and NLP examples.
- Documentation for architecture, API examples, and evaluation.
## Architecture
```mermaid
flowchart LR
A["User text"] --> B["Normalize text"]
B --> C["Detect language"]
B --> D["Detect intent"]
B --> E["Extract entities"]
B --> F["Match …