This backend implements a data-driven ML system for automated income loss claims.
- Python 3.8+
- Virtual environment (recommended)
-
Navigate to the backend directory:
cd backend -
Create and activate a virtual environment:
python -m venv venv # On Windows: .\venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Initialize AI Models (CRITICAL): Run the training script to generate the regional models and initial synthetic data.
python ai_service/train.py
This will create a
backend/ai_service/models/folder with.pklfiles.
-
Start the Flask Server:
python app.py
The server will start at
http://localhost:5000. -
Trigger the Weekly Pipeline (Admin Hook): You can manually trigger a full system evaluation (ingestion -> features -> AI -> decision -> claims) by sending a POST request to:
http://localhost:5000/predictions/run-pipeline
To verify all API endpoints and logic:
python -m pytest tests/ai_service/: Standalone ML training and prediction logic (Region-based & Personalized).services/: Core logic for ingestion, preprocessing, and the rules engine.routes/: Flask API endpoints.jobs/: Background tasks/pipelines.db/: Mock MongoDB implementation.