A RESTful API backend for an eCommerce platform, built with Django and Django REST Framework. It supports product management, user auth via JWT, newsletter subscriptions, and Stripe payments integration.
- Overview
- Features
- Tech Stack & Dependencies
- Architecture
- Installation & Setup
- Usage
- Testing
- Deployment
- Contributing
- License
This backend serves as the foundation of an eCommerce application. Powered by Django REST Framework, it provides secure APIs for managing:
- Products
- User registration/login via JSON Web Tokens (JWT)
- Newsletter subscription
- Stripe-based checkout process ([github.com][1])
- 🛒 Products API: List, retrieve, create, update, delete products
- 🔐 JWT Authentication: Secure endpoints with token-based auth
- 📬 Newsletter: Subscribe via API; manage subscribers in the admin panel ([github.com][1])
- 💳 Stripe Payments: Full checkout flow with secure payment processing ([github.com][2])
- Python 3.13
- Django 5.x
- Django REST Framework
- PostgreSQL (recommended)
- Stripe SDK
- django‑taggit for tagging, Pillow for image handling ([github.com][1])
src/
├── accounts/ # JWT auth, user registration/login
├── products/ # Product CRUD and filtering
├── newsletter/ # Newsletter subscription API
├── payments/ # Stripe checkout logic
├── core/ # Common utils and base settings
└── settings/ # Django settings modules
- Each Django app has its models, serializers, views, and URLs.
- JWT auth protects endpoints, with permissions for user and admin roles.
- Stripe integration occurs within the
payments/app, called during order processing.
- Python 3.13
- Docker (optional)
- PostgreSQL
-
Clone the repo
git clone https://github.com/MisaghMomeniB/Django-Ecommerce-BackEnd.git cd Django-Ecommerce-BackEnd -
Create environment file
.env:DJANGO_SECRET_KEY=your_secret DJANGO_SETTINGS_MODULE=src.settings.dev DATABASE_URL=postgres://user:pass@localhost:5432/dbname STRIPE_SECRET_KEY=sk_test_xxx STRIPE_PUBLISHABLE_KEY=pk_test_xxx
-
Install dependencies:
pip install -r requirements/base.txt
-
Migrate database:
python manage.py migrate
-
Run development server (local):
python manage.py runserver
Or use Docker:
docker-compose up -d- Products Endpoint:
GET /api/products/,POST /api/products/,PUT/PATCH /api/products/<id>/, etc. - Authentication:
POST /api/accounts/token/to get JWT tokens. - Newsletter:
POST /api/newsletter/to subscribe. - Payment:
POST /api/payments/create-checkout-session/to initiate Stripe checkout.
Explore the DRF browsable API when running in DEBUG mode.
Run the test suite using:
python manage.py testIncludes tests for serializers, views, and payment workflows.
- Production-ready with Docker files and
gunicorn.conf.pyfor WSGI deployment ([github.com][1]) - Easily deployable to Kubernetes or any container platform.
- Use
production.dockerfileand.envwith production settings (DB, Stripe keys, AWS, etc.) ([github.com][1])
Contributions are welcome! To contribute:
- Fork the repository
- Create a branch (
feature/...) - Make your changes with clear commit messages
- Submit a Pull Request
Distributed under the MIT License. Feel free to use, modify, and distribute.
- Add order history & user cart management
- Integrate webhooks for Stripe events
- Improve permissions (e.g., admin-only endpoints)
- Add Swagger/OpenAPI documentation