A modular Django REST Framework backend for managing Vendors, Products, Courses, Certifications, and their mappings.
All APIs are implemented using APIView, with drf-yasg for Swagger and ReDoc documentation.
This project is a modular Django REST Framework backend for managing Vendors, Products, Courses, Certifications, and their mappings. All APIs use APIView only (no ViewSets, routers, GenericAPIView, or mixins). API documentation is provided via drf-yasg (Swagger & ReDoc).
- Clone the repository:
git clone https://github.com/25punam/Modular-API.git cd modular_api - Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Add to
INSTALLED_APPSinsettings.py:'rest_framework', 'drf_yasg', 'vendor', 'product', 'course', 'certification', 'vendor_product_mapping', 'product_course_mapping', 'course_certification_mapping',
- Apply migrations:
python manage.py makemigrations python manage.py migrate
- Create a superuser (optional):
python manage.py createsuperuser
- Run the server:
python manage.py runserver
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/vendors/ | List vendors |
| POST | /api/vendors/ | Create vendor |
| GET | /api/vendors/<id>/ | Retrieve vendor |
| PUT | /api/vendors/<id>/ | Update vendor |
| PATCH | /api/vendors/<id>/ | Partial update |
| DELETE | /api/vendors/<id>/ | Delete vendor |
Similar endpoints exist for products, courses, and certifications.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/vendor-product-mappings/ | List vendor-product mappings |
| POST | /api/vendor-product-mappings/ | Create mapping |
| GET | /api/vendor-product-mappings/<id>/ | Retrieve mapping |
| PUT | /api/vendor-product-mappings/<id>/ | Update mapping |
| PATCH | /api/vendor-product-mappings/<id>/ | Partial update mapping |
| DELETE | /api/vendor-product-mappings/<id>/ | Delete mapping |
Similar endpoints exist for product-course and course-certification mappings.
- Swagger: http://localhost:8000/swagger/
- ReDoc: http://localhost:8000/redoc/
All APIs include:
- Request body schema
- Response schema
- Query parameters for filtering
- Success and error response examples
Use query params for filtering in list APIs:
/api/products/?vendor_id=1/api/courses/?product_id=2/api/certifications/?course_id=3
- Unique code for master entities
- Prevent duplicate mappings
- Only one primary mapping per parent
- Required fields
All models are registered for admin management.
Create a vendor:
curl -X POST http://localhost:8000/api/vendors/ \
-H "Content-Type: application/json" \
-d '{"name": "Vendor1", "code": "V001", "description": "Test vendor"}'Retrieve all products:
curl http://localhost:8000/api/products/Create a vendor-product mapping:
curl -X POST http://localhost:8000/api/vendor-product-mappings/ \
-H "Content-Type: application/json" \
-d '{"vendor": 1, "product": 2, "primary_mapping": true}'python manage.py makemigrations
python manage.py migratepython manage.py runserver- Add your own fixtures or use Django admin to create initial data.
MIT