shopify-api-clone
This is part of the technical interview for backend developer candidates for Coop Commerce.
Setup
- Clone this repo and
cd
into it - Create the virtual environment:
python3 -m venv venv
- Enter the virtual environment:
source venv/bin/activate
- Download the necessary packages:
pip install -r requirements.txt
- Run migrations:
python manage.py migrate
- Run the server:
python manage.py runserver
- Run
curl 'http://127.0.0.1:8000/api/ping/' | python -mjson.tool
. If it works, you should see{ "status": "pong" }
Exercise
We want to understand your proficiency with Django, Django REST Framework, and backend API development.
Please write an API that mimics the shopify API using the following specifications:
- There are stores and each one has a set of products.
- There are users, some of whom have bought products.
- There are tags (e.g. 'women over 30', 'men under 25', etc). They are applied to stores to specify their category (only one can be set). They are also applied to a user to specify their preferences (many can be applied).
- No frontend code required, only backend.
- No auth code needed; assume anonymous users can do everything.
- No need to deploy this anywhere. Run it locally.
Test cases
POST
/api/stores creates a store.POST
/api/users creates a user.POST
/api/purchases creates a purhase.GET
/api/stores/1 retrieves a store. Each store has a list of products and a category.GET
/api/users/1 retrieves a user. Each user has a list of preferences.GET
/api/purchases/1 retrieves a purhase.
Procedure
Create a branch, write your code, and submit a PR with the output for the test cases above.
Bonus
Suppose we wanted to give recommendations to users on what they should buy in the future based off what they've bought in the past. Draft some pseudo-code to describe how you'd do this.