Skip to content

salogist/Supplement-Store-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Supplement Store API - E-Commerce Platform

A comprehensive e-commerce REST API and GraphQL backend built with Django REST Framework. The platform provides a complete solution for managing supplement products, user authentication, blog content, and order management with professional-grade features.

Overview

Supplement Store is a production-ready backend solution for e-commerce platforms specializing in supplement sales. The system is built with scalability, security, and maintainability as core principles.

Key Features

Core Functionality

  • Product Management: Complete CRUD operations for supplement products with category organization
  • User Authentication: JWT-based authentication with role-based access control (RBAC)
  • Blog System: Content management system for blog posts with status control
  • GraphQL API: Modern GraphQL endpoint for flexible querying alongside REST API
  • Admin Dashboard: Django admin interface for content and user management

Technical Features

  • Multi-API Support: Both REST and GraphQL interfaces
  • Security: Role-based permissions, custom authentication, CORS support
  • Database Design: Optimized relational schema with proper indexing
  • Scalability: Modular Django app architecture for horizontal scaling
  • Documentation: Complete API documentation with examples and schema visualization

Technology Stack

  • Backend Framework: Django 4.x+
  • API Frameworks: Django REST Framework, Graphene-Django
  • Database: SQLite (development) / PostgreSQL (production-ready)
  • Authentication: JWT (JSON Web Tokens)
  • Language: Python 3.8+

Project Structure

supplement_store/          # Main project configuration
├── settings.py           # Django settings and configuration
├── urls.py              # URL routing
├── schema.py            # GraphQL schema definition
└── graphql_middleware.py # GraphQL custom middleware

blog/                      # Blog management app
├── models.py            # Blog post models
├── views.py             # REST API views
├── views_generic.py     # Generic views
├── serializers.py       # API serializers
└── admin.py             # Admin configuration

products/                  # E-commerce products app
├── models.py            # Product and category models
├── views.py             # REST API views
├── views_generic.py     # Generic views
├── serializers.py       # API serializers
└── admin.py             # Admin configuration

users/                     # User management app
├── models.py            # User profile model
├── views.py             # REST API views
├── views_auth.py        # Authentication endpoints
├── authentication.py     # JWT authentication logic
├── permissions.py       # Custom permission classes
├── serializers.py       # API serializers
└── admin.py             # Admin configuration

API Endpoints

REST API Documentation

Comprehensive REST API documentation available in API_DOCUMENTATION.md

Main Endpoints:

  • POST /api/auth/register/ - User registration
  • POST /api/auth/login/ - User login
  • GET /api/products/ - List all products
  • POST /api/products/ - Create new product (admin only)
  • GET /api/blog/ - List blog posts
  • POST /api/blog/ - Create blog post (admin only)

GraphQL API

Interactive GraphQL playground available at /graphql/

Complete GraphQL documentation available in GRAPHQL_DOCUMENTATION.md

Example Query:

{
  products(first: 10) {
    edges {
      node {
        id
        name
        price
        category {
          name
        }
      }
    }
  }
}

Getting Started

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)

Installation

# Clone the repository
git clone [repository-url]
cd supplement

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run migrations
python manage.py migrate

# Create superuser for admin access
python manage.py createsuperuser

# Start development server
python manage.py runserver

The API will be available at http://localhost:8000/

Configuration

Environment Variables

Create a .env file in the project root:

SECRET_KEY=your-secret-key
DEBUG=False
ALLOWED_HOSTS=localhost,127.0.0.1
DATABASE_URL=postgresql://user:password@localhost/supplement_db

Database Setup

PostgreSQL is recommended for production:

# Using PostgreSQL (recommended for production)
pip install psycopg2-binary

Testing

Comprehensive test suite included:

# Run all tests
python manage.py test

# Run tests with coverage report
python manage.py test --verbosity=2

Test files are located in each app's tests.py file.

API Documentation Files

Production Deployment

Recommended Setup

  • Web Server: Gunicorn or uWSGI
  • Reverse Proxy: Nginx
  • Database: PostgreSQL
  • Caching: Redis
  • Task Queue: Celery (for async operations)

Deployment Checklist

python manage.py collectstatic
python manage.py check --deploy

Performance & Quality

  • Clean, maintainable code with proper separation of concerns
  • Comprehensive error handling and validation
  • RESTful API design principles
  • GraphQL best practices implementation
  • Modular and extensible architecture

Future Enhancement Opportunities

  • Payment gateway integration (Stripe, PayPal)
  • Email notifications and verification
  • Order tracking and management
  • Advanced product filtering and search
  • Review and rating system
  • Wishlist functionality
  • Analytics and reporting dashboard

Business Benefits

Scalable: Modular Django architecture supports growth
Maintainable: Clean code structure and comprehensive documentation
Flexible: Both REST and GraphQL APIs for diverse client needs
Secure: Industry-standard authentication and permission system
Production-Ready: Optimized for deployment and monitoring


Academic Project

This is an educational project developed as part of academic coursework. It demonstrates professional software engineering practices, including API design, authentication, database modeling, and REST/GraphQL implementation patterns.

Learning Outcomes

  • Full-stack web application development
  • RESTful and GraphQL API design
  • Database design and optimization
  • User authentication and authorization
  • Software testing and quality assurance
  • API documentation standards

Support & Contact

For questions or issues, please refer to the project documentation or contact the development team.

License

[Specify your license here]

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors