The modern eCommerce backend platform tailored for small to mid-sized businesses, offering seamless management of products, orders, and categories through a custom Unfold Admin dashboard. Built with Django REST Framework, it includes JWT-based cookie authentication, Razorpay integration for payments, and Cloudinary for media storage. The platform provides consistent API responses, robust error handling, and efficient pagination, all deployed on Vercel with CockroachDB as the database. It delivers an ideal solution for businesses seeking a reliable, maintainable, and scalable online presence.
The project utilizes a variety of modern technologies and services to ensure scalability, maintainability, nad performance. Below is a list of key technologies used and ALL OF THEM ARE EITHER FREE OR HAVE GREAT FREE TIER:
- Django REST Framework - A powerful toolkit for building Web APIs in Django.
- Unfold Admin - A package for customizing the Django admin interface with enhanced UX and UI.
- CockroachDB - A distributed SQL database that scales horizontally and provides high resilience.
- Cloudinary - A cloud-based media management platform that offers image and video optimization.
- Razorpay - A payment gateway that enables online transactions with secure and seamless payment processing.
- Vercel - A platform for deploying front-end applications and serverless functions seamlessly but supports Python runtime as well.
-
Clone the repository:
git clone https://github.com/izharxyz/revvona.git
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the environment variables:
# Create a .env file in the root directory and add the following variables: ENV=DEV SECRET_KEY="your_secret_key_here" ALLOWED_HOSTS="127.0.0.1,localhost,.cloudflarestorage.com,.vercel.app,your_custom_domain.com" COCKROACH_DB_NAME=defaultdb COCKROACH_DB_USER=user_name COCKROACH_DB_PASS=user_password COCKROACH_DB_HOST=free-tier.gcp-us-central1.cockroachlabs.cloud COCKROACH_DB_PORT=26257 CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret
-
If you are using CockroachDB, you can create a free-tier cluster on CockroachCloud and get the connection details from the CockroachCloud dashboard. Or you can use any other database of your choice like SQLite for quick setup.
-
Run the migrations:
python manage.py makemigrations python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
This project is a comprehensive, full-featured e-commerce solution designed for small to mid-sized businesses looking to establish or scale their online presence. The system focuses on ease of management for individual sellers and small teams, with a clear distinction between administrative and user functionalities. The platform is built to ensure high maintainability, scalability, and robust performance, all while maintaining a smooth user experience. Note: Product and category creation and management are restricted to administrators, making this platform ideal for businesses where a central admin oversees the product catalog.
The application leverages the powerful django-unfold package to deliver an intuitive and data-rich admin dashboard. This custom dashboard is designed to give administrators quick and actionable insights into business performance:
- Product Sales Chart: Visualizes sales data to show how individual products are performing.
- Monthly Revenue Chart: Provides a comprehensive view of monthly earnings, helping administrators track revenue trends over time.
- Order Performance Chart: Displays the total number of orders and highlights changes in order volumes to help gauge customer activity.
- Top 3 Best-Selling Products Cards: Highlights the three best-performing products, giving a quick glance at what's driving sales.
- New Customers Data Card: Summarizes recent customer sign-ups, offering insights into the growing customer base.
- New Products Data Card: Displays data on recently added products, keeping administrators informed of new inventory.
- New Categories Data Card: Provides a summary of new product categories, giving an overview of catalog diversification.
- Implements a secure authentication mechanism using JWT, with access and refresh tokens stored in secure HTTP-only cookies. This approach combines the stateless benefits of token-based authentication with enhanced security practices for user session management.
- All API endpoints return standardized response formats with custom helper functions for handling both successful and error states. This ensures uniformity across the entire platform, simplifies error management, and enhances the user experience on the front-end by providing clear feedback.
- Utilizes Cloudinary for all media storage, ensuring fast and reliable hosting of images and media assets. Cloudinary\u2019s built-in transformation tools allow for automatic optimization of media, improving page load times and overall performance.
- The application integrates Razorpay for seamless online payments, enabling secure transactions between customers and the platform. Additionally, a Cash on Delivery (COD) option is available, allowing for greater flexibility and accessibility for users who prefer offline payment methods.
- Enables users to leave reviews for products they have purchased, improving customer engagement and providing valuable feedback to store owners. Administrators maintain full control over reviews, allowing for easy moderation to ensure only relevant and appropriate content is displayed.
- All list-based views are paginated using a custom class designed for flexibility. It supports customizable page sizes and default sorting by the
created_at
field, ensuring recent entries are always surfaced first.
- Offers a full suite of cart and order management features, including adding, updating, and removing items from the cart. The cart logic ensures that the same product cannot be added multiple times, even by administrators.
- Orders are fully manageable, with the ability to update only the shipping address post-purchase, cancel, or return orders, ensuring users have the flexibility to manage their purchases.
- Products and categories can only be created, updated, or deleted by administrators. This centralized management approach is perfect for small businesses or individual sellers who need full control over their product catalog and inventory.
- Users can view and purchase products, but they cannot modify the product catalog, or become a seller on the platform.
- The application uses Whitenoise to serve static files in production environments, reducing server load and improving the overall performance of the website. This ensures that assets such as stylesheets and JavaScript files are delivered quickly and efficiently to users.
- Features robust error handling throughout the application, providing meaningful feedback for both successful and erroneous operations. This ensures smooth functionality and enhances the user experience by catching and resolving issues promptly.
- The project takes advantage of Django REST Framework\u2019s ViewSets, which provide a structured and maintainable way to handle API endpoints. ViewSets minimize code redundancy by automatically routing requests to the appropriate view methods based on HTTP methods, making it easier to scale and extend the application.
This documentation provides an overview of the API endpoints for the application, categorized by functionality. The API follows RESTful principles and is organized into various sections. Each section contains a list of endpoints, along with their descriptions, request bodies, and responses.
-
-
URL:
/api/v1/account/register/
-
Method:
POST
-
Description: Register a new user.
-
Request Body:
{ "username": "string", "email": "string", "password": "string" }
-
Responses:
201 Created
- User registered successfully.403 Forbidden
- User already logged in or username/email already exists.400 Bad Request
- Validation errors.
-
-
-
URL:
/api/v1/account/login/
-
Method:
POST
-
Description: Log in a user.
-
Request Body:
{ "username": "string", "password": "string" }
-
Responses:
200 OK
- Login successful.403 Forbidden
- User already logged in.404 Not Found
- User not found or invalid credentials.400 Bad Request
- Validation errors.
-
-
- URL:
/api/v1/account/logout/
- Method:
POST
- Description: Log out the currently logged-in user.
- Responses:
200 OK
- Logout successful.403 Forbidden
- User not logged in.
- URL:
-
- URL:
/api/v1/profile/
- Method:
GET
- Description: Retrieve the logged-in user's profile information.
- Responses:
200 OK
- User profile details.
- URL:
-
-
URL:
/api/v1/profile/update/
-
Method:
PUT
-
Description: Update the logged-in user's profile information.
-
Request Body:
{ "username": "string", "email": "string", "password": "string" }
-
Responses:
200 OK
- User profile updated successfully.
-
-
-
URL:
/api/v1/profile/delete/
-
Method:
DELETE
-
Description: Delete the logged-in user's profile.
-
Request Body:
{ "password": "string" }
-
Responses:
204 No Content
- User profile deleted successfully.
-
-
- URL:
/api/v1/addresses/
- Method:
GET
- Description: Retrieve a list of addresses for the logged-in user.
- Responses:
200 OK
- List of user addresses.
- URL:
-
-
URL:
/api/v1/addresses/create/
-
Method:
POST
-
Description: Create a new address for the logged-in user.
-
Request Body:
{ "name": "string", "phone_number": "string", "street": "string", "landmark": "string", "city": "string", "state": "string", "pin_code": "string" }
-
Responses:
201 Created
- Address created successfully.
-
-
- URL:
/api/v1/addresses/<int:pk>/
- Method:
GET
- Description: Retrieve a specific address by ID.
- Responses:
200 OK
- Address details.404 Not Found
- Address not found.
- URL:
-
-
URL:
/api/v1/addresses/<int:pk>/update/
-
Method:
PUT
-
Description: Update a specific user address.
-
Request Body:
{ "name": "string", "phone_number": "string", "street": "string", "landmark": "string", "city": "string", "state": "string", "pin_code": "string" }
-
Responses:
200 OK
- Address updated successfully.404 Not Found
- Address not found.
-
-
- URL:
/api/v1/addresses/<int:pk>/delete/
- Method:
DELETE
- Description: Delete a specific user address.
- Responses:
204 No Content
- Address deleted successfully.404 Not Found
- Address not found.
- URL:
-
- URL:
/api/v1/products/
- Method:
GET
- Description: Retrieve a list of all products.
- Responses:
200 OK
- List of products.
- URL:
-
- URL:
/api/v1/products/<int:pk>/
- Method:
GET
- Description: Retrieve details of a specific product by ID.
- Responses:
200 OK
- Product details.404 Not Found
- Product not found.
- URL:
-
- URL:
/api/v1/products/<int:product_id>/reviews/
- Method:
GET
- Description: Retrieve reviews for a specific product.
- Responses:
200 OK
- List of reviews.
- URL:
-
-
URL:
/api/v1/products/<int:product_id>/reviews/create/
-
Method:
POST
-
Description: Create a new review for a specific product.
-
Request Body:
{ "rating": "integer", "comment": "string" }
-
Responses:
201 Created
- Review created successfully.400 Bad Request
- Validation errors.
-
-
- URL:
/api/v1/reviews/<int:pk>/
- Method:
GET
- Description: Retrieve details of a specific review.
- Responses:
200 OK
- Review details.404 Not Found
- Review not found.
- URL:
-
-
URL:
/api/v1/reviews/<int:pk>/update/
-
Method:
PUT
-
Description: Update a specific review.
-
Request Body:
{ "rating": "integer", "comment": "string" }
-
Responses:
200 OK
- Review updated successfully.404 Not Found
- Review not found.
-
-
- URL:
/api/v1/reviews/<int:pk>/delete/
- Method:
DELETE
- Description: Delete a specific review.
- Responses:
204 No Content
- Review deleted successfully.404 Not Found
- Review not found.
- URL:
-
- URL:
/api/v1/categories/
- Method:
GET
- Description: Retrieve a list of all categories.
- Responses:
200 OK
- List of categories.
- URL:
-
- URL:
/api/v1/categories/featured/
- Method:
GET
- Description: Retrieve a list of featured categories.
- Responses:
200 OK
- List of featured categories.
- URL:
-
- URL:
/api/v1/categories/<slug:category_slug>/products/
- Method:
GET
- Description: Retrieve products in a specific category.
- Responses:
200 OK
- List of products in the category.
- URL:
-
- URL:
/api/v1/cart/
- Method:
GET
- Description: Retrieve the contents of the user's cart.
- Responses:
200 OK
- Cart details.
- URL:
-
-
URL:
/api/v1/cart/add/
-
Method:
POST
-
Description: Add a product to the user's cart.
-
Request Body:
{ "product": "integer", "quantity": "integer" }
-
Responses:
201 Created
- Product added to cart.
-
-
-
URL:
/api/v1/cart/<int:pk>/update/
-
Method:
PUT
-
Description: Update the quantity of a specific cart item.
-
Request Body:
{ "quantity": "integer" }
-
Responses:
200 OK
- Cart item updated successfully.404 Not Found
- Cart item not found.
-
-
- URL:
/api/v1/cart/<int:pk>/remove/
- Method:
DELETE
- Description: Remove a specific item from the cart.
- Responses:
204 No Content
- Cart item removed successfully.404 Not Found
- Cart item not found.
- URL:
-
- URL:
/api/v1/cart/clear/
- Method:
DELETE
- Description: Clear all items from the cart.
- Responses:
204 No Content
- Cart cleared successfully.
- URL:
-
- URL:
/api/v1/checkout/orders/
- Method:
GET
- Description: Retrieve a list of orders for the logged-in user.
- Responses:
200 OK
- List of orders.
- URL:
-
-
URL:
/api/v1/checkout/orders/create/
-
Method:
POST
-
Description: Create a new order. User must have items in the cart.
-
Request Body:
{ "shipping_address": "integer", "billing_address": "integer" }
-
Responses:
201 Created
- Order created successfully.
-
-
- URL:
/api/v1/checkout/orders/<int:pk>/
- Method:
GET
- Description: Retrieve details of a specific order.
- Responses:
200 OK
- Order details.404 Not Found
- Order not found.
- URL:
-
URL:
/api/v1/checkout/orders/<int:pk>/update/
-
Method:
PUT
-
Description: Update the shipping address of a specific order.
-
Request Body:
{ "shipping_address": "integer" }
-
Responses:
200 OK
- Order updated successfully.404 Not Found
- Order not found.
-
-
- URL:
/api/v1/checkout/orders/<int:pk>/cancel/
- Method:
PUT
- Description: Cancel a specific order.
- Responses:
200 OK
- Order canceled successfully.404 Not Found
- Order not found.
- URL:
-
- URL:
/api/v1/checkout/orders/<int:pk>/return/
- Method:
PUT
- Description: Return a specific order. Only initiates the return process.
- Responses:
200 OK
- Order returned successfully.404 Not Found
- Order not found.
- URL:
-
-
URL:
/api/v1/checkout/payments/create/
-
Method:
POST
-
Description: Create a new payment for an order.
-
Request Body:
{ "order": "integer", "method": "string" }
-
Responses:
201 Created
- Payment created successfully.
-
-
-
URL: /api/v1/checkout/payments/verify/
-
Method:
PUT
-
Description: Verify a payment. This endpoint is used by the only by the payment gateway (razorpay) to verify the payment status.
-
Request Body:
{ "payment": "string", "order": "integer" }
-
Responses:
200 OK
- Payment verified successfully.
-
-
- URL:
/api/v1/checkout/payments/<int:order_id>/
- Method:
GET
- Description: Retrieve payment details for a specific order.
- Responses:
200 OK
- Payment details.404 Not Found
- Payment not found.
- URL:
This project is licensed under the slightly modified MIT License - see the LICENSE file for details.
- Initial project setup
- User authentication and authorization
- Product and category management
- Cart and order management
- Payment integration with Razorpay
- Cloudinary integration for media storage
- Custom Unfold Admin dashboard
- API documentation
- Email notifications
- Oauth2 authentication
- Automated tests
- Scalability improvements
- Additional payment gateways
- Performance optimization