A simple perishable inventory management system
The process of installation is in four simple stages Note that the guide assumes you are familiar with node.js environment and its framework express.js and have installed MySQL Workkbench on your machine.
- Clone the repository to your local machine.
- Create a database on your MySQL workbench and change the database parameters in the configuration file (/src/config.ts) to your newly created database.
- Manually add the perishable products to the is_products table in the database. Note: The required fields are name and slug. slug is best with value small letters, (with underscore, hyphen and number(s)). The :item parameter in the URI represents the slug.
- (Optional) The Application Port is defaulted to 3000 and can be changed in /index.ts directly inside of the project root directory.
- Navigate to project root directory on your CLI and run any of the commands, npm run start or npm run start:dev or npm run start:build
- Then you should have your app run successfully.
- POST /:item/add
- a. Add a lot of :item to the system
- b. IN: {quantity: Number, expiry: Number}
- i. quantity - quantity of item in the lot to be added
- ii. expiry - milliseconds-since-epoch representing the expiry time of this lot
- c. OUT: {}
- POST /:item/sell
- a. sell a quantity of an item and reduce its inventory from the database.
- b. IN: {quantity: Number}
- i. quantity - quantity to be sold.
- c. OUT: {}
- GET /:item/quantity
- a. get non-expired quantity of the item from the system
- b. IN: {}
- c. OUT: {quantity: Number, validTill: Number | null}
- i. quantity - non-expired quantity of item
- ii. validTill - milliseconds-since-epoch representing the maximum time till which the returned quantity is valid. should be null if returned quantity is 0