Skip to content

Ani29hs/Warely_Flask_Django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

--To Run the application:

--create a virtual environment inside the project folder

python -m venv env

--activate that virtual environment

env\Scripts\activate

--install the dependencies inside the activated virtual environment

pip install -r requirements.txt

--run the application:

python app.py

--On first run, an admin user will automatically be created:
- Email: admin@gmail.com
- Password: admin@123

--To test the following endpoints use the Postman software or any HTTP client tool


API Endpoints:
--------------
- `POST /registerapi` – Register a new user via JSON
- `POST /loginapi` – Login and receive JWT token
- `GET /productsapi` – Get all products (JWT required)
- `POST /productsapi` – Add a new product (JWT required)
- `GET /productsapi/<productid>` – Get single product (JWT required)
- `PUT /productsapi/<productid>` – Update product (JWT required)
- `DELETE /productsapi/<productid>` – Delete product (Admin role only, JWT required)
- `GET /productsapi/category/<category>` – Filter products by category (JWT required)


List of Sample payload of different functionalities:
-----------------------------------------------------

1. User Registration Endpoint

POST /registerapi

{
  "name": "John Doe",
  "email": "john@example.com",
  "mobile": "9876543210",
  "password": "john123",
  "role": "user"     // Optional: "user" or "admin"
}


2. User Login Endpoint

POST /loginapi

{
  "username": "john@example.com",
  "password": "john123"
}


Response will contain JWT token like:

{
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}


Use this token as Bearer in headers for the protected endpoints:

Authorization: Bearer <access_token>



PRODUCT ENDPOINTS (JWT Required)
=================================

3. Add New Product

POST /productsapi


{
  "name": "Laptop",
  "price": "70000",
  "quantity": 5,
  "category": "Electronics"
}


4. Update Existing Product

PUT /productsapi/<productid>

{
  "name": "Gaming Laptop",
  "price": "85000",
  "quantity": 3,
  "category": "Electronics"
}


5. Get Product By ID

GET /productsapi/<productid>

No body required.


6. Delete Product

DELETE /productsapi/<productid>

Requires JWT Token of admin role.

No body required.


7. Get All Products

GET /productsapi

No body required.


8. Get Products by Category
GET /productsapi/category/<category>

Example:
/products/category/Electronics


9.Add Warehouse
POST /api/Warehouses

{
  "address": "Delhi Warehouse"
}


10. Transfer product

GET /api/transfer

{
  "product_id": 1,
  "from_warehouse_id": 2,
  "to_warehouse_id": 3,
  "quantity_to_transfer": 2,
  "transfer_date": "2025-05-06"
}

-------------------------------------------------------------------------------------------------------

Django Application

To run app :-

1.Create and activate virtual environment:

python -m venv env
source venv/bin/activate  # On Windows: venv\Scripts\activate

2.Install Django dependencies:

pip install -r requirements.txt


3.Move to folder

cd InventoryManagement


4.Apply migrations:

python manage.py makemigration
python manage.py migrate

5. Run the Django server:

python manage.py runserver


Django app will start at:
http://127.0.0.1:8000/








About

Warely is a scalable and efficient inventory management system developed using a hybrid backend architecture with Django and Flask. The system leverages Django for core functionalities such as authentication, database management, and admin operations, while Flask is used for lightweight API'S and modular services to enhance flexibility

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors