Skip to content

A RESTful API for an advanced eCommerce platform built with Django and Django REST Framework (DRF). Includes JWT authentication, product management, cart and order systems, and full API documentation with Swagger and ReDoc.

License

Notifications You must be signed in to change notification settings

anis191/Django-REST-API

Repository files navigation

PhiMart - REST API for an eCommerce Platform

Django DRF JWT Payments

A robust RESTful API for an eCommerce platform built with Django REST Framework. PhiMart provides comprehensive endpoints to manage users, products, shopping carts, orders, and more, following modern API design practices.

🌐 Live Deployment

🚀 Key Features

  • JWT Authentication (Token-Based Security)
  • User Management: Registration, Login, and Profile Management
  • Product Catalog: Full CRUD Operations for Products
  • Advanced Search & Filters: Find products by category, price range, ratings, etc.
  • Shopping Cart System: Add/Remove items, manage quantities
  • Order Management: Create orders, view order history, and update status
  • Secure Payment Integration: Integrated with SSLCommerz for payment processing
  • Pagination: Optimized for large datasets
  • API Documentation: Interactive Swagger & ReDoc support
  • Social Auth Integration: Via social-auth-app-django

💳 Payment Feature

PhiMart now supports online payments using SSLCommerz.

🔑 Endpoints

Method Endpoint Description
POST /api/v1/payment/initiate/ Start a new payment session with SSLCommerz
POST /api/v1/payment/success/ Callback for successful payment – updates order status to Paid
POST /api/v1/payment/cancel/ Callback for canceled payment – marks order as Canceled
POST /api/v1/payment/fail/ Callback for failed payment – marks order as Failed

✅ Additional utility:

  • GET /api/v1/orders/has_ordered/<int:product_id>/ → Check if a user has purchased a specific product (useful for review eligibility).

Payment workflow ensures that only valid orders can be paid for, with secure redirection to SSLCommerz and proper callback handling.

🛠️ Technologies & Frameworks

  • Backend: Django 5.1.7, Django REST Framework 3.15.2
  • Authentication: JWT (SimpleJWT), Djoser
  • Database: SQLite (Default Django DB)
  • Image Handling: Pillow
  • API Docs: drf-yasg (Swagger/ReDoc)
  • Filtering: django-filter
  • Dependencies: See requirements.txt

📚 API Documentation

Explore the live interactive API documentation:

🔧 Installation & Local Setup

  1. Clone the repository

    git clone https://github.com/anis191/Django-REST-API.git
    cd PhiMart
  2. Create & activate virtual environment

    python -m venv .phi_env
     source .phi_env/Scripts/activate  # For Windows
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables
    Create a .env file in the project root and configure it as follows:

    # Django Secret
    SECRET_KEY=your_secret_key
    DEBUG=True
    
    # Database (PostgreSQL)
    DB_USER=your_db_user
    DB_PASSWORD=your_db_password
    DB_HOST=your_db_host
    DB_PORT=your_db_port
    DB_NAME=your_db_name
    
    # Cloudinary (for media uploads)
    CLOUD_NAME=your_cloud_name
    CLOUDINARY_API_KEY=your_api_key
    CLOUDINARY_API_SECRET=your_api_secret
    CLOUDINARY_URL=cloudinary://your_api_key:your_api_secret@your_cloud_name
    
    # Email Configuration
    EMAIL_HOST=your_email_host
    EMAIL_PORT=your_email_port
    EMAIL_USE_TLS=True
    EMAIL_HOST_USER=your_email_address
    EMAIL_HOST_PASSWORD=your_email_app_password
    
    # Frontend Integration
    FRONTEND_PROTOCOL=http
    FRONTEND_DOMAIN=localhost:5173
    FRONTEND_URL=http://localhost:5173
    
    # Backend URL
    BACKEND_URL=http://127.0.0.1:8000
    
    # Payment (SSLCommerz)
    SSLCommerz_STORE_ID=your_store_id
    SSLCommerz_STORE_PASSWORD=your_store_password
  5. Run migrations

    python manage.py migrate
  6. Start development server

    python manage.py runserver

🔒 Authentication

This API uses JWT Tokens for secure access.

📌 Endpoints

Base URL: http://127.0.0.1:8000/api/v1

  • POST /auth/jwt/create/ – Obtain tokens (Login)
  • POST /auth/jwt/refresh/ – Refresh tokens
  • POST /auth/users/ – User registration

📂 Project Structure

Django-REST-API/
 ├── PhiMart/ – Main Django project folder (Django settings and URLs)
 │ ├── __init__.py
 │ ├── asgi.py
 │ ├── settings.py
 │ ├── urls.py
 │ └── wsgi.py
 │
 ├── api/ – Implements all API endpoints (urls)
 │ ├── __init__.py
 │ ├── views.py
 │ ├── serializers.py
 │ ├── urls.py
 │ └── (other supporting files)
 │
 ├── fixtures/ – Contains demo data for database
 │ └── product_data.json – Used to load sample product data
 │
 ├── media/
 │ └── products/
 │  └── images/ – Stores uploaded product images
 │
 ├── order/ – Manages both order and cart-related features
 │ ├── models.py
 │ ├── views.py
 │ ├── serializers.py
 │ ├── urls.py
 │ └── (other supporting files)
 │
 ├── product/ – Handles product-related logic
 │ └── (models, views, serializers, urls, etc.)
 │
 ├── users/ – User authentication, profiles, registration
 │ └── (models, views, serializers, urls, etc.)
 │
 ├── .gitignore – Git ignore rules
 ├── manage.py – Django management script
 └── requirements.txt – Project dependencies

🤝 Contributing

Contributions help make this project better and are always welcome!

How to Contribute

  • ⭐ Star the repo
  • 🍴 Fork the project
  • 📥 Clone your fork
  • 💡 Create a feature branch: git checkout -b feature/awesome-feature
  • ✅ Commit your changes: git commit -m 'Add some feature'
  • 📤 Push your branch: git push origin feature/awesome-feature
  • 🛠️ Open a Pull Request

Ensure your code follows the project standards and passes all tests.

💻 Author

Anisul Alam
Full-Stack Developer | Django | React | PostgreSQL

LinkedIn Portfolio


About

A RESTful API for an advanced eCommerce platform built with Django and Django REST Framework (DRF). Includes JWT authentication, product management, cart and order systems, and full API documentation with Swagger and ReDoc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published