Skip to main content

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

  1. 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
  1. Install required dependencies:
pip install -r requirements.txt

Prerequisites

Before starting any service:

  1. Ensure MongoDB is running and accessible

  2. Copy environment templates and configure variables:

ServiceTemplate LocationTarget LocationRequired Variables
Chatbot.env_template.envMONGODB_URI
MONGODB_DB
MONGODB_COLLECTION
OPENAI_API_KEY
Emailemail_service/.env_templateemail_service/.envMONGODB_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:

EndpointMethodPurpose
/send-emailPOSTSend email to recipient
/subscribePOSTSubscribe to topics
/unsubscribePOSTUnsubscribe from topics
/topicsGETList available topics
/daily-reports/countriesGETGet countries with daily reports

Running the Chatbot

Start the service:

python src/app.py

Available endpoints at http://localhost:5000:

EndpointMethodPurpose
/queryPOSTMain chatbot interaction endpoint
/docsGETOpenAPI documentation
/redocGETAlternative 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:

  1. Start MongoDB (if not already running)
  2. Run parsers and uploaders:
python src/run_all_parsers.py
python src/run_all_uploaders.py
python src/report_chatting/upload_all_reports.py
  1. Start the services:
# In separate terminals:
python src/email_service/app.py
python src/app.py

Common Issues

  1. MongoDB Connection

    • Check if MongoDB is running
    • Verify connection string in .env
    • Check network connection
  2. Missing Data

    • Run parsers individually to identify issues
    • Check if API endpoints are accessible
    • Verify file permissions in src/assets/
  3. 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