ME-Bot is a specialized React and Flask-based Artificial Intelligence assistant using LangChain and Retrieval-Augmented Generation (RAG). This chatbot acts as an expert exclusively on Middle Eastern culture, history, politics, and geographic information. It strictly enforces a specialized focus on the Middle East, gracefully declining questions outside its scope.
- Frontend: React.js
- Backend: Python / Flask
- LLM Orchestration: LangChain
- Vector Database: ChromaDB
- Embeddings: HuggingFace (
sentence-transformers/all-mpnet-base-v2) - LLM Provider: OpenRouter (OpenAI-compatible APIs)
- Retrieval-Augmented Generation (RAG): Uses a local directory (
middle_east_data/) populated with specialized.txtknowledge files to strictly base answers on verifiable context. - Auto-Initialization: On initial boot, the backend automatically reads the text files, chunks them using the
RecursiveCharacterTextSplitter, creates embeddings, and persists the data to a localchroma_dbfolder. - Graceful Fallback Logic: The System Prompt is engineered to differentiate between correct facts, explicit false statements, and out-of-scope inquiries.
- RESTful API Endpoint: Handles standard backend connectivity via POST
/api/chat. - Static Hosting: The Flask application is built to serve the compiled frontend production static bundle directly.
DesertMind/
├── chat_bot.py # Main Flask API and LangChain configuration
├── requirement.txt # Python dependencies (Flask, Langchain, etc.)
├── middle_east_data/ # Directory containing text documents for the knowledge base
│ └── me_members.txt # Example facts and regional changes (2026 update)
├── chroma_db/ # (Generated) Local vector store initialized by LangChain
├── .env # Contains Environment variables (like OPENROUTER_API_KEY)
└── front_end/ # React.js application
├── src/ # React components, pages, CSS styles, and UI logic
├── public/ # Static base HTML and assets
└── package.json # Node modules and build scripts
- Navigate to the Root Directory
cd DesertMind - Setup a Python Virtual Environment (Optional but Recommended)
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install Dependencies
pip install -r requirement.txt
- Environment Variables
Create a
.envfile in the root directory and add your OpenRouter key:OPENROUTER_API_KEY=your_api_key_here
- Start the Backend Server
Note: On your first run, the server will briefly pause to automatically chunk your
python3 chat_bot.py
middle_east_data/files and create thechroma_dbvector store before binding tohttp://localhost:5000.
- Open a new terminal and navigate to the frontend directory
cd DesertMind/front_end - Install Node.js dependencies
npm install
- Start the Development Server
The React app will typically run on
npm start
http://localhost:3000and proxy backend requests to the running Flask server.
The Flask server (chat_bot.py) is written with production hosting in mind. It serves the static bundle directly from /api fallback routes:
- Build the React Frontend
Ensure the output directory is configured as
cd front_end npm run build../me-bot-frontend/build(or the respective script mapping) so Flask can serveindex.htmlon the root/endpoint. - Run your Flask app under a WSGI server like
gunicornto expose and host the full stack seamlessly!
To update what ME-Bot knows:
- Add, modify, or remove
.txtfiles inside themiddle_east_data/folder. - Delete the
chroma_db/folder from your root directory entirely. - Restart
chat_bot.py. The backend will naturally rebuild the vector database with your new contextual data!