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