docker-compose up -d
To stop Docker services:
docker-compose down
To rebuild and restart services:
docker-compose up --build
Run all tests
docker-compose -f docker-compose.test.yml up --build //bizzard
Run all tests for the authentication app:
docker-compose exec web pytest apps/authentication/tests/ -v //bizzard
Run specific test files:
docker-compose exec web pytest apps/referrals/tests/test_service.py -v
To run tests in the background with Docker:
docker-compose up -d --build
A Django-based RESTful API service for managing referral systems with JWT authentication, async operations, and third-party integrations.
- User authentication with JWT and OAuth 2.0
- Referral code management
- Email verification with Email Hunter
- User data enrichment with Clearbit
- Redis caching for improved performance
- Comprehensive API documentation
- Asynchronous operations
- PostgreSQL database
- Docker and Docker Compose
- Python 3.11+
- PostgreSQL 13+
- Redis 6+
- Clone the repository:
git clone https://github.com/yourusername/referral-system.git
cd referral-system
- Create a
.env
file:
cp .env.example .env
- Build and start services:
docker-compose up --build
- Run migrations:
docker-compose exec web python manage.py migrate
- Access the API:
- API: http://localhost:8000/api/v1/
- Documentation: http://localhost:8000/swagger/
POST /api/v1/auth/register/
Content-Type: application/json
{
"email": "[email protected]",
"password": "secure_password",
"first_name": "John",
"last_name": "Doe"
}
POST /api/v1/auth/login/
Content-Type: application/json
{
"email": "[email protected]",
"password": "secure_password"
}
POST /api/v1/referrals/codes/create/
Authorization: Bearer <token>
Content-Type: application/json
{
"expires_at": "2024-12-31T23:59:59Z"
}
POST /api/v1/referrals/register/
Content-Type: application/json
{
"referral_code": "CODE123",
"email": "[email protected]",
"password": "secure_password"
}
docker-compose exec web pytest //bizard
Run a specific test file:
docker-compose exec web pytest apps/referrals/tests/test_views.py
-
Update environment variables:
DEBUG=0
- Secure
SECRET_KEY
- Database credentials
- API keys for Clearbit and Email Hunter
-
Build and deploy:
docker-compose -f docker-compose.prod.yml up --build
- Use HTTPS in production
- Regularly rotate JWT secrets
- Monitor API rate limits
- Keep dependencies updated
- Regular security audits
Used for enriching user data during registration. Configured via:
CLEARBIT_API_KEY
in .env
Verifies email addresses during registration. Configured via:
EMAILHUNTER_API_KEY
in .env
Redis is used for caching:
- Referral codes
- Enriched user data
- API responses
Configure cache settings in settings.py
:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
'LOCATION': 'redis://redis:6379/0',
}
}
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request