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.
- π Base URL β https://phimart-ecommerce-wheat.vercel.app/
- π API Root β https://phimart-ecommerce-wheat.vercel.app/api/v1/
- 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
PhiMart now supports online payments using SSLCommerz.
| 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.
- 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
Explore the live interactive API documentation:
- Swagger UI: https://phimart-ecommerce-wheat.vercel.app/swagger/
- ReDoc: https://phimart-ecommerce-wheat.vercel.app/redoc/
-
Clone the repository
git clone https://github.com/anis191/Django-REST-API.git cd PhiMart -
Create & activate virtual environment
python -m venv .phi_env source .phi_env/Scripts/activate # For Windows
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
Create a.envfile 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
-
Run migrations
python manage.py migrate
-
Start development server
python manage.py runserver
- API Access: http://127.0.0.1:8000/ (Localhost only)
This API uses JWT Tokens for secure access.
Base URL: http://127.0.0.1:8000/api/v1
POST /auth/jwt/create/β Obtain tokens (Login)POST /auth/jwt/refresh/β Refresh tokensPOST /auth/users/β User registration
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
Contributions help make this project better and are always welcome!
- β 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.
Anisul Alam
Full-Stack Developer | Django | React | PostgreSQL