Challenge Overview
Challenge Objectives
-
Python Rest API development using Flask framework - refactor existing codebase
NOTE: The review/appeals timeline is shorter than usual - pay attention to the deadlines
Project Background
-
Our client has developed a specific method of converting electrical properties
-
All the calculations are currently in an Excel workbook - our goal is to create an API to process the data, i.e. move the calculations from Excel into the codebase.
-
In this challenge, we’ll refactor the api endpoints and remove all database related features
Technology Stack
-
Python 3
-
Flask
-
Flask-Restplus
Code access
The base code is available in the forums.
Individual requirements
-
Remove all database related features
Goal here is to make the calculations backend stateles, ie remove all the db related features - importing data, updates, searching, etc. Remove all the db models and all api endpoints except for one POST /calculation endpoint (that is the current POST /data endpoint) that takes the input parameters, calculates and returns both the inputs and outputs (keep same request response format). Update RestPlus models and test suite. -
Return charts in the response
Current API saves the output charts in the db and only returns the resource ids. Update the behavior so that the charts are returned as base64 encoded images in the calculation outputs. Add two query parameters to the POST /calculation endpoint: charts:true/false (controls weather the base64 image will be returned) and format:png/svg (format of the chart).
General requirements
-
Unit tests are required for all endpoints.
-
All endpoints should be annotated with Swagger annotations and swagger UI should be served by the API.
-
All endpoint routes should be prefixed with “API_NAME_”
-
All configuration parameters should be extracted to a common settings module. All environment variables have to be prefixed with “API_NAME_”
-
Please make sure your code is well-documented. Use the following style guides Google Python Style Guide, Python Style Guide, and Docstring Conventions. Code linter is required. Please make sure it is well-engineered but not over-engineered (YAGNI and KISS) solution. We're looking for well-structured and tested code. Well-structured code follows good design principles like the SOLID principles and well-tested code has comprehensive unit tests.
-
The code should be implemented using Python3 only.
-
Use matrix operations with numpy/pandas where possible
What To Submit
-
All source code
-
Deployment guide
-
Postman collection containing sample calls for all endpoints (success/failure)
-
Verification guide - how to set up the environment, start the API, and verification screenshots
-
The unit tests coverage report