{"id":22376822,"url":"https://github.com/saiccoumar/myfridge","last_synced_at":"2026-05-02T09:32:59.462Z","repository":{"id":211682890,"uuid":"729380615","full_name":"saiccoumar/MyFridge","owner":"saiccoumar","description":"A Food Inventory System built with SQLite","archived":false,"fork":false,"pushed_at":"2023-12-31T21:43:07.000Z","size":131,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T23:29:58.520Z","etag":null,"topics":["dbms","flask","flask-sqlalchemy","html","sql","sqlalchemy","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saiccoumar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-09T03:52:24.000Z","updated_at":"2023-12-31T21:45:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"e5c7647c-7398-4558-b89d-1e8eaf71160d","html_url":"https://github.com/saiccoumar/MyFridge","commit_stats":null,"previous_names":["saiccoumar/myfridge"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiccoumar%2FMyFridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiccoumar%2FMyFridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiccoumar%2FMyFridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiccoumar%2FMyFridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saiccoumar","download_url":"https://codeload.github.com/saiccoumar/MyFridge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245708994,"owners_count":20659626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbms","flask","flask-sqlalchemy","html","sql","sqlalchemy","sqlite","sqlite3"],"created_at":"2024-12-04T22:11:32.626Z","updated_at":"2026-05-02T09:32:59.413Z","avatar_url":"https://github.com/saiccoumar.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MyFridge: A SQLite Based Food Inventory System\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"100%\" height=\"auto\" src=\"https://github.com/saiccoumar/MyFridge/assets/55699636/146d1d3e-d902-423c-9fb8-5fa96dedfa5e\"\u003e\n  \u003cem\u003e https://www.pinterest.com/triviastar \u003c/em\u003e\n\u003c/p\u003e\nby Sai Coumar\n\u003cbr /\u003e\n\n\n# Introduction\nWelcome to my course project for information systems! This is a SQLLite Food Inventory system built with python, flask, sqlalchemy, and basic html for the UI. I'll cover the usage, features, and some takeaways from this project. I'll also be covering some of the tools used to build this in depth and notes from the design process. Note that some of the data I used wasn't very accurate so some things don't make sense. Like a pizza with 17,000 calories.\n\n# Usage\nTo run the application, run the following command from the main directory\n```\npython main.py\n```\n\nThe following webpage will be opened in your default web browser. \n![image](https://github.com/saiccoumar/MyFridge/assets/55699636/01fe195a-a95d-407a-a594-0603e6303046)\n\nFrom here you can navigate the application with the UI\n\n# Features\nMyFridge has several features. The main functionality is being able to add custom ingredients to the inventory, as well as relevant information (Ingredient, Unit, Calories per Unit, Quantity). Relevant information about calories and units can be found from food health websites, like https://www.nutritionix.com/  \n![image](https://github.com/saiccoumar/MyFridge/assets/55699636/1834f2b6-b560-4c97-aadb-cacb544e0ea0)\n\nUsers can manually increment/decrement the quantity of ingredients or take advantage of the restock feature. When a user makes a mass restock, via a grocery run, they can use a restock form instead of manually incrementing the ingredients' quantity one by one. There's a search feature so users can search for the ingredients they've restocked \n![image](https://github.com/saiccoumar/MyFridge/assets/55699636/f9f420ba-d272-4fd5-8bf9-2a7d5068c313)\n\nSince ingredients can accumulate, there's a search feature with multiple filtering options. I'll cover how this works in detail later.\n![image](https://github.com/saiccoumar/MyFridge/assets/55699636/c7c07ff9-d1bd-430c-a7e1-ac429293bf35)\n\nMyFridge also manages users' recipes. A user can 'use' a recipe and MyFridge will automatically update the inventory to keep track of the ingredients consumed. Ideally, a user would upload recipes they use often. When they make a meal, they'll 'consume' the recipe as well as all the ingredients required. The recipes can also be searched, similar to ingredients. \n![image](https://github.com/saiccoumar/MyFridge/assets/55699636/8989ff8d-6e01-4a3b-9008-3a0874153bac)\n\nRecipes can be viewed as well, in case a user needs a reminder on how to make a dish. Further information about the dish is displayed as well (ex. cuisine, diet type). \n![image](https://github.com/saiccoumar/MyFridge/assets/55699636/85ebad93-c364-4bf2-b03d-8d78ebeba76f)\n\n# Development Process\nWhen I started designing this project, there were the big three components to consider. The front-end, the back-end, and the database system. Since this project focuses more on the database system, I opted to reuse the html front-end and flask back-end from another project, and spent more effort on designing and polishing the database system. There were many options I considered for the DBMS: MySQL, SQLite (SQLAlchemy), MongoDB, Neo4j, etc. I ruled out non-relational DBMS systems since the added flexibility wouldn't have provided me any benefit and I got more value out of the structured record systems. I could also use more features like ORMs and Stored Procedures that aren't available in non-relational DBMS, and there were some search benefits as well. Between MySQL an SQLite...SQLite is just easier. For production environments and applications, MySQL is objectively better, but for my small-scale locally hosted application using SQLite was much easier. Setting up a MySQL sequel for a small DBMS was so excessive. \nBefore any programming, I made an ERD for the database:\n\u003cbr /\u003e\n![db_design](https://github.com/saiccoumar/MyFridge/assets/55699636/9b65890d-f34c-4001-99d1-9ce6602aaeac)\nWith the following schemas:\n```\nTABLE Ingredients ( \ningredient_id INTEGER PRIMARY KEY,\ningredient_name TEXT,\nquantity_available REAL,\ncalories_per_unit INTEGER\n); \n\nTABLE Recipes ( \nrecipe_id INTEGER PRIMARY KEY,\nrecipe_name TEXT, \nDietType TEXT, \nApproximateTotalCalories INTEGER,\nCuisine TEXT\n);\n\nTABLE RecipeIngredients ( \nPRIMARY KEY (recipe_id, ingredient_id),\nrecipe_id INTEGER,\ningredient_id INTEGER, \nquantity_required REAL\n);\n```\n\nThen I sketched out the UI:\n\u003cp align=\"middle\"\u003e\n  \u003cimg src=\"https://github.com/saiccoumar/MyFridge/assets/55699636/3227c112-56fd-4a65-b600-2f6539e9e303\" width=\"30%\" /\u003e\n  \u003cimg src=\"https://github.com/saiccoumar/MyFridge/assets/55699636/6af8a925-83e1-4065-8ab8-c7c8e6b9c309\" width=\"30%\" /\u003e \n  \u003cimg src=\"https://github.com/saiccoumar/MyFridge/assets/55699636/5a436197-9233-4c8a-9ba1-1174c25d2430\" width=\"30%\" /\u003e\n\u003c/p\u003e\n\u003cp align=\"middle\"\u003e\n\n  \u003cimg src=\"https://github.com/saiccoumar/MyFridge/assets/55699636/c82f272a-88d6-429a-b64b-3c839a17c02f\" width=\"30%\" /\u003e\n  \u003cimg src=\"https://github.com/saiccoumar/MyFridge/assets/55699636/36165f34-9a77-4aca-af3a-4ce85e34c95d\" width=\"30%\" /\u003e\n\u003c/p\u003e\n\nWhile implementing the DBMS, I used Object-Relational Mapping to define my tables and add items into the DBMS. This was a feature of SQLAlchemy that isn't standard with SQLite3 and really came in handy. This simplified the upload process as well as simple accesses to the database such as get_by_id and delete. For the search feature, I used a store procedure approach for a more distinct result. I made the stored procedure by concatenating predefined strings with input strings to form a whole query and then ran said query. \nTo improve searching speed, I indexed the database based on likely common searches. \n\n### Indexes available:\n\u003e db.Index('idx_name_unit', Ingredient.name, Ingredient.unit)\n\u003e Specific Queries that benefit:\n\u003e order by name, unit - SELECT * FROM (SELECT * FROM ingredient WHERE LOWER(ingredient.name) LIKE {pattern})  ORDER BY {[name, unit]}\n\n\u003e db.Index('idx_name', Ingredient.name)\n\u003e Specific Queries that benefit:\n\u003e order by name - SELECT * FROM (SELECT * FROM ingredient WHERE LOWER(ingredient.name) LIKE {pattern})  ORDER BY {[name]}\n\u003e order by name - Ingredient.query.filter_by(name=request.form['name']).first()\n\u003e order by name - Ingredient.query.filter(Ingredient.name.ilike(f\"%{ingredient_search}%\")).all()\n\n\u003e db.Index('idx_unit', Ingredient.unit)\n\u003e Specific Queries that benefit:\n\u003e order by unit - SELECT * FROM (SELECT * FROM ingredient WHERE LOWER(ingredient.name) LIKE {pattern})  ORDER BY {[unit]}\n\n\u003e db.Index('idx_quantity', Ingredient.quantity)\n\u003e Specific Queries that benefit:\n\u003e order by quantity - SELECT * FROM (SELECT * FROM ingredient WHERE LOWER(ingredient.name) LIKE {pattern})  ORDER BY {[quantity]}\n\u003e filter for quantity != 0 to show in stock items - SELECT * FROM (SELECT * FROM ingredient WHERE LOWER(ingredient.name) LIKE {pattern})  ORDER BY {[quantity]} WHERE quantity \u003e 0\n\n\n\u003e db.Index('idx_calories', Ingredient.calories)\n\u003e Specific Queries that benefit:\n\u003e order by calories - SELECT * FROM (SELECT * FROM ingredient WHERE LOWER(ingredient.name) LIKE {pattern})  ORDER BY {[calories]}\n\nI chose to index on any of the filtering options so that the reports would generate faster. I also picked the composite key of name, unit as well as individual keys because I think those are the keys that users will want to generate reports on the most frequently. There are cases where a user could order by every option, but I imagine those are much more unlikely and the efficiency benefit might not outweigh the cons of having so many indexes.\n\n# Takeaways\nDuring the development of this project, there were a lot of recurring ideas that came up.\n1. SQLite and relational databases are absurdly valuable; having a structure made modifying data and synchronizing record consistency extremely simple. Prior to this, I had always preferred JSON format because of how flexible it was (and how little effort I put into data structure), but structured data with predefined schemas helps make transactions easier to track and enforced ACID properites make transactions reliable. This whole application would've been much messier had I used non-relational JSON formatted data instead and I saved myself a huge headache using SQLite instead\n2. Flask/HTML is getting old. My design sucks and just looking at some ways I could improve it, it became very clear just how much more prevalent Javascript frameworks have become in creating UIs. A lot can change in a few years\n3. Routing can get extremely complex along the way. In my main.py, I have 14 routes, some of which are subroutes. A lot of this can be refactored to be more readable and I wish I had planned that ahead of time instead of cluttering up my code. In a production application, I would've separated recipes into it's own API that the MyFridge would redirect to rather than take a monolothic approach. \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaiccoumar%2Fmyfridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaiccoumar%2Fmyfridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaiccoumar%2Fmyfridge/lists"}