Production-ready Django REST Framework backend built using strict APIView architecture for managing:
- Vendors
- Products
- Courses
- Certifications
- Hierarchical mappings:
- Vendor -> Product
- Product -> Course
- Course -> Certification
- Django 5.1.6
- Django REST Framework 3.15.2
- drf-yasg 1.21.8 (Swagger + ReDoc)
- SQLite (default, can be swapped for PostgreSQL in production)
- Separate app per master entity:
vendorproductcoursecertification
- Separate app per mapping:
vendor_product_mappingproduct_course_mappingcourse_certification_mapping
- APIs implemented using
APIViewonly - No
ViewSet,ModelViewSet,GenericAPIView, mixins, or routers - Manual queryset filtering by query params
- Validation for duplicate mappings and single-primary-per-parent rule
- drf-yasg integrated with
/swagger/and/redoc/
project/
├── certification/
├── common/
├── course/
├── course_certification_mapping/
├── product/
├── product_course_mapping/
├── project/
├── vendor/
├── vendor_product_mapping/
├── manage.py
├── requirements.txt
└── README.md
Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1pip install -r requirements.txtpython manage.py makemigrations
python manage.py migratepython manage.py seed_datapython manage.py runserver- Swagger UI:
http://127.0.0.1:8000/swagger/ - ReDoc:
http://127.0.0.1:8000/redoc/
-
GET /api/vendors/ -
POST /api/vendors/ -
GET /api/vendors/{id}/ -
PUT /api/vendors/{id}/ -
PATCH /api/vendors/{id}/ -
DELETE /api/vendors/{id}/ -
GET /api/products/ -
POST /api/products/ -
GET /api/products/{id}/ -
PUT /api/products/{id}/ -
PATCH /api/products/{id}/ -
DELETE /api/products/{id}/ -
GET /api/courses/ -
POST /api/courses/ -
GET /api/courses/{id}/ -
PUT /api/courses/{id}/ -
PATCH /api/courses/{id}/ -
DELETE /api/courses/{id}/ -
GET /api/certifications/ -
POST /api/certifications/ -
GET /api/certifications/{id}/ -
PUT /api/certifications/{id}/ -
PATCH /api/certifications/{id}/ -
DELETE /api/certifications/{id}/
-
GET /api/vendor-product-mappings/ -
POST /api/vendor-product-mappings/ -
GET /api/vendor-product-mappings/{id}/ -
PUT /api/vendor-product-mappings/{id}/ -
PATCH /api/vendor-product-mappings/{id}/ -
DELETE /api/vendor-product-mappings/{id}/ -
GET /api/product-course-mappings/ -
POST /api/product-course-mappings/ -
GET /api/product-course-mappings/{id}/ -
PUT /api/product-course-mappings/{id}/ -
PATCH /api/product-course-mappings/{id}/ -
DELETE /api/product-course-mappings/{id}/ -
GET /api/course-certification-mappings/ -
POST /api/course-certification-mappings/ -
GET /api/course-certification-mappings/{id}/ -
PUT /api/course-certification-mappings/{id}/ -
PATCH /api/course-certification-mappings/{id}/ -
DELETE /api/course-certification-mappings/{id}/
GET /api/products/?vendor_id=1GET /api/courses/?product_id=2GET /api/certifications/?course_id=3GET /api/vendor-product-mappings/?vendor_id=1&primary_mapping=true
- Required field checks through serializers
- Unique code validation for all master entities
- Duplicate mapping prevention at serializer + DB constraint levels
- FK validation via
PrimaryKeyRelatedField - Only one active
primary_mapping=Trueper parent in each mapping layer
- 200 OK, 201 Created, 400 Bad Request, 404 Not Found
- Global DRF custom exception handler returns JSON 500 Internal Server Error payload
- Abstract base model (
TimeStampedActiveModel) for shared fields - Soft delete (
is_active=False) on DELETE endpoints - Reusable object retrieval utility (
get_object_or_404_message) - Nested mapping API responses (parent/child details included)
- Seed data management command (
seed_data) - Unit tests for API and mapping validations
{
"name": "Acme Vendor",
"code": "VENDOR-100",
"description": "Global training vendor",
"is_active": true
}{
"vendor_id": 1,
"product_id": 1,
"primary_mapping": true,
"is_active": true
}python manage.py test- Modular app structure
- APIView-only CRUD APIs
- Validation rules
- Swagger + ReDoc
- Admin registrations
- Seed command
- Unit tests