A comprehensive Django REST Framework-based Vendor Management System with JWT authentication, automated reminders, and full CRUD operations for vendors and their services/contracts.
- Python 3.8 or higher
- pip (Python package manager)
cd /path/to/assignment# Linux/Mac
python3 -m venv venv
source venv/bin/activate
# Windows
python -m venv venv
venv\Scripts\activatepip install -r requirements.txtpython manage.py makemigrations
python manage.py migratepython manage.py createsuperuserThis allows you to access the Django admin panel at /admin/
python manage.py runserverThe API will be available at http://127.0.0.1:8000/
Edit project/settings.py and uncomment/configure SMTP settings for production:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'your-email@gmail.com'
EMAIL_HOST_PASSWORD = 'your-password'
DEFAULT_FROM_EMAIL = 'your-email@gmail.com'
ADMIN_EMAIL = 'admin@example.com' # For reminder notificationspython manage.py insert_dummy_data.py
All vendor and service management endpoints require JWT authentication. Include the access token in the Authorization header:
Authorization: Bearer <access_token>
POST /api/register/
No authentication required
Request Body:
{
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword123",
"password2": "securepassword123",
"first_name": "John",
"last_name": "Doe"
}POST /api/token/
No authentication required
Request Body:
{
"username": "johndoe",
"password": "securepassword123"
}Response:
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}POST /api/token/refresh/
Request Body:
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}Returns a new access token.
POST /api/token/verify/
Request Body:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}- Access Token Lifetime: 1 hour
- Refresh Token Lifetime: 7 days
- Token Rotation: Enabled
- Header Format:
Authorization: Bearer <token>
0 9 * * * /path/to/assignment/venv/bin/python manage.py check_reminders --days 15
All API endpoints are prefixed with /api/
Note: All endpoints below require JWT authentication unless otherwise specified.
All list endpoints support pagination with a default page size of 20 items.
Query Parameters:
?page=1- Get specific page?page_size=20- Change page size
Response Format:
{
"count": 100,
"next": "http://localhost:8000/api/vendors/?page=2",
"previous": null,
"results": [...]
}GET /api/vendors/
Requires authentication
Returns paginated list of vendors with their services.
Query Parameters: ?page=1&page_size=20
GET /api/vendors/{id}/
Requires authentication
Returns vendor with all services.
POST /api/vendors/
Requires authentication
Request Body:
{
"name": "Vendor Name",
"contact_person": "John Doe",
"email": "vendor@example.com",
"phone": "+1234567890",
"status": "Active"
}PUT/PATCH /api/vendors/{id}/
Requires authentication
DELETE /api/vendors/{id}/
Requires authentication
GET /api/vendors/list_with_active_services/
Requires authentication
Returns paginated list of vendors with only their active services.
Query Parameters: ?page=1&page_size=20
GET /api/services/
Requires authentication
Returns paginated list of services with vendor information.
Query Parameters: ?page=1&page_size=20
GET /api/services/{id}/
Requires authentication
Returns service with vendor information and status color.
POST /api/services/
Requires authentication
Request Body:
{
"vendor": 1,
"service_name": "Service Name",
"start_date": "2024-01-01",
"expiry_date": "2024-12-31",
"payment_due_date": "2024-12-15",
"amount": "1000.00"
}PUT/PATCH /api/services/{id}/
Requires authentication
DELETE /api/services/{id}/
Requires authentication
GET /api/services/expiring_soon/
Requires authentication
Returns paginated list of services expiring within 15 days.
Query Parameters: ?page=1&page_size=20
GET /api/services/payment_due_soon/
Requires authentication
Returns paginated list of services with payment due within 15 days.
Query Parameters: ?page=1&page_size=20
GET/POST /api/services/check_reminders/
Requires authentication
POST /api/services/check_reminders/ with body: {"days": 15}
GET /api/services/check_reminders/ (uses default 15 days)
Checks services and sends email notifications for those expiring or with payment due within the specified number of days (default: 15).
GET /api/services/services_by_color/
Requires authentication
Returns services grouped by status color:
red: Expired servicesorange: Payment overdueyellow: Expiring/payment due soon (within 15 days)green: Active and healthygray: Other statuses
See requirements.txt for complete list:
- Django 5.2.8
- djangorestframework 3.16.1
- djangorestframework-simplejwt 5.5.1
- PyJWT 2.10.1
- pandas 2.3.3
This project is part of an assignment for vendor management system implementation.