To run this it can be directly installed by using python pip / pip3
$ pip3 install coupon_validating_system==1.0.0
├── coupon_validating_system
| └── data
| └── config.ini
| └── database
| └── __init__.py
| └── Connection.py
| └── Session.py
| └── entity
| └── __init__.py
| └── DatabaseModels.py
| └── Models.py
| └── exception
| └── __init__.py
| └── SQLException.py
| └── operations
| └── __init__.py
| └── Coupon.py
| └── CouponUsageLog.py
| └── User.py
| ├── __init__.py
| ├── CommonEnums.py
| ├── configuration.py
| ├── CouponValidatingSystem.py
| ├── ModuleLogger.py
├── MANIFEST.in
├── README.md
└── setup.py
- Import the database before going ahead with the execution.
- Database design document can be found here.
- Design document related to APIs and function can be found here.
- Postman collection can be found here.
- Video explanation of the project can be found here.
- Python3.9
- MySQL
- MySQL workbench
- Create a python-virtual environment using the below command for python3.9
python3.9 -m venv venv
- Navigate to the setup.py.
- Enter the below command to install all the required packages
pip install .
Below are the APIs implemented in the coupon_validating_system FastAPI service.
-
/create/user
- This API is used to create a user in the system. With the help of user id or username a user can make use of the coupon.
- cURL command
curl -X 'POST' \ 'http://localhost:5000/create/user?username=lavsharma' \ -H 'accept: application/json' \ -d ''
-
/read/all/user
- This API is used to read all the users that are present in the User table.
- cURL command
curl -X 'GET' \ 'http://localhost:5000/read/all/user/' \ -H 'accept: application/json'
-
/create/coupon
- This API is used to create a coupon in the system. With the help of the added configuration we will be able to add a limiter to our coupon so that a single coupon is not used ‘n’ or many times.
- cURL command
curl -X 'POST' \ 'http://localhost:5000/create/coupon' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "Coupon_Name": "holiday coupon", "Global_Total_Repeat_Count": 10000, "User_Total_Repeat_Count": 3, "User_Daily_Repeat_Count": 1, "User_Weekly_Repeat_Count": 1 }'
-
/read/all/coupon
- This API is used to read all the coupons from the Coupon table.
- cURL command
curl -X 'GET' \ 'http://localhost:5000/read/all/coupon/' \ -H 'accept: application/json'
-
/apply/coupon
- This API is used to apply the coupon for a particular user.
- This API will first validate the existence of the coupon and the adherence to repeat count configurations for the respective coupon.
- cURL command
curl -X 'POST' \ 'http://localhost:5000/apply/coupon' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "Coupon_Name": "holiday coupon", "Username": "lavsharma" }'