A complete e-commerce API built with Django REST Framework, featuring product management, order processing, and user authentication.
- Project Overview
- Features
- Requirements
- Setup Instructions
- Configuration
- Running the Application
- Monitoring
- Security
- API Documentation
- Contributing
This project implements a full-featured e-commerce API with:
- Product management system
- Order processing
- User authentication
- Rate limiting
- Request monitoring
- API documentation
- RESTful API endpoints
- JWT authentication
- Request throttling
- Product management
- Order processing
- User management
- API documentation
- Request monitoring
- Docker containerization
- Python 3.9+
- Docker
- Docker Compose
- Git
git clone https://github.com/yourusername/yourrepository.git
cd yourrepositorycp .env.example .envUpdate .env with your configuration:
# Django Settings
SECRET_KEY=your_secure_key_here
DEBUG=False
ALLOWED_HOSTS=your_domain.com
# Database Settings
DATABASE_URL=mysql://user:password@localhost:3306/django-rsf
# Redis Settings
REDIS_URL=redis://localhost:6379/1
CELERY_BROKER_URL=redis://localhost:6379/1
CELERY_RESULT_BACKEND=redis://localhost:6379/1
# JWT Settings
ACCESS_TOKEN_LIFETIME=60 # minutes
REFRESH_TOKEN_LIFETIME=1440 # days# Build containers
docker-compose build
# Start containers in detached mode
docker-compose up -d# Create migrations
docker-compose exec api python manage.py makemigrations
# Apply migrations
docker-compose exec api python manage.py migrateThe project uses environment variables for configuration. The following variables are supported:
SECRET_KEY: Django secret keyDEBUG: Enable/disable debug modeALLOWED_HOSTS: Comma-separated list of allowed hostsDATABASE_URL: Database connection URLREDIS_URL: Redis connection URLCELERY_BROKER_URL: Celery broker URLCELERY_RESULT_BACKEND: Celery result backend URLACCESS_TOKEN_LIFETIME: JWT access token lifetime in minutesREFRESH_TOKEN_LIFETIME: JWT refresh token lifetime in days
# Start containers
docker-compose up
# Start Celery worker
docker-compose exec api celery -A backend worker --loglevel=info
# Start Celery beat (for scheduled tasks)
docker-compose exec api celery -A backend beat --loglevel=info# Build and start containers in detached mode
docker-compose up --build -dThe application provides several monitoring endpoints:
- API Documentation:
http://localhost:8000/docs/ - API Redoc:
http://localhost:8000/redoc/ - Celery Flower:
http://localhost:5555(default credentials:admin/admin) - Django Admin:
http://localhost:8000/admin/ - Silk Monitoring:
http://localhost:8000/silk/
- Environment Variables
- Store sensitive data in
.envfile - Never commit
.envto version control - Use secure values in production
- JWT Authentication
- Access tokens expire after 60 minutes
- Refresh tokens expire after 24 days
- Use HTTPS in production
- Rate Limiting
- Anonymous users: 2 requests/minute
- Authenticated users: Configurable
- Endpoint-specific limits available
- Database Security
- Use secure passwords
- Limit database access
- Regular backups
The API documentation is available at http://localhost:8000/docs/ and includes:
- API endpoints
- Request/response examples
- Authentication information
- Schema definitions
- Fork the repository
- Create a feature branch
- Implement changes
- Add tests
- Submit pull request
This project is licensed under the MIT License. See LICENSE for details.