Django backend for eCommerce project
This project is built using Django REST Framework to provide the backend API for the eCommerce project. The frontend is available here.
- Products API endpoint available at
/api/products/
. - Custom user authentication using JSON Web Tokens. The API is available
at
/api/accounts/
. - 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/
. - Stripe payments API endpoint available
at
/api/payments/
.
python
>=3.13,<3.14Django
>=5.1,<5.2PostgreSQL
16+
This project also uses other packages (see requirements/base.txt
file for
details). For instance, tag support is provided by
django-taggit and image processing is
thanks to Pillow.
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 the 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 available
at http://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 need to be set in a .env
file, see the Deployment
section below
for the example contents of such file.
There is a production-ready Docker image production.dockerfile
available.
It can be deployed in a Kubernetes cluster for example.
To build it manually:
docker build --file production.dockerfile .
To run this image, you need to set the environment correctly. You can use a .env
file like this:
PROJECT_ENVIRONMENT=production
# Django settings
DJANGO_SECRET_KEY="f41z(gp#mm7ktjo1bfux-n*0!mlti$9d1@k_sws@&kl*@tfi21"
DJANGO_SETTINGS_MODULE=src.settings.defaults
# Database settings
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_HOST=
POSTGRES_PORT=5432
# Stripe
STRIPE_SECRET_KEY=
STRIPE_PUBLISHABLE_KEY=
# AWS
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_STORAGE_BUCKET_NAME=
You can then run the image like this:
docker run --env-file .env -d <image-name>