A simple and robust Inventory Management REST API built using Django Rest Framework.
It supports full CRUD functionality for products with JWT authentication and role-based permissions.
- ✅ CRUD operations with proper status codes
- 🔐 JWT-based authentication (Register/Login)
- 👥 Role-based access:
- Unauthenticated users can view products
- Only admin/staff can create, update, or delete products
- 🧾 Unique barcode constraint with custom error messages
- 📊 Filtering by price range
- 📈 Ordering by
unit_price
ortotal_price
- 💡
total_price = unit_price × quantity
auto-calculated in:- List view
- Create response
- Update response
- ❌ Error handling for duplicate barcode entries
- Backend: Django, Django REST Framework
- Auth: JWT (
djangorestframework-simplejwt
) - Database: SQLite (default)
- Testing: Django
APITestCase
inventory_app/ │ ├── models.py # Product model ├── views.py # API views with permissions and validations ├── serializers.py # Custom serializer with total_price logic ├── tests.py # Comprehensive test cases using APITestCaseinventory/ ├── urls.py # Routes for API endpoints
python manage.py test
Runs all test cases under inventory_app/tests.py
. Covers authentication, CRUD, permissions, filters, ordering, and validations.
git clone https://github.com/mdjaved24/inventory-api.git
cd inventory-api
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
- Register:
/register/
- Login:
/login/
Returns access and refresh tokens using JWT.
Method | Endpoint | Access | Description |
---|---|---|---|
POST | /register/ | Public | Register a new user |
POST | /login/ | Public | Login and receive JWT token |
GET | /products/ | Public | List all products |
POST | /products/ | Admin Only | Create a new product |
GET | /products/<id>/ | Public | Get product details |
PUT | /products/<id>/ | Admin Only | Fully update product |
PATCH | /products/<id>/ | Admin Only | Partially update product |
DELETE | /products/<id>/ | Admin Only | Delete a product |
- Django >= 4.0
- djangorestframework
- djangorestframework-simplejwt
Md Javed
Django & DRF Developer | Data Scientist
GitHub Profile