Coder Social home page Coder Social logo

louispuyo / ecommerce-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kkosiba/ecommerce-backend

0.0 0.0 0.0 178.77 MB

Django backend for eCommerce project

Python 97.10% HTML 0.96% Dockerfile 0.01% Shell 0.02% PowerShell 0.01% JavaScript 0.76% C++ 0.02% C 0.32% CSS 0.80% TeX 0.01%

ecommerce-backend's Introduction

ecommerce-backend

Django backend for eCommerce project

This project is built using Django REST Framework to provide the backend API for eCommerce project. The deployed API is available on Heroku. The frontend is available here.

Features

  1. Products API endpoint available at /api/products/.
  2. Custom user authentication using JSON Web Tokens. The API is available at /api/accounts/.
  3. Simple newsletter functionality: superuser can view the list of all subscribers in Django admin panel; any visitor can subscribe. The relevant API endpoint is available at /api/newsletter/.
  4. Stripe payments API endpoint available at /api/payments/.

Main requirements

  1. python 3.5, 3.6, 3.7
  2. Django 2.1.8
  3. PostgreSQL 11.1

This project also uses other packages (see requirements.txt file for details). For instance, tag support is provided by django-taggit and image processing is thanks to Pillow.

How to set up

Setup using Docker

The easiest way to get backend up and running is via Docker. See docs to get started. Once set up run the following command:

docker-compose up

This command takes care of populating products list with sample data.

It may take a while for the process to complete, as Docker needs to pull required dependencies. Once it is done, the application should be accessible at 0.0.0.0:8000.

Manual setup

Firstly, create a new directory and change to it:

mkdir ecommerce-backend && cd ecommerce-backend

Then, clone this repository to the current directory:

git clone https://github.com/ncunx/ecommerce-backend.git .

For the backend to work, one needs to setup database like SQLite or PostgreSQL on a local machine. This project uses PostgreSQL by default (see Django documentation for different setup). This process may vary from one OS to another, eg. on Arch Linux one can follow a straightforward guide here.

The database settings are specified in src/settings/local.py. In particular the default database name is eCommerceDjango, which can be created from the PostgreSQL shell by running createdb eCommerceDjango.

Next, set up a virtual environment and activate it:

python3 -m venv env && source env/bin/activate

Install required packages:

pip3 install -r requirements.txt

Next, perform migration:

python3 manage.py migrate --settings=src.settings.local

At this point, one may want to create a superuser account and create some products. One can also use sample data provided in products/fixtures.json by running:

python3 manage.py loaddata products/fixture.json --settings=src.settings.local

The backend is now ready. Run a local server with

python3 manage.py runserver --settings=src.settings.local

The backend should be available at localhost:8000.

In order to use Stripe payments one needs to create an account and obtain a pair of keys (available in the dashboard after signing in). These keys should replace STRIPE_SECRET_KEY and STRIPE_PUBLISHABLE_KEY values in src/settings/local.py.

To do

  1. Implement an API endpoint at /api/orders/ to accept POST request with order JSON from authenticated user, and GET requests from superuser (for further processing).
  2. Implement password recovery.
  3. Change REST API into Graphql api -> by Graphene and Hasura*
  4. Set endpoint for social media

ecommerce-backend's People

Contributors

kkosiba avatar louispuyo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.