WasteWorth – Waste Recycling Management Platform
WasteWorth is a Django-based waste recycling management platform that leverages the Django REST Framework, OTP-based authentication, and JWT for secure API authentication. It provides a comprehensive API with endpoints across multiple apps:
- Users – User registration, login, OTP verification, and JWT-based authentication.
- Wallet – Wallet management, transactions, fund transfers, and withdrawals.
- Marketplace – Connect waste disposers with recyclers for efficient waste collection.
- Payments – Paystack integration for secure escrow payments and payouts.
- OTP – OTP generation, verification, and management for secure operations.
- Referral – User referral system with rewards tracking.
- Contact – Contact form and automated email notifications.
WasteWorth is a robust platform that connects waste disposers with recyclers, promoting environmental sustainability while providing financial incentives. The platform addresses waste management challenges by offering secure payments, real-time tracking, and a reward-based ecosystem. This API contains User Authentication, Wallet Operations, Marketplace Transactions, and Payment Integration.
Live Project https://www.wasteworth.com.ng/
Postman API Documentation https://documenter.getpostman.com/view/31085830/2sB3QDxDi5#intro.
Ensure the following tools are installed:
- Python (>= 3.9 recommended)
- pip (Python package manager)
- Git
- Virtual environment tool (e.g.,
venvorvirtualenv) - PostgreSQL (for production) or SQLite (for development)
- Redis (for caching and background tasks)
- Clone the repository:
git clone https://github.com/InternPulse/wasteworth-backend-django.git
cd wasteworth-backend-django- Set up a virtual environment:
Windows:
python -m venv venv
venv\Scripts\activatemacOS/Linux:
python -m venv venv
source venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
Create a .env file in the project root directory and configure the following variables:
# Django Settings
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
# Database Configuration
USE_POSTGRES=False # Set to True for PostgreSQL, False for SQLite
# PostgreSQL Settings (if USE_POSTGRES=True)
DATABASE_NAME=wasteworth_db
DATABASE_USER=your_db_user
DATABASE_PASSWORD=your_db_password
DATABASE_HOST=localhost
DATABASE_PORT=5432
SSL_MODE=disable
# Email Configuration
EMAIL_BACKEND=utils.email_backend.SMTPBackendWithTimeout
EMAIL_HOST=smtp-relay.brevo.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=[email protected]
EMAIL_HOST_PASSWORD=your-smtp-password
DEFAULT_FROM_EMAIL=[email protected]
EMAIL_TIMEOUT=120
# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
# Paystack Integration
PAYSTACK_SECRET_KEY=your-paystack-secret-key
PAYSTACK_PUBLIC_KEY=your-paystack-public-key
PAYSTACK_WEBHOOK_SECRET=your-webhook-secret
# Frontend URL
FRONTEND_URL=http://localhost:3000
# CORS Settings
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
# Cloudinary (Optional - for image uploads)
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret- Run database migrations:
python manage.py migrate- Create a superuser (optional):
python manage.py createsuperuser- Start Redis server (in a separate terminal):
redis-server- Run the development server:
python manage.py runserverThe API will be available at http://127.0.0.1:8000/
Base URL: http://127.0.0.1:8000/api/v1/
| Endpoint | Method | Description | Auth Required |
|---|---|---|---|
/users/signup/ |
POST | Register a new user (disposer/recycler) | No |
/users/login/ |
POST | Login and obtain JWT tokens | No |
/users/logout/ |
POST | Logout user | Yes |
/users/forgotPassword/ |
POST | Request password reset OTP | No |
/users/resetPassword/ |
POST | Reset password using OTP | No |
/users/updatePassword/ |
PATCH | Update user password (requires OTP) | Yes |
/users/user-dashboard/ |
GET | Get user dashboard statistics | Yes |
/users/update-user/ |
PATCH | Update user profile information | Yes |
/auth/token/refresh/ |
POST | Refresh JWT access token | No |
| Endpoint | Method | Description | Auth Required |
|---|---|---|---|
/otp/send/ |
POST | Send OTP to email or phone | No |
/otp/verify/ |
POST | Verify OTP code | No |
| Endpoint | Method | Description | Auth Required |
|---|---|---|---|
/wallet/balance/ |
GET | Get current wallet balance | Yes |
/wallet/transactions/ |
GET | Get transaction history | Yes |
/wallet/fund/ |
POST | Add funds to wallet | Yes |
/wallet/transfer/ |
POST | Transfer funds to another user | Yes |
/wallet/withdraw/ |
POST | Withdraw funds to bank account | Yes |
| Endpoint | Method | Description | Auth Required |
|---|---|---|---|
/payments/initialize/ |
POST | Initialize Paystack payment | Yes |
/payments/verify/ |
GET | Verify payment transaction | Yes |
/payments/webhook/ |
POST | Paystack webhook handler | No |
| Endpoint | Method | Description | Auth Required |
|---|---|---|---|
/contact/ |
POST | Submit contact form message | No |
Backend Framework:
- Django 5.2.6
- Django REST Framework
Authentication & Security:
- JWT (djangorestframework-simplejwt)
- OTP-based verification
- django-axes (brute force protection)
- Rate limiting
Database:
- PostgreSQL (production)
- SQLite (development)
Caching & Background Tasks:
- Redis
- django-rq
Payment Processing:
- Paystack
Email Services:
- Custom async email backend
- SMTP integration (Brevo/SendinBlue recommended)
Cloud Storage:
- Cloudinary (image uploads)
Other Libraries:
- python-decouple (environment variables)
- django-cors-headers (CORS management)
wasteworth-backend-django/
├── apps/
│ ├── contact/ # Contact form functionality
│ ├── core/ # Core utilities and health checks
│ ├── listings/ # Waste listings management
│ ├── marketplace/ # Marketplace transactions
│ ├── notifications/ # Notification system
│ ├── otp/ # OTP generation and verification
│ ├── payments/ # Paystack payment integration
│ ├── referral/ # Referral system
│ ├── users/ # User authentication and management
│ └── wallet/ # Wallet and transaction management
├── config/
│ ├── settings.py # Django settings
│ ├── urls.py # Main URL configuration
│ └── wsgi.py # WSGI configuration
├── utils/
│ ├── email_backend.py # Custom email backend with timeout
│ ├── error_handler.py # Centralized error handling
│ ├── logging.py # Logging configuration and filters
│ ├── otp.py # OTP utilities
│ ├── rate_limiter.py # Rate limiting decorator
│ └── tasks.py # Background tasks
├── .env.example # Environment variables template
├── .gitignore
├── manage.py
├── README.md
└── requirements.txt
- Role-based access (Disposer, Recycler, Admin)
- Secure JWT authentication
- OTP-based email verification
- Password reset with OTP
- User profile management
- Points-based reward system
- Cash wallet for transactions
- Fund transfers between users
- Withdrawal to bank accounts
- Complete transaction history
- Connect disposers with recyclers
- Waste listing management
- Real-time transaction tracking
- Escrow-based payments for security
- Paystack payment processing
- Secure escrow system
- Automated payouts to recyclers
- Payment verification and webhooks
- Transaction audit trail
- JWT token authentication
- OTP verification for sensitive operations
- Rate limiting on API endpoints
- Brute force protection (django-axes)
- CORS configuration
- Password strength validation
- Secure payment handling
- User referral tracking
- Referral code generation
- Reward distribution
- Referral analytics
- Email notifications
- Transaction alerts
- OTP delivery
- Contact form responses
- User statistics
- Transaction monitoring
- System health checks
- Performance metrics
SECRET_KEY– Django secret key for cryptographic signingDEBUG– Set toTruefor development,Falsefor productionALLOWED_HOSTS– Comma-separated list of allowed hosts
USE_POSTGRES– Set toTruefor PostgreSQL,Falsefor SQLiteDATABASE_NAME– PostgreSQL database nameDATABASE_USER– PostgreSQL usernameDATABASE_PASSWORD– PostgreSQL passwordDATABASE_HOST– PostgreSQL host addressDATABASE_PORT– PostgreSQL port (default: 5432)SSL_MODE– SSL mode for database connection
EMAIL_BACKEND– Email backend classEMAIL_HOST– SMTP server hostEMAIL_PORT– SMTP server portEMAIL_USE_TLS– Use TLS encryptionEMAIL_HOST_USER– SMTP usernameEMAIL_HOST_PASSWORD– SMTP passwordDEFAULT_FROM_EMAIL– Default sender email addressEMAIL_TIMEOUT– Email operation timeout in seconds
REDIS_HOST– Redis server hostREDIS_PORT– Redis server portREDIS_PASSWORD– Redis password (if required)
PAYSTACK_SECRET_KEY– Paystack secret API keyPAYSTACK_PUBLIC_KEY– Paystack public API keyPAYSTACK_WEBHOOK_SECRET– Webhook secret for verification
FRONTEND_URL– Frontend application URL for CORS and redirects
CORS_ALLOWED_ORIGINS– Comma-separated list of allowed origins
CLOUDINARY_CLOUD_NAME– Cloudinary cloud nameCLOUDINARY_API_KEY– Cloudinary API keyCLOUDINARY_API_SECRET– Cloudinary API secret
Run all tests:
python manage.py testRun tests for a specific app:
python manage.py test apps.users
python manage.py test apps.wallet
python manage.py test apps.otp
python manage.py test apps.paymentsRun tests with coverage:
coverage run manage.py test
coverage report
coverage html # Generate HTML coverage report- ✅ Set
DEBUG=Falsein environment variables - ✅ Configure
ALLOWED_HOSTSwith your production domain - ✅ Set up PostgreSQL database
- ✅ Configure Redis for production use
- ✅ Set all security-related environment variables
- ✅ Configure production SMTP server for emails
- ✅ Set up Paystack production API keys
- ✅ Configure CORS with production frontend URLs
- ✅ Collect static files:
python manage.py collectstatic - ✅ Run database migrations:
python manage.py migrate - ✅ Set up SSL certificates for HTTPS
- ✅ Configure backup strategy for database
- ✅ Set up monitoring and logging
- ✅ Configure firewall and security groups
This project is configured for deployment on:
- Render – Uses
render.yamlconfiguration - Railway – Auto-detection compatible
- Heroku – Includes
Procfile - DigitalOcean – Manual deployment supported
- AWS/GCP – Docker-ready
Render/Railway (automatic):
git push origin mainManual deployment:
# Collect static files
python manage.py collectstatic --noinput
# Run migrations
python manage.py migrate
# Start gunicorn server
gunicorn config.wsgi:application --bind 0.0.0.0:8000We welcome contributions to WasteWorth! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name
- Make your changes and commit using conventional commits
- Write or update tests for your changes
- Push to your fork:
git push origin feature/your-feature-name
- Submit a pull request
Use conventional commit format:
| Type | Description | Example |
|---|---|---|
feat |
New feature | feat: add wallet withdrawal endpoint |
fix |
Bug fix | fix: resolve OTP verification timeout issue |
docs |
Documentation changes | docs: update API endpoint documentation |
style |
Code style changes (formatting, etc.) | style: format wallet models with black |
refactor |
Code refactoring | refactor: optimize database queries |
test |
Adding or updating tests | test: add unit tests for payment service |
chore |
Maintenance tasks | chore: update dependencies |
perf |
Performance improvements | perf: optimize wallet balance calculation |
Example:
git commit -m "feat: add email verification for new users"- Follow PEP 8 style guide for Python code
- Use meaningful variable and function names
- Write docstrings for functions and classes
- Keep functions small and focused
- Add comments for complex logic
- Provide a clear description of the changes
- Reference any related issues
- Ensure all tests pass
- Update documentation if needed
- Request review from maintainers
This project is licensed under the MIT License. See the LICENSE file for details.
For issues, questions, or feature requests:
- GitHub Issues: Create an issue
- Email: [email protected]
- Documentation: API Documentation
- InternPulse Team – Development and maintenance
- Django & DRF – Robust framework for API development
- Paystack – Secure payment processing
- Brevo – Email service provider
- Cloudinary – Media management
WasteWorth – Making waste management rewarding and sustainable 🌍♻️
