The aim of this project was to build an inventory management system for small businesses.
- Abdul-Mumin Awinaba: X/Github/LinkedIn
- Emmanuel Kwadwo Tettey: X/Github/Linkedin
- Johnkennedy Umeh: X/Github/LinkedIn
- Python (>=3.8)
- MySQL Server (>= 8.x)
- Yarn
sudo apt update
sudo apt install python3sudo apt update
sudo apt install mysql-serversudo apt update
sudo apt install nodejs npm
npm install -g yarn-
Clone repository:
git clone https://github.com/anuelt2/inventrix.git
-
Change the current working directory to the cloned repo:
cd inventrix/ -
Create and activate a virtual environment (optional but recommended):
python3 -m venv .env source .env/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Create MySQL user and database:
cat scripts/db_scripts/setup_inventrix_dev.sql | sudo mysql -u root -p -
Dump mock data into database:
cat scripts/db_scripts/mock_data.sql
-
Run the flask app:
python3 -m api.v1.app
-
Start the react app:
cd frontend/ npm install -g vite #Install dependencies yarn install #Run the server vite
The react app should be served on http://localhost:5173/ by default
You can choose to either interact with the API directory by sending requests with curl or Postman of your preferred API testing tool
The base route for the endpoints is /api/v1/{resource}
All the endpoints are protected except /api/v1/register and /api/v1/register
To access the remaining resources:
-
Create a user by sending POST
/api/v1/registerendpoint. The request body must contain:first_name,last_name,username,emailandpassword# Example using curl curl -X POST http://127.0.0.1:5000/api/v1/register \ -H "Content-Type: application/json" \ -d '{ "first_name": "John", "last_name": "Doe", "username": "jdoe", "email": "[email protected]", "password": "johndoe" }'
-
Login by sending a POST to
/api/v1/loginendpoint. The request body must containnameandpassword. The response will contain a JSON Web Token(JWT) you can use for authorisation to access protected resources.curl -X POST http://127.0.0.1/api/v1/register \ -H "Content-Type: application/json" \ -d '{ "email": "[email protected]", "password": "johndoe" }'
-
Categories
-
GET
/api/v1/categories: Returns a list of all categories. -
GET
/api/v1/categories/<category_id>: Returns a category linked tocategory_id. -
POST
/api/v1/categories/: Creates a new category. The request body must contain at least the name of the category e.g.{"name": "category_name"}.# Example using curl curl -X POST http://127.0.0.1/api/v1/categories \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_token" \ -d '{ "name": "Self-help Books", "description": "Self-help books" }'
-
PUT
/api/v1/categories/<category_id>: Updates a category linked tocategory_id -
DELETE
/api/v1/categories/<category_id>: Deletes a category linked tocategory_id -
PUT
/api/categories/<category_id>/products: Returns a list of all products linked tocategory_id -
PUT
/api/categories/<category_id>/products/<product_id>: Links a product to a category
-
-
Products
-
GET
/api/v1/products: Returns a list of all Products -
GET
/api/v1/products/<product_id>: Returns a product linked toproduct_id. -
POST
/api/v1/products/: Creates a new product. The request body should contain:name(string, required),brand(string),model(string),description(string),sku(string, required),price(integer, required),stock_quantity(integer, required),reorder_level(integer, required)# Example using curl curl -X POST http://127.0.0.1/api/v1/products \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_token" \ -d '{ "name": "OMO", "brand": "OMO", "model": "1KG", "description": "Detergent", "sku": "KJFAUHALIJS", "price": 15.99, "stock_quantity": 1000, "reorder_level": 100 }'
-
PUT
/api/v1/products/<product_id>: Updates a product linked toproduct_id -
DELETE
/api/v1/products/<product_id>: Deletes a product linked toproduct_id6.#TODO: Confirm if there is an endpoint to retrieve all suppliers for a product
-
-
Customers
-
GET
/api/v1/customers: Returns a list of all Customers. -
GET
/api/v1/customers/<customer_id>: Returns a customer linked tocustomer_id. -
POST
/api/v1/customers/: Creates a new customer. The request body acceptsname(string),phone(string),email(string) andaddress(string).# Example using curl curl -X POST http://127.0.0.1/api/v1/products \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_token" \ -d '{ "name": "John", "phone": "+233 12 345 6789", "email": "[email protected]", "address": "123 C-Sharp street" }'
-
PUT
/api/v1/customers/<customer_id>: Updates a customer linked tocustomer_id -
DELETE
/api/v1/customers/<customer_id>: Deletes a customer linked tocustomer_id
-
-
Suppliers
-
GET
/api/v1/suppliers: Returns a list of all Suppliers. -
GET
/api/v1/suppliers/<supplier_id>: Returns a supplier linked tosupplier_id. -
GET
/api/v1/suppliers/<supplier_id>/products: Returns a list of products of supplier linked tosupplier_id. -
POST
/api/v1/suppliers/: Creates a new supplier. The request body acceptsname(required),contact_person(requried),phone(required),email(required) andaddress.# Example using curl curl -X POST http://127.0.0.1/api/v1/suppliers \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_token" \ -d '{ "name": "Quick Supplies", "contact_person": "Juliet" "phone": "+233 12 345 6789", "email": "[email protected]", "address": "123 C-Sharp street" }'
-
PUT
/api/v1/suppliers/<supplier_id>: Updates a supplier linked tosupplier_id -
DELETE
/api/v1/suppliers/<supplier_id>: Deletes a supplier linked tosupplier_id
-
-
Transactions
-
GET
/api/v1/transactions: Returns a list of all Transactions. -
GET
/api/v1/transactions/<transaction_id>: Returns a transaction linked totransaction_id. -
POST
/api/v1/transactions/: Creates a new transaction. The request body acceptstransaction_type(string, required),user_id(string, required),supplier_id(string, required forpurchasetransaction_type),customer_id(string, required forsaletransaction_type) and list of transaction_items (list of objects, required). Each transaction_item acceptsquantity(integer, required),unit_price(integer, required),total(integer, required),product_id(string, required).# Example using curl with sale transaction curl -X POST http://127.0.0.1/api/v1/transactions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_token" \ -d '{ "transaction_type": "sale", "user_id": "1234567890", "customer_id": "1234567890", "transaction_items": [ {"quantity": 3, "unit_price": 2, "total": 6, "product_id": "1234567890"} ] }'
-
PUT
/api/v1/transactions/<transaction_id>: Updates a transaction linked totransaction_id -
DELETE
/api/v1/transactions/<transaction_id>: Deletes a transaction linked totransaction_id
-
-
Open the browser and go to
http://127.0.0.1:5000 -
The app will display the homepage
-
Create a new user if you haven't already.
-
Login with your user's credentials.
- User authentication
- CRUD operations
- RESTful API for managing resources
- Pagination