Skip to content

MisaghMomeniB/django-ecommerce-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛍️ Django Ecommerce Backend

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.


📋 Table of Contents

  1. Overview
  2. Features
  3. Tech Stack & Dependencies
  4. Architecture
  5. Installation & Setup
  6. Usage
  7. Testing
  8. Deployment
  9. Contributing
  10. License

💡 Overview

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])

✅ Features

  • 🛒 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])

🛠️ Tech Stack & Dependencies

  • Python 3.13
  • Django 5.x
  • Django REST Framework
  • PostgreSQL (recommended)
  • Stripe SDK
  • django‑taggit for tagging, Pillow for image handling ([github.com][1])

🧭 Architecture

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.

⚙️ Installation & Setup

Requirements

  • Python 3.13
  • Docker (optional)
  • PostgreSQL

Steps

  1. Clone the repo

    git clone https://github.com/MisaghMomeniB/Django-Ecommerce-BackEnd.git
    cd Django-Ecommerce-BackEnd
  2. 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
  3. Install dependencies:

    pip install -r requirements/base.txt
  4. Migrate database:

    python manage.py migrate
  5. Run development server (local):

    python manage.py runserver

Or use Docker:

docker-compose up -d

🚀 Usage

  • 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.


🧪 Testing

Run the test suite using:

python manage.py test

Includes tests for serializers, views, and payment workflows.


🚢 Deployment

  • Production-ready with Docker files and gunicorn.conf.py for WSGI deployment ([github.com][1])
  • Easily deployable to Kubernetes or any container platform.
  • Use production.dockerfile and .env with production settings (DB, Stripe keys, AWS, etc.) ([github.com][1])

🤝 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a branch (feature/...)
  3. Make your changes with clear commit messages
  4. Submit a Pull Request

📄 License

Distributed under the MIT License. Feel free to use, modify, and distribute.


🧩 What's Next?

  • Add order history & user cart management
  • Integrate webhooks for Stripe events
  • Improve permissions (e.g., admin-only endpoints)
  • Add Swagger/OpenAPI documentation

Releases

No releases published

Packages

 
 
 

Contributors