A rules engine for calculating BC Winter Supplement benefits.
The goal of this assignment is to implement a business rules engine that determines eligibility and calculates the benefits a client is eligible to receive.
The engine implements the following validation rules and constraints:
- Family composition has to be "single" or "couple" (case insensitive)
- Number of children has to be a non-negative integer not exceeding 30
- I chose this upper limit to accommodate for most cases while making sure the system can't be misused
- I assume cases exceeding this limit would likely require manual review
- Eligibility is determined by the
familyUnitInPayForDecemberstatus
Prerequisites:
Clone the repository
git clone https://www.github.com/mikesmvl/winter-supplement-engine.git
cd winter-supplement-engine/Copy the example env file
cp .env.example .envContinue with the installation by either following the Docker Setup or the Poetry Setup.
Prerequisites:
- Docker (installed/running)
Build the Docker Image
docker build -t winter-supplement-engine .
Install poetry using pipx
pipx install poetry
poetry installThe engine processes requests by default in wildcard subscription mode, handling all requests on the BRE/calculateWinterSupplementInput topic.
To process requests for a specific MQTT topic ID, update your .env file with the MQTT_TOPIC_ID given by the Winter Supplement Calculator:
MQTT_TOPIC_ID=8c882c0e-b4c3-41b4-9d71-a58e2df2f5cb
Start the engine using Docker:
docker run --rm --env-file .env winter-supplement-engineStart the engine using Poetry:
poetry run startTo run the unit tests with Docker use:
docker run --rm --entrypoint poetry winter-supplement-engine run pytestTo run the unit tests with Poetry use:
poetry run pytest