How to Run All Services
Author: Georgi Peev
This guide explains how to set up and run the WFP Chatbot and Email services - particularly, all the parsers, uploaders, and services required to run the WFP Hungermap project.
Environment Setup
- Create and activate a Python virtual environment:
# Create venv
python -m venv venv
# Activate venv
# On Windows:
venv\Scripts\activate
# On Unix/MacOS:
source venv/bin/activate
- Install required dependencies:
pip install -r requirements.txt
Prerequisites
Before starting any service:
-
Ensure MongoDB is running and accessible
-
Copy environment templates and configure variables:
Service | Template Location | Target Location | Required Variables |
---|---|---|---|
Chatbot | .env_template | .env | MONGODB_URI MONGODB_DB MONGODB_COLLECTION OPENAI_API_KEY |
email_service/.env_template | email_service/.env | MONGODB_URI MONGODB_DB_EMAIL_SERVICE BREVO_API_KEY BREVO_SENDER_EMAIL BREVO_SENDER_NAME BASE_URL |
Running the Email Service
Start the service:
python src/email_service/app.py
Available endpoints at http://localhost:5001
:
Endpoint | Method | Purpose |
---|---|---|
/send-email | POST | Send email to recipient |
/subscribe | POST | Subscribe to topics |
/unsubscribe | POST | Unsubscribe from topics |
/topics | GET | List available topics |
/daily-reports/countries | GET | Get countries with daily reports |
Running the Chatbot
Start the service:
python src/app.py
Available endpoints at http://localhost:5000
:
Endpoint | Method | Purpose |
---|---|---|
/query | POST | Main chatbot interaction endpoint |
/docs | GET | OpenAPI documentation |
/redoc | GET | Alternative API documentation |
See API Documentation for detailed endpoint specifications.
Running Data Pipeline
1. Run All Parsers
Execute all data parsers:
python src/run_all_parsers.py
This will run parsers for:
- Country reports
- General country data
- Additional country data
- PDC (Pacific Disaster Center) data
- Conflict data
- IPC (Integrated Food Security Phase Classification) data
- ISO3 country codes
- Yearly reviews
2. Run All Uploaders
Upload all parsed data to MongoDB:
python src/run_all_uploaders.py
This will upload:
- Country data (general, additional, PDC, conflict, IPC)
- Population and economic data
- Food security data (FCS, RCSI)
- Reports (country reports, yearly reviews)
3. Run Report Processing
Process and upload report content:
python src/report_chatting/upload_all_reports.py
Running Everything
To run all services in the correct order:
- Start MongoDB (if not already running)
- Run parsers and uploaders:
python src/run_all_parsers.py
python src/run_all_uploaders.py
python src/report_chatting/upload_all_reports.py
- Start the services:
# In separate terminals:
python src/email_service/app.py
python src/app.py
Common Issues
-
MongoDB Connection
- Check if MongoDB is running
- Verify connection string in
.env
- Check network connection
-
Missing Data
- Run parsers individually to identify issues
- Check if API endpoints are accessible
- Verify file permissions in
src/assets/
-
Service Issues
- Check if MongoDB collections exist and have data
- Verify that all required environment variables are set
- Ensure ports 5000 and 5001 are available
- Ensure all dependencies are installed