192

Game-shop

This project is an e-commerce website selling video games.

E-commerce website

This project is an e-commerce website selling video games.

Frameworks

We've decided to use Python and Django for our backend structure.

For the frontend, the framework in use is React with Bootstrap.

And for the API, the application in use is Postman.

API Endpoints

HTTP VerbsEndpointsAction
POST/products/postTo create a new product
POST/category/postTo create a new category
POST/shopping_cart/postTo create a new shopping cart
POST/discount/postTo create a new discount
GET/productsTo retrieve all products
GET/categoryTo retrieve all categories
GET/shopping_cartTo retrieve all shopping carts
GET/discountTo retrieve all discounts
PUT/products/int:id/updateTo edit the details of product
PUT/category/int:id/updateTo edit the details of a category
PUT/shopping_cart/int:id/updateTo edit the details of a shopping cart
PUT/discount/int:id/updateTo edit the details of a discount
DELETE/products/int:id/deleteTo delete a product
DELETE/category/int:id/deleteTo delete a category
DELETE/shopping_cart/int:id/deleteTo a shopping cart
DELETE/discount/int:id/deleteTo delete a discount

Installation

Get the project from git

git clone https://github.com/Mouayad2016/Game-shop-v.git
cd backend
pip install -r requirements.txt

Deployment

To deploy this project, write this in the backend in one terminal

cd frontend
npm install
 
cd backend
python manage.py runserver

And this in the frontend in another terminal

cd frontend
npm install
npm start

Usage/Examples We're using serializers instead of regular django form.

serializers.py

python
Copy code
from .models import Product
from rest_framework import serializers
 
class ProductSerializer(serializers.ModelSerializer):
    class Meta:
        model = Product
        fields = '__all__'
 

views.py

from .serializers import ProductSerializer
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
 
@api_view(['GET'])
def getProduct(request):
    try:
        product = Product.objects.all()
        serializer = ProductSerializer(product, many=True)
        return Response(serializer.data)
    except Exception as e:
        return Response(str(e), status=status.HTTP_400_BAD_REQUEST)