The project will have following features-
- You need to create three types of users: admins, vendors, and customers.
- Weather conditions can be categorized into normal, hot, and cold.
- You need to make multiple APIs for these users.
- All users should be able to log in to the system using email & password through API. Use JWT token for authentication.
- Ensure you use the proper HTTP methods and codes while writing these APIs.
- You can use any free Weather API for this project. OpenWeather is a free weather API that you can use or you can use other free weather APIs too. Ensure you provide the required API keys and instructions on the project's Readme.md file.
- Vendors should be able to CRUD(Create, Read, Update, Delete) products with the quantity of the product.
- Admin should be able to CRUD product types. For example normal, hot, cold.
- Admin should be able to CRUD weather types. For example normal, hot, cold.
- Admin should be able to set the temperature range(high, low) for each weather type.
- Customers should be able to see all the products.
- Customers should be able to see product recommendations depending on the current weather condition grabbed from the weather API. For example, If the temperature is in the normal range, the user will be recommended the normal weather clothes.
- Customers should be able to search for products using the product's name or weather type.
** Write REST APIs to expose the information. ** Write test cases to test your code.
SRL | METHOD | ROUTE | FUNCTIONALITY | ACCESS |
---|---|---|---|---|
1 | POST | /api/token/ |
Login user | All users |
2 | POST | /api/token/refresh/ |
Refresh the access token | All users |
3 | POST | /api/token/verify/ |
Verify the validity of a token | All users |
SRL | METHOD | ROUTE | FUNCTIONALITY | ACCESS |
---|---|---|---|---|
4 | POST | /api/auth/customer/ |
Register new customer | Allow any |
5 | GET | /api/auth/customer/ |
List all customer | Adminuser |
6 | PUT | /api/auth/customer/uid/ |
Update customer | Adminuser |
7 | DELETE | /api/auth/customer/uid/ |
Delete customer | Adminuser |
SRL | METHOD | ROUTE | FUNCTIONALITY | ACCESS |
---|---|---|---|---|
8 | POST | /api/auth/vendor/ |
Register new vendor | Allow any |
9 | GET | /api/auth/vendor/ |
List all vendor | Adminuser |
10 | PUT | /api/auth/vendor/uid/ |
Update vendor | Adminuser |
11 | DELETE | /api/auth/vendor/uid/ |
Delete vendor | Adminuser |
SRL | METHOD | ROUTE | FUNCTIONALITY | ACCESS |
---|---|---|---|---|
12 | POST | /api/weather/ |
Add new weather type | Adminuser |
13 | GET | /api/weather/ |
List all weather type | Adminuser |
14 | PUT | /api/weather/id/ |
Edit weather type | Adminuser |
15 | DELETE | /api/weather/id/ |
Delete weather type | Adminuser |
16 | PATCH | /api/weather/id/ |
Update high and low temperature | Adminuser |
SRL | METHOD | ROUTE | FUNCTIONALITY | ACCESS |
---|---|---|---|---|
17 | GET | /api/product/ |
All product list | Any user |
18 | POST | /api/product/ |
Add new product | vendor |
19 | PUT | /api/product/pid/ |
Edit product | vendor |
20 | DELETE | /api/product/pid/ |
Delete product | vendor |
21 | GET | /api/search/?search=text |
Search product according to product title or weather type | Any user |
22 | PATCH | /api/product/id/ |
Update product type | Adminuser |
23 | GET | /api/recommendation/?location=city_name |
Product recommendation | Any one |
Python (3.9.0)
Django(4.1.1)
django rest framework (3.14.0 )
asgiref==3.5.2
autopep8==1.7.0
djangorestframework-simplejwt==5.2.0
pycodestyle==2.9.1
PyJWT==2.5.0
python-dotenv==0.21.0
pytz==2022.2.1
sqlparse==0.4.3
toml==0.10.2
SQLite
Open Weather Map API (https://openweathermap.org/api)
The first thing to do is to clone the repository:
$ https://github.com/MahmudJewel/DRF-Product-Recommendation-System
Create a virtual environment to install dependencies in and activate it:
$ cd DRF-Product-Recommendation-System
$ python -m venv venv
$ source venv/bin/activate
Then install the dependencies:
(venv)$ pip install -r requirements.txt
Note the (venv)
in front of the prompt. This indicates that this terminal
session operates in a virtual environment set up by virtualenv2
.
Once pip
has finished downloading the dependencies:
(venv)$ python manage.py migrate
(venv)$ python manage.py runserver 8000