Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/farazkhanfk7/buying-frenzy
https://github.com/farazkhanfk7/buying-frenzy
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/farazkhanfk7/buying-frenzy
- Owner: farazkhanfk7
- Created: 2021-07-20T10:19:06.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-07-22T04:19:24.000Z (over 3 years ago)
- Last Synced: 2024-12-03T22:13:36.952Z (about 2 months ago)
- Language: Python
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Buying Frenzy
## Problem Statement
Building a backend service and a database for a food delivery platform, with the given two raw datasets:
* dataset-1 contains a list of restaurants with their menus and prices, as well as their cash balances.
* dataset-2 contains a a list of users with their transaction history and cash balances.The task is to build an API server, with documentation and a backing relational database that will allow a front-end client to navigate through that sea of data easily, and intuitively.
The operations the front-end team would need you to support are:
* List all restaurants that are open at a certain datetime.
* List top y restaurants that have more or less than x number of dishes within a price range.
* Search for restaurants or dishes by name, ranked by relevance to search term.
* Process a user purchasing a dish from a restaurant, handling all relevant data changes in an atomic transaction.Couldn't add all features because of time shortage due to my work schedule.
**Docker Setup**
* `$ docker-compose build`
* `$ docker-compose up`**Administrator Login Credentials**
```
Username : adminPassword : 1234
```# Features Added
> List of features added.
## Command to set up your server and database using json dataset.
* Store restaurant and user data in restaurant.json and users.json respectively.
The database file `db.sqlite3` is already present in the directory.
```
python manage.py runserver
```1. If you want to recreate database again delete `db.sqlite3`.
2. Run the following commands to migrate json data to sqlite database.Commands :
```
python ./manage.py makemigrations glintspython manage.py migrate
python manage.py addrestaurant restaurant.json
python manage.py addusers users.json
```Also openingHours for restaurants which was given in a string as :
```
"openingHours": "Mon, Fri 2:30 pm - 8 pm / Tues 11 am - 2 pm / Weds 1:15 pm - 3:15 am / Thurs 10 am - 3:15 am / Sat 5 am - 11:30 am / Sun 10:45 am - 5 pm"
```Wrote helper functions to covert it to format below:
```
{
'Mon': ['15:45', '17:00'],
'Tues': ['11:30', '03:00'],
'Weds': ['15:45', '17:00'],
'Thurs': ['10:00', '23:30'],
'Fri': ['07:00', '09:45'],
'Sat': ['12:45', '13:15'],
'Sun': ['14:00', '19:00']
}
```
This helps in organising and insertion to database.
## List all restaurants that are open at a certain datetime.
> day `2` here means Tuesday.
```
http://127.0.0.1:8000/api/v1/restaurants/?day=2&time=12:00
```## List top y restaurants that have more or less than x number of dishes within a price range.
> show = 2 means "number of restaurants", price_gt = "price greater than" and price_lt="price less than"
```
http://127.0.0.1:8000/api/v1/restaurants/?show=2&price_gt=13&price_lt=14
```## Search for restaurants or dishes by name
> search = "name or keyword for filtering"
```
http://127.0.0.1:8000/api/v1/restaurants/?search=grill
```## Create an order
Send a POST request to `http://127.0.0.1:8000/api/v1/purchase/`
Request Body:
```
{
"purchaser" : 1, #id of buyer
"menu_bought" : 2 #id of the menu object
}
```Response :
```
{
"payment": {
"id": "order_Hba8AJ2IsIzCNP", #order_id generated by razorpay
"entity": "order",
"amount": 1064,
"amount_paid": 0,
"amount_due": 1064, #10.64 is interpreted as 1064 (1 INR = 100 Indian Paisa)
"currency": "INR",
"receipt": "e304ca5d-9582-492b-a275-4429b62463a6",
"offer_id": null,
"status": "created",
"attempts": 0,
"notes": [],
"created_at": 1626870697
},
"data": {
"purchase_id": "e304ca5d-9582-492b-a275-4429b62463a6",
"purchaser": 1,
"menu_bought": 2,
"restaurant": 1,
"dishName": "GAI TOM KA: CHICKEN IN COCONUT CREAM SOUP WITH LIME JUICE GALANGA AND CHILI",
"restaurantName": "'Ulu Ocean Grill and Sushi Lounge",
"transactionAmount": 10.64,
"transactionDate": "2021-07-21 12:31:36 PM",
"success": false
}
}
```# Payment
The payment feature is not fully implemented yet.
* A request will be made to `/purchase` endpoint.
* The response recieved can later be used (`/payment`) to verify signatures and process payment.# Things not yet implemented or future work. (Due to shortage of time)
* Developers will have to use Django API panel to test api for now because it uses django's inbuild backend.To authenticate using frontend or a client, something like JWT Authentication should be used.
* JWT based authentication can be setup using `django-simple-jwt` package.
* Charges will be deducted from `cashBalance` only after a payment is successful. It isn't implemented yet.
* Test cases are missing. I haven't added the test cases yet neither coverage report.
* The API isn't deployed yet on any server.