Skip to content

Andrew-oduola/shoplit

Repository files navigation

Shoplit API Documentation

Overview

The Shoplit API is a backend service for an e-commerce platform. It allows users to interact with product data, categories, and subcategories via RESTful endpoints. The API is built using Django and Django REST Framework (DRF).

Deployed Version: https://shoplit.onrender.com/

Database Schema

Postman Collection

Features

User Management

  • User Registration: Create user accounts.
  • User Authentication: Login/logout functionality with token-based authentication.
  • Password Reset: Reset forgotten passwords via email.
  • User Profiles: View and update user information.

Product Management

  • Product Listings: Fetch a list of all available products.
  • Product Details: Retrieve detailed information for a specific product.
  • Category & Subcategory Management: Filter products by category or subcategory.
  • Product Search: Search for products by name or description.
  • Product pagination and caching: For faster performance

Cart Management

  • Add to Cart: Add products to a shopping cart.
  • View Cart: Retrieve items in the user’s cart.
  • Update Cart: Adjust quantities of products in the cart.
  • Remove from Cart: Delete items from the cart.

Order Management

  • Place Orders: Checkout and place orders for products in the cart.
  • Order History: View all orders placed by a user.
  • Order Details: Fetch detailed information about a specific order.

Payment Integration

  • Payment Gateway: Integration with paystack.
  • Order Payment Status: Update and track payment status of orders.

Wishlist

  • Add to Wishlist: Save products for later purchase.
  • View Wishlist: Fetch the user’s wishlist items.
  • Remove from Wishlist: Delete items from the wishlist.

Reviews and Ratings

  • Product Reviews: Allow users to leave reviews and ratings for products.
  • Review Moderation: Approve or reject reviews for public display.
  • Review Display: Fetch all reviews for a specific product.

Admin Features

Notifications

  • Order Status Updates: Notify users about order status changes via in app and SMS.
  • Promotional Notifications: Send updates about sales, discounts, or new arrivals.

SMS Notifications

  • Order Updates: Notify users via SMS about their order status (e.g., confirmed, shipped, delivered).
  • Promotions: Send promotional offers and updates directly to users' phones.

Prerequisites

To run the API locally, ensure you have the following installed:

  • Python 3.9+
  • Django
  • Django REST Framework
  • MySQL (or any database supported by Django)
  • Use the requirements.txt file

Installation

  1. Clone the repository:

    git clone https://github.com/Andrew-oduola/shoplit.git
    cd shoplit
  2. Create and activate a virtual environment:

    python -m venv env
    source env/bin/activate  # On Windows, use env\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Configure environment variables:

    • Create a .env file in the project root.
    • Add the following variables:
      SECRET_KEY=your_secret_key
      DEBUG=True
      ALLOWED_HOSTS=localhost, 127.0.0.1
      DATABASE_URL=your_database_url
  5. Run database migrations:

    python manage.py migrate
  6. Start the development server:

    python manage.py runserver

API Endpoints

Products

List All Products

GET /api/products/

Response:

[
    {
        "id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
        "name": "Product Name",
        "description": "Product description",
        "price": 29.99,
        "category": "Category Name",
        "subcategory": "Subcategory Name"
    },
    ...
]

Retrieve a Single Product

GET /api/products/<id>/

Response:

{
    "id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
    "name": "Product Name",
    "description": "Product description",
    "price": 29.99,
    "category": "Category Name",
    "subcategory": "Subcategory Name"
}

Create a Product

POST /api/products/

Request:

{
    "name": "New Product",
    "description": "New product description",
    "price": 19.99,
    "category": "Category Name",
    "subcategory": "Subcategory Name"
}

Response:

{
    "id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
    "name": "New Product",
    "description": "New product description",
    "price": 19.99,
    "category": "Category Name",
    "subcategory": "Subcategory Name"
}

Update a Product

PUT /api/products/<id>/

Request:

{
    "name": "Updated Product",
    "description": "Updated product description",
    "price": 24.99
}

Response:

{
    "id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
    "name": "Updated Product",
    "description": "Updated product description",
    "price": 24.99
}

Delete a Product

DELETE /api/products/<id>/

Response:

{
    "message": "Product deleted successfully."
}

### Categories
#### List All Categories
**GET** `/api/categories/`

Response:
```json
[
    {
        "id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
        "name": "Category Name",
        "description": "Category description"
    },
    ...
]

Create a Category

POST /api/categories/

Request:

{
    "name": "New Category",
    "description": "New category description"
}

Response:

{
    "id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
    "name": "New Category",
    "description": "New category description"
}

Subcategories

List All Subcategories

GET /api/subcategories/

Response:

[
    {
        "id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
        "name": "Subcategory Name",
        "category": "Category Name"
    },
    ...
]

Deployment

To deploy on Heroku:

  1. Log in to Heroku:

    heroku login
  2. Create a Heroku app:

    heroku create shoplit
  3. Add Heroku Postgres:

    heroku addons:create heroku-postgresql:hobby-dev
  4. Push to Heroku:

    git push heroku main
  5. Run migrations on Heroku:

    heroku run python manage.py migrate
  6. Open the app:

    heroku open

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature-name.
  3. Commit your changes: git commit -m 'Add new feature'.
  4. Push to your branch: git push origin feature-name.
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


About

An E-commerce API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published