This application receives the user profile through the API and transforms it into a risk profile by calculating a risk score for each line of insurance (life, disability, home & auto) based on the information.
Test Coverage: 97%
Requirements:
- Python ^3.7
- Poetry
- Optional: pre-commit
Required steps:
First, you must install dependencies by running:
poetry install
Spawn a virtualenv and activate it.
poetry shell
Start the application:
uvicorn main:app --reload --app-dir ire
pre-commit install
This projects uses pytest.
pytest --cov=ire --cov-report html tests
This projects relies on FastAPI as the web framework.
The reasoning for this decision were many:
- A micro-framework, fast to code, with a simple and easy to use routing system;
- Automatic interactive API documentation;
- The usage of Pydantic for data validation, and settings management using python type annotations.
This projects uses the pattern of "Pluggable Backends" to make an extensible recommendation engine.
All configuration right now is in the file ire.core.config
.
It is worth to mention two important ones:
- RISK_SCORE_RULES
- INELIGIBILITY_RULES
They are a list of string which contains the full path to the respective classes that implements the risk rules logic.
The advantage of this approach is to provide loose coupling between the risk service and the rules, making it easy to add/remove rules.
It also provides easier testing.
The below image summarizes this strategy:
Interactive documentation is available on: