A comprehensive Django REST Framework backend for an influencer marketing platform that connects brands with influencers for campaign collaborations.
This backend system powers an influencer marketing platform where:
- Brands can create campaigns, manage budgets, and collaborate with influencers
- Influencers can browse campaigns, place bids, and deliver content
- Both parties can communicate through an integrated messaging system
- Payments are processed securely through Stripe integration
- Real-time notifications keep users informed of campaign updates
- Dual account types: Brand and Influencer
- JWT-based authentication with access and refresh tokens
- Email verification with OTP
- Profile management with profile pictures and bio
- Instagram username integration
- Create, update, and delete campaigns
- Campaign status tracking (Open, Pending Payment, In Progress, Completed, Closed)
- Campaign images and detailed descriptions
- Budget management
- Date-based campaign scheduling
- Influencers can bid on open campaigns
- Brands can accept or decline bids
- Bid status tracking (Pending, Accepted, Declined)
- Delivery status management (Pending, Delivered, Approved)
- Stripe integration for secure payments
- Checkout session creation
- Payment status tracking (Pending, Completed, Failed)
- Payment success and cancellation handling
- Track campaign performance metrics
- Engagement rate monitoring
- Reach and impressions tracking
- Clicks and conversions reporting
- Direct messaging between users
- Recent conversations view
- Contact list management
- Unread message indicators
- Automatic notifications for new messages
- Real-time notification system
- Multiple notification types
- Read/unread status tracking
- Automatic notifications for key events
- Framework: Django 5.1.2
- API: Django REST Framework 3.15.2
- Authentication: JWT (djangorestframework-simplejwt 5.5.0)
- Database: SQLite3 (development)
- Payment Processing: Stripe
- Image Handling: Pillow 11.1.0
- CORS: django-cors-headers 4.7.0
- Real-time Features: Channels 4.2.2, Redis 6.2.0, Daphne 4.2.0
- Python 3.8 or higher
- pip (Python package manager)
- Virtual environment (recommended)
-
Clone the repository
git clone https://github.com/UmanSheikh/backend-IS.git cd backend-IS -
Create and activate virtual environment
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Run migrations
python manage.py migrate
-
Create superuser (optional)
python manage.py createsuperuser
-
Run the development server
python manage.py runserver
The API will be available at http://localhost:8000/
Key settings in backend/settings.py that you may want to configure:
SECRET_KEY: Django secret key (change in production)DEBUG: Set toFalsein productionALLOWED_HOSTS: Add your domain in productionDATABASES: Configure production databaseSTRIPE_API_KEY: Your Stripe API keyFRONTEND_URL: Frontend application URL (default:http://localhost:3000)
The API is configured to accept requests from:
http://localhost:3000(default frontend)
Add additional origins in CORS_ALLOWED_ORIGINS in settings.py
- Access token lifetime: 60 minutes
- Refresh token lifetime: 1 day
POST /apis/register-user/- Register a new userPOST /apis/login/- User loginGET /apis/user-profile/- Get authenticated user profile
GET /apis/users/- List all usersGET /apis/user/<uuid:id>/- Get user detailsPUT /apis/update-user/<str:email>/- Update userDELETE /apis/delete-user/<str:email>/- Delete user
GET /apis/campaign/- List open campaigns (for influencers)GET /apis/campaigns/- List all campaigns (for authenticated users)POST /apis/create-campaign/- Create a new campaignGET /apis/campaigns/<uuid:id>/- Get campaign detailsPUT /apis/update-campaign/<uuid:id>/- Update campaignDELETE /apis/delete-campaign/<uuid:id>/- Delete campaignGET /apis/completed-campaigns/- List completed campaigns
GET /apis/bids/- List bidsPOST /apis/bids/create/- Create a new bidGET /apis/bids/list/<uuid:campaign_id>/- List bids for a campaignPUT /apis/bids/update/<uuid:id>/- Update bid statusPOST /apis/bids/deliver/<uuid:id>/- Mark bid as delivered
POST /apis/create-checkout-session/- Create Stripe checkout sessionGET /apis/pay/success/- Payment success callbackGET /apis/pay/cancel/- Payment cancellation callback
GET /apis/analytics/- List analyticsPOST /apis/create-analytics/- Create analytics recordPUT /apis/update-analytics/<uuid:id>/- Update analyticsDELETE /apis/delete-analytics/<uuid:id>/- Delete analytics
GET /apis/messages/contacts/- Get contact listGET /apis/messages/recent/- Get recent conversationsGET /apis/messages/- List messagesPOST /apis/messages/- Send a new message
GET /apis/notifications/- List notificationsPOST /apis/create-notification/- Create notificationPUT /apis/update-notification/<uuid:id>/- Update notificationDELETE /apis/delete-notification/<uuid:id>/- Delete notification
GET /apis/brand-data/- Get brand dashboard data
POST /apis/fetch-instagram-data/- Fetch Instagram profile data
backend-IS/
βββ apis/ # Main API application
β βββ migrations/ # Database migrations
β βββ __init__.py
β βββ admin.py # Admin panel configuration
β βββ apps.py # App configuration
β βββ models.py # Database models
β βββ serializers.py # DRF serializers
β βββ tests.py # Test cases
β βββ urls.py # API URL routing
β βββ views.py # API views
βββ backend/ # Project settings
β βββ __init__.py
β βββ asgi.py # ASGI configuration
β βββ settings.py # Django settings
β βββ urls.py # Main URL configuration
β βββ views.py # Base views
β βββ wsgi.py # WSGI configuration
βββ media/ # User-uploaded media files
β βββ profile_pics/ # Profile pictures
β βββ campaign_images/ # Campaign images
βββ db.sqlite3 # SQLite database (development)
βββ manage.py # Django management script
βββ requirements.txt # Python dependencies
βββ README.md # This file
Custom user model extending Django's AbstractUser with:
- UUID primary key
- Email and username (unique)
- Account type (Brand/Influencer)
- Instagram username
- Profile picture and bio
- OTP verification system
- Title, description, and budget
- Start and end dates
- Status tracking
- Image upload
- Foreign key to Brand (IS_Users)
- Campaign and Influencer references
- Bid amount
- Status (Pending, Accepted, Declined)
- Payment status
- Delivery status
- One-to-one relationship with Bid
- Amount and payment date
- Status tracking
- Campaign and Influencer references
- Engagement metrics (rate, reach, impressions)
- Click and conversion tracking
- Sender and recipient (IS_Users)
- Message content
- Read status
- Timestamp
- User reference
- Message content
- Notification type
- Read status
The API uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header:
Authorization: Bearer <access_token>
- Register a new user at
/apis/register-user/ - Login at
/apis/login/to receive access and refresh tokens - Use the access token for authenticated requests
- Refresh the token using the refresh token when it expires
The platform uses Stripe for payment processing:
- Brand accepts an influencer's bid
- Campaign status changes to "Pending Payment"
- Brand initiates payment through
/apis/create-checkout-session/ - User completes payment on Stripe checkout page
- Success callback updates payment status
- Campaign status updates to "In Progress"
curl -X POST http://localhost:8000/apis/register-user/ \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"username": "username",
"first_name": "John",
"last_name": "Doe",
"password": "secure_password",
"phone_number": "+1234567890",
"account_type": "brand"
}'curl -X POST http://localhost:8000/apis/login/ \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "secure_password"
}'curl -X POST http://localhost:8000/apis/create-campaign/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"title": "Summer Product Launch",
"description": "Promote our new summer collection",
"budget": "5000.00",
"start_date": "2024-06-01",
"end_date": "2024-08-31"
}'curl -X POST http://localhost:8000/apis/bids/create/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"campaign": "<campaign_uuid>",
"amount": "1500.00"
}'Run the test suite:
python manage.py testRun tests for a specific app:
python manage.py test apis- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Change
SECRET_KEYin production - Set
DEBUG = Falsein production - Use environment variables for sensitive data
- Update
ALLOWED_HOSTSfor production deployment - Use a production-grade database (PostgreSQL, MySQL)
- Implement rate limiting for API endpoints
- Review and update CORS settings
- Set up a production database
- Configure static files serving
- Set up media files storage (e.g., AWS S3)
- Configure Redis for Channels
- Use a production ASGI server (e.g., Daphne, uvicorn)
- Set up SSL/TLS certificates
- Configure environment variables
- Set up logging and monitoring
Uman Sheikh, Hamza Shafique
For support, please open an issue or contact the development team.
- v1.0.0 - Initial release with core functionality
Note: This is a development setup. Please ensure proper security measures and configurations before deploying to production.