It allows you to scan items you have in your kitchen and input the quantity of that item that you currently have, and also the minimum quantity of that product that you always want to have. Example: You always want to have at least 6 litters of milk, you will then scan your milk's barcode, indicate how much you currently have and say that you want at least to have 6 litters of milk.
Once all your items are scanned, you can continuously update your inventory, and when it's time to go shopping, an accurate shopping list will tell you what to buy and the quantities. This is useful if you easily forget things when shopping (my case).
The web has 3 pages
- Inventory: Check your stock on current items, change the stock quantities and modify the minimum stock required.
- Scanner: This page integrates a barcode scanner to add new items or check how much you have of some product.
- Shopping List: This page shows what's lacking in your inventory for your next shopping session.
- Frontend: React TS Framework, html5-qrcode NPM package.
- Backend: Flask, Open Food Facts API, SQLite3 Database.
The frontend was made with React TS + React Router DOM.
It contains 3 main pages (already explained before).
It also contains 3 components. Product, Inventory Minimum and Inventory Modify, both of these last ones contained inside the first one.
Product is a component that shows the name, image and quantity per unit of a product, it also accepts props, toggling modification and shopping list view. Modification is what makes InventoryMinimum and InventoryModify components show up, and shopping list view simply tells the user how much of this product they must buy.
Inventory Minimum is simply an input and a button that sends the modification of minimum requisites for an item to the backend.
Inventory Modify are two buttons which allow adding or removing inventory quantities to items. They update the main Product component to show correctly how much of that product the user has.
The backend uses Django and an SQLite Database. This choice was done to ensure the simplicity of the project, as a more complex database should not be required for this.
SQLite databases add a constraint which makes it impossible for two processes to connect to it at the same time, so proper connection opening and closing had to be done, to avoid getting concurrency errors.
- Add quantity: This function accepts the item barcode and adds or removes quantity from the database inventory.
- Delete product: This function accepts the item barcode and removes a product from the database.
- Get all products: This function returns all items in the database, their quantities and information. This function is used for the inventory page.
- Get product: This function returns an items in the database, it's quantity and information.
- Get product column: This function returns an items specific column in the database.
- Get shopping list: This function returns all items who have less quantity then the one specified in inventory minimum. This function is used for the shopping list page.
- Insert product: This function accepts a name, category, barcode, image and more info to insert the item in the database. Products are automatically inserted once they are scanned.
- Modify column: This function accepts a barcode and modifies the specified column with a certain value.
- Product is saved: This function checks if a product is already in the database.
- Product Serializer: This function accepts one or many products and converts it from the SQLite library format to a dict. This function is used in almost the entirety of the project to facilitate reading.
/inventory, /shopping-list, /product/<code>
- /inventory This endpoint returns all items in the inventory, and its info. It uses the getAllProducts function.
- /shopping-list This endpoint returns all items in the inventory, which have less quantity than the one required by the inventory minimum specification. It uses the getShoppingList function.
-
/product
- GET: This method creates a new product by giving it the barcode. It accesses the Open Food Facts API and saves all the info inside the database. It then returns all the information.
- POST: This method adds quantity to a product. It simply adds the quantity per unit every time this endpoint and method is hit.
- DELETE: This method remove quantity from a product. It does the inverse of the POST method. It makes sure no negative quantities are recorded in the database.
- PUT: This method allows you to modify the inventory minimum quantity.