Skip to content

mdjaved24/Inventory-Management-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

🧾 Inventory Management API

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.


🚀 Key Features

  • ✅ 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 or total_price
  • 💡 total_price = unit_price × quantity auto-calculated in:
    • List view
    • Create response
    • Update response
  • ❌ Error handling for duplicate barcode entries

🛠️ Tech Stack

  • Backend: Django, Django REST Framework
  • Auth: JWT (djangorestframework-simplejwt)
  • Database: SQLite (default)
  • Testing: Django APITestCase

📁 Project Structure

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 APITestCase

inventory/ ├── urls.py # Routes for API endpoints


🧪 Running Tests

python manage.py test

Runs all test cases under inventory_app/tests.py. Covers authentication, CRUD, permissions, filters, ordering, and validations.


🚀 Getting Started (Locally)

Clone the repo


git clone https://github.com/mdjaved24/inventory-api.git
cd inventory-api

Install dependencies

pip install -r requirements.txt

Run migrations


python manage.py makemigrations
python manage.py migrate

Create a superuser (optional)

python manage.py createsuperuser

Start the development server

python manage.py runserver

🔐 Authentication

  • Register: /register/
  • Login: /login/

Returns access and refresh tokens using JWT.


📮 API Endpoints

Method Endpoint Access Description
POST/register/PublicRegister a new user
POST/login/PublicLogin and receive JWT token
GET/products/PublicList all products
POST/products/Admin OnlyCreate a new product
GET/products/<id>/PublicGet product details
PUT/products/<id>/Admin OnlyFully update product
PATCH/products/<id>/Admin OnlyPartially update product
DELETE/products/<id>/Admin OnlyDelete a product

📌 Requirements

  • Django >= 4.0
  • djangorestframework
  • djangorestframework-simplejwt

👨‍💻 Author

Md Javed
Django & DRF Developer | Data Scientist
GitHub Profile


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages