Skip to content

GrewalCreator/E-Commerce-Webapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E-Commerce Web Application

A RESTful e-commerce web application featuring products, reviews, a server-side shopping cart, and checkout functionality.

This project uses a Django + Django REST Framework backend and a vanilla HTML/CSS/JavaScript frontend.
CRUD operations are implemented using a mix of DRF generic class-based views and APIView for transactional logic such as cart management and checkout.

Project Demo

Testing / Sample Data

If you are using a custom products.json, place it in:

django/mystore/data/

Ensure the file follows the same structure and filename as the initially provided products.json.
This file is used to seed the database with initial product data.


API Endpoints

All endpoints are prefixed with /api/.


Create a Product

  • POST /api/products/

Body Example:

{
  "name": "Fireproof Blanket",
  "price": 19.99,
  "quantity": 0,
  "length": "10.00",
  "width": "8.00",
  "height": "1.00",
  "description": "For small kitchen fires."
}

List Products

  • GET /api/products/

Search Products by Name

  • GET /api/products/?search=<name>

Example:

/api/products/?search=blanket

Filter Stock

  • GET /api/products/?in_stock=true
  • GET /api/products/?in_stock=false

Get Product by ID

  • GET /api/products/<id>/

Example:

/api/products/1/

Update Product

  • PUT /api/products/<id>/

Body Example:

{
  "name": "Fireproof Blanket",
  "price": 24.99,
  "quantity": 5,
  "length": "10.00",
  "width": "8.00",
  "height": "1.00",
  "description": "Updated description."
}

Delete Product

  • DELETE /api/products/<id>/

Add a Review

  • POST /api/products/reviews/

Body Example:

{
  "user": 1,
  "product": 1,
  "rating": 9,
  "comment": "Works great!"
}

Get Product Reviews

  • GET /api/products/reviews/?product_id=<id>

Example:

/api/products/reviews/?product_id=1

View Cart

  • GET /api/cart/

Add Item to Cart

  • POST /api/cart/items/

Body Example:

{
  "product_id": 1,
  "quantity": 2
}

Update Cart Item Quantity

  • PATCH /api/cart/items/<item_id>/

Body Example:

{
  "quantity": 5
}

Remove Cart Item

  • DELETE /api/cart/items/<item_id>/delete/

Checkout

  • POST /api/orders/checkout/

Body Example:

{
  "purchaser_name": "Gurtej Grewal",
  "items": [
    { "product_id": 1, "quantity": 2 },
    { "product_id": 2, "quantity": 1 }
  ]
}

List Orders

  • GET /api/orders/

Get Individual Order

  • GET /api/orders/<id>/

Example:

/api/orders/1/

Installation

Prerequisites

  • Docker & Docker Compose installed
  • Python 3.10+ (for local development)

Setup

# Clone the repository
git clone https://github.com/GrewalCreator/E-Commerce-Webapp.git
cd E-Commerce-Webapp

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate

# Install backend dependencies
pip install -r django/requirements.txt

# Run migrations
cd django
python manage.py check
python manage.py makemigrations mystore
python manage.py migrate
python manage.py createsuperuser

Run with Docker

docker-compose up --build

Visit:

http://localhost:8080

Stopping the Application

docker-compose down
deactivate

Author: Gurtej Grewal

About

A generic E-commerce Webapp configured via json

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors