Skip to content

Repository files navigation

Winter Supplement Engine

A rules engine for calculating BC Winter Supplement benefits.


Table of Contents

Overview

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.

Assumptions & Constraints

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 familyUnitInPayForDecember status

Installation

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 .env

Continue with the installation by either following the Docker Setup or the Poetry Setup.

Docker Setup

Prerequisites:

Build the Docker Image

docker build -t winter-supplement-engine .

Poetry Setup

Install poetry using pipx

pipx install poetry
poetry install

Usage

The engine processes requests by default in wildcard subscription mode, handling all requests on the BRE/calculateWinterSupplementInput topic.

Custom Configuration

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

Running with Docker

Start the engine using Docker:

docker run --rm --env-file .env winter-supplement-engine

Running with Poetry

Start the engine using Poetry:

poetry run start

Testing

Testing with Docker

To run the unit tests with Docker use:

docker run --rm --entrypoint poetry winter-supplement-engine run pytest

Testing with Poetry

To run the unit tests with Poetry use:

poetry run pytest

Demo

winter-supplement-engine

About

A rules engine for calculating BC Winter Supplement benefits.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages