Skip to content

juliusmarkwei/ecommerce-server

Repository files navigation

Ecommerce Backend build with Django Rest Framework

A fully functional Ecommerce - Django Rest API project build and tested with restframework and deployed to vercel

The project was inspired by a random database schema of an ecommerce website I found on Azimutt gallery. Every piece of this project required alot of time and research since it was one of my beginner projects build with django. The activities involved in this project are as follows:

  1. Database model (table) development and configurations
  2. Writing the various API views for all the neccessary methods of each view
  3. Admin panel management configurations.
  4. Adding all the neccesary URL endpoints to for all the various views and thier methods. Not forgetting the admin panel too.
  5. Writing tests for all the views and thier methods. I also used Postman for testing as well.
  6. Including a documentation for the project through a python module called drf-yash by OpenAPI Initiative.
  7. Dockerized the Django Rest API whci I was able to successfully run on my local machine.
  8. Deploy the Django REST API to vercel

Images of the WebAPI

Prerequisites

    python3.10
    django
    djanfo-restframework
    docker (*optional)

Installation

  1. Clone this repository

    git clone https://github.com/juliusmarkwei/ecommerce-backend.git
    cd ecommerce-backend/
  1. Install all the neccessary packages/dependencies

    pip install -r requirements.txt
  1. In the root directory of the project, create a superuser to manage all the users of the application. be sure python is installed before you proceed with this stage.
    python3 manage createsuperuser
  1. Run the program with the following command

    python3 manage runserver

Run the program using Docker

Docker and Docker Compose should be installed on your system. For Docker installation guide: Get Docker and Install Docker Compose. Steps to run the application:

  1. Clone the Repository

    git clone https://github.com/juliusmarkwei/ecommerce-backend.git
    cd ecommerce-backend/
  1. Environment Variables

  • Create a .env preferrably in /main/settings/. Inside the .env add a SECRET_KEY and your database configurations of the database of your choice. You can generate a SECRET_KEY using the following code snippet:
    from django.core.management.utils import get_random_secret_key
    print(get_random_secret_key())
  • Add the following line printed above to the .env file:
    SECRET_KEY=your_secret_key_here
    DB_HOST=your_db_host
    DB_USER=your_db_user
    DB_PASSWORD=your_db_password
    DB_NAME=your_db_name
    DB_PORT=your_db_port
    DB_ENGINE=your_db_engine
  1. Build and Run with Docker Compose

    docker-compose up --build
  • This command builds the Docker image starts the containers as defined in the docker-compose.yml file.
  1. Access the Application

  • Once the application (container) is running, access the application running on port 8000 via http://localhost:8000.
  1. Additional Commands

  • Stopping the application: docker-compose down
  • Rebuilding the application after changes: docker-compose up --build

Get Involved

We welcome contributions and participation from the community to help make this e-commerce backend API even better! Whether you're looking to fix bugs, add new features, or improve documentation, your help is greatly appreciated. Here's how you can get involved:

Reporting Issues 🚩

If you encounter any bugs or issues, please report them using the Issues section of my GitHub repository. When reporting issues, please include:

  • A clear and descriptive title.
  • A detailed description of the problem, including steps to reproduce it.
  • Any relevant logs or error messages. Your environment details (e.g., Django version, DRF version, database, etc.).

Contributing Code 💁🏼

I love receiving pull requests from the community! If you have an improvement or a new feature you'd like to add, please feel free to do so 👍