TowFood PWA: An integrated Database system for the TowFood Larders By Sebastian Prentice UNIVERSITY OF BUCKINGHAM SCHOOL OF COMPUTING FINAL PROJECT 2022 2016525 Sebastian Prentice 1 Declaration: I solemnly declare that the project report TowFood PWA is based on my own research under the supervision of HONGBO DU. I declare the statements made and the conclusions drawn are a result of my own research. I further certify that: I. The work in the repo rt submitted is my own and original and I have done it myself under the supervision of HONGBO DU. II. I have not submitted the work to any other institute for any degree/diploma/certificate. III. I have followed the guidelines provided by the university wh ile writing my report. IV. I have referenced the source for any information/data/graph etc. used/quoted in the report. 26 - Sep - 22 Sebastian Prentice 2016525 Sebastian Prentice 2 Abstract: Established in January 2021, Towcester Community Food (TowFood) is a community project that partners with local supermarkets, businesses , and food surplus providers to reduce food waste and distribute affordable food throughout the community. how food is now over a year old and needs a databa se to keep track of the food products collected by its volunteers and the food products picked up by members of the service . The current systems are inefficient and inconsistent, using a matter of different lists in a single paper notebook, which is curren tly managed by one person. The proposed system uses Django, Tailwind CSS , and a n SQLite database to provide the volunteers of TowFood Community Food the ability to manage stock, and perform create, read, update and delete (CRUD) operations on stored stock data themselves . Including adding products to a specific larders stock, from a specific supplier by a specific volunteer, removing items from a specific larders stock, to a specific member by a specific volunteer. These two functions provide the systems with all the stock data which is then analyzed for Report generation, showing member, supplier, volunteer , and stock data on a monthly or daily basis 2016525 Sebastian Prentice 3 Table of Contents Navigate w ith hyperlinks from this page Declaration: ................................ ................................ ................................ .................. 1 Abstract: ................................ ................................ ................................ ....................... 2 Table of Contents ................................ ................................ ................................ .......... 3 1. Introduction ................................ ................................ ................................ ............... 5 1.1 What the project is about, its aims, and objecti ves: ................................ .......................... 5 1.2 The background of the project: ................................ ................................ ........................ 5 1.3 The scope of the project: ................................ ................................ ................................ 6 1.4 Impacts and Benefits of the Result Software ................................ ................................ .... 6 2. Review of literature: ................................ ................................ ................................ .. 7 2.1 EAN Data ................................ ................................ ................................ ........................ 7 2.2 Existing Similar Systems ................................ ................................ ................................ ... 8 2.2.1 Food Bank Manager Software and Donor System ................................ ................................ ............. 8 2.2.2 ZOHO Inventory ................................ ................................ ................................ ................................ .. 8 2.2.3 Food management systems ................................ ................................ ................................ ............... 9 2.4 Notes from literature review ................................ ................................ ........................... 9 3. User Requirement Collection and Analysis ................................ ................................ 10 3.1 Requirement collection ................................ ................................ ................................ 10 3.2 User research: ................................ ................................ ................................ ............... 10 3.3 Data requirements: ................................ ................................ ................................ ....... 11 3.4 Functional requirements: ................................ ................................ .............................. 11 3.5 Non - Functional requirements: ................................ ................................ ....................... 12 3.6 Data operation and analysis: ................................ ................................ ......................... 12 4. Software Design ................................ ................................ ................................ ...... 15 4.1 System structure design: ................................ ................................ ............................... 15 4.2 Database Design: ................................ ................................ ................................ ........... 17 4.3 User interface design: ................................ ................................ ................................ .... 17 4.4 Report Design: ................................ ................................ ................................ .............. 20 5. Implementation and Testing ................................ ................................ .................... 22 5.1 The development stack and its changes ................................ ................................ ......... 22 2016525 Sebastian Prentice 4 5.2 Core Infrastructure ................................ ................................ ................................ ........ 23 5.3 User Interface (Front End) ................................ ................................ .............................. 24 5.4 Back end ................................ ................................ ................................ ....................... 25 5.4.1 Performing a Collection (Stock In) ................................ ................................ ................................ ... 25 5.4.2 Performing a Pick - up (Stock Out) ................................ ................................ ................................ ..... 28 5.4.3 Report Generation ................................ ................................ ................................ ........................... 29 5.5 Implementation problems encountered and resolved ................................ .................... 30 5.5.1 Identify threats and issues ................................ ................................ ................................ ............... 30 5.5.2 Estimate risk and problem - solving ................................ ................................ ................................ ... 30 6. Testing ................................ ................................ ................................ .................... 35 6.1 Testing Strategy ................................ ................................ ................................ ............ 35 6.2 Unit Testing Results ................................ ................................ ................................ ....... 35 6.2.1 Collection Test Results ................................ ................................ ................................ ..................... 35 6.2.2 Pick - up Test Results ................................ ................................ ................................ .......................... 36 6.2.3 Report Test Results ................................ ................................ ................................ .......................... 37 6.3 Integration Testing Results ................................ ................................ ............................ 38 6.3.1 Functional requirements tests: ................................ ................................ ................................ ........ 38 6.3.2 Non - Functional requirements tests: ................................ ................................ ................................ 39 7. Overall evaluation ................................ ................................ ................................ ... 40 8. Project plan ................................ ................................ ................................ ............. 40 9. Conclusion & Future work ................................ ................................ ........................ 41 9.1 Conclusion ................................ ................................ ................................ .................... 41 9.2 Future wor k ................................ ................................ ................................ .................. 41 11. References ................................ ................................ ................................ ............. 42 2016525 Sebastian Prentice 5 1. Introduction 1.1 What the project is about, its aims , and objectives : Aim: To design and develop a scalable and easy - to - maintain database with a progressive web app for managing information for the Towcester Community Larder Network, named TowFood PWA Objectives: - To investigate the real needs and essential data items to be maintained - To correctly understand functional aspects of data operations for TowFood - To design a correctly functioning database - To design a scalable system infrastructure with a back - end database platform on a server - To develop an easy - to - use app front - end interface for data capturing and acquisition. - To ensure seamless data flow connection between the f ront - end apps and the back - end database - To investigate the effective use of cloud platforms for supporting the back - end database. - To ensure thorough testing of the developed software. 1.2 The background of the project : During the covid pandemic , it has become evident that certain groups of people in the community need help with getting essential items such as food items, toiletries, and other household necessities. Due to various reasons, normal supermarket visits by people in such posi tions may be impossible. Yet, there is a huge amount of food waste by suppliers such as supermarkets. Food items are often thrown away simply because the items are not sold and/or out of the "best sell by" dates even though the items are still perfectly al l right for human consumption. To reduce food wastage, the government charges supermarkets per tonne of food waste. To reduce waste and help people in need, supermarkets give away food they have either over - ordered or is nearing its best before dates. Shop s and supermarkets often find it an incredibly difficult task to strike the right balance between the level of stock they need to maintain each day and the amount that could potentially go to waste. Towcester Community Food , a community project managed by the charity South 2016525 Sebastian Prentice 6 Northants Volunteer Bureau, partners with local supermarkets, businesses , and food surplus providers to reduce food waste and distribute affordable food throughout the community 1.3 The scope of the project : At TowFood the only computer system that is in use is a simple website displaying the Larders focus along with a donation link and sign - up link. The sign - up links use a google form, to collect new member data which in turn stores all member data in a google sheet. Aside from these tw o services , there are no other software systems currently in use for any other operations of the TowFood Larder. To take TowFood to the next step, we hope to have an all - in - one piece of software. To allow volunteers to access the current stock of the larder, track ingoing and outgoing food, and generate reports from data. Currently when a Volunteer does a pickup (ingoing stock) of food from a supplier, such as Tesco . They drive to the store, where they are given multiple trollies worth of food, which is then loaded into the vehicle and driven to one of the larder locations. Once the Volunteer has arrived the food has to be unloaded, separated into perishable and non - perishable , and products need to be weighed , dated, and logged down. Then the food can be put away for storage. This long process is made worse due to there not being a consistent written storage form and physical location, which means it is almost impossible to see what is cur rently in stock, let alone what stock is in multiple locations. 1.4 Impacts and Benefits of the Result Software The TowFood PWA would allow the volunteers to scan the barcodes of the products , which auto - fills an add product form, which in turn adds pr oducts to a database linked to the specific larder I f a product has no barcode the Volunteer can also manually enter the product details. This function will dramatically reduce the length of time needed to complete a pickup, as the majority of product wei ghts will be provided automatically. Along with the data being collected and stored consistently on a database instantly with all other pickups for each location. Currently, at TowFood larders there is no record process at all when it comes to food Gather ing (outgoing stock), Selected food is put out on tables with members selecting five non - perishable items and any items of their choosing from a perishable selection, then the members leave with their selected food products. 2016525 Sebastian Prentice 7 The TowFood PWA all ows the volunteers to select the collecting member and then proceed to scan the member's selected product barcodes, to autofill and collection form or manually enter a collection form. This data will help to analy z e stock data, to see what food items are in h igh demand along with being able to see what stock is in at each larder update live. 2. Review of l iterature: 2.1 EAN Data TowFood PWA's main functions will be to record ingoing stock from suppliers and outgoing stock to members. Each product needs to be tracked and data to be recorded to analyze the location of specific products. Rather than manual data entry, a barcode scanner could be used to enter product data. Over 90% of the products in TowFood's stock are barcoded. Time savings are very significant when using bar codes, SATO conducted a study where 25 employees completed inventory over a weekend, compared to 4 employees completing the whole inventory in 5 hours (STO America, 2020) Using barcodes will also help to reduce errors, as the aspect of human error is removed as the barcode will provide the same data each time. To read the EAN barcode number from the barcode and re ceive the product data, third - party source s can provide a da ta response with information on the product's name, weight, and c ategory (perishable vs non - perishable). There are a few different databases, some open - sourced and some private. Here are four databases that would work for this project: Barcode Lookup ( barcodelookup.com) is a database that has product information and images for 500 million entries worldwide. It has records of products using UPC, EAN, and ISBN barcodes. Data responded to the request are only the name and features attributes. Barcode Looku p's API provides no information on product categories or weight. Also, it is not accurate enough to use as a reliable source of data as Testing Barcode Lookup with a coke can barcode, it got the product wrong. Open EAN/GTIN Database is a product database, however, does not have as many products as the others and is not regularly updated. It is also In German, not English , converting response from German to English requires too much computational power EAN Search ( www.ean - search.org ) is an EAN database with over 310 million products with country of origin, manufacture, and product number. EAN search also provides a Barcode 2016525 Sebastian Prentice 8 creator based on a given EAN number. One issue with the EAN search database, it has a rather limited number of API calls before entering a paid tier, and the database is too broad as it doesn’t focus on food products. Also, it has a wide range of product categories, with limited specific product data. Upon testing EAN - search for data on a coke can, only the product name was returned. Open Food Facts (world.openfoodfacts.org) i s an open - source food products database wit h ingredients, allergens, and nutrition facts. Open Food Facts has a public API , providing a n EAN barcode in an HTTP request Open Food Facts will return product name, image, packaging, quantity, categories, ingredients, product NOVA group, and nutrition facts as JSON as the HTTP response to the request Open Food Facts provides all the data needed for ingoing stock collections currently noted plus m ore, it is also a free service that has no error and is reliable. With the use of a barcode API call function, I can parse only the data I want from each product into the TowFood products database quickly and with the trust of reliability. Extra data suc h as ingredients could be saved, to use later for notification of member allergens. 2.2 Existing Similar Systems 2.2 .1 Food Bank Manager Software and Donor System T he Food Bank Manager Software and Donor System is a piece of software targeted at food banks. Its main features are stock management , set predefined food parcels or bespoke parcels , access control, online referrals, security , reporting , and the ability to track incoming donations, allowing admin to track who donated what and when. The l imitations to this software are that it doesn't facilitate multi - location management tracking stock across multiple locations and seeing overall stock. Also, there is no function to manage volunteers. Also, data entry is manually entered, requiring a long learning curve for staff to learn how to use the devices. 2. 2.2 ZOHO Inventory Zoho Inventory is a stock management, order fulfillment, and inventory control software. Zoho is targeted toward businesses with multi - channel selling platforms, such as Amazon, eBay, or Etsy. They allow the client to manage orders across the selling platforms in one place, along with creating purchase orders, backorders, and drop shipments all in one place. 2016525 Sebastian Prentice 9 Zoho also provides a service for end - to - end parcel tracking, shipping in tegrations, and accounting support. Zoho Inventory system also focuses on selling inventory and linking to services that will not be used by Towcester Community Food such as amazon and eBay. The system does not cover staff management, tracking which member of staff worked on what item in the inventory. Being able to link volunteers to ingoing and outgoing functions is essential for Towcester Community Food for reporting and error checking. 2. 2.3 Food m anagement s ystems Food management systems provide softwa re for the food industry. Their software provides tools to allow its users to create and print labels for food products from a centralized cloud database on any device. Allergen Management, “pre - loaded with the 14 significant substances which form the current basic list of allergens” allows food ingredients to be recorded and products checked and flagged for allergen categorizations The Foo d management systems solution focuses on label printing and allergen check upon going inventory, however, does not provide a database of items in the inventory. 2. 4 Notes from literature review Research on product data sources and existing systems helps to evaluate that the majority of stock management software is for a commercial purpose with sales in mind, focusing on connecting to e - commerce platforms and sites However, f rom my findings, the useful functions for the TowFood app found in the Food Bank Ma nager software and Donor Management System are the ability to manage stock and track item location, date, supplier, and customer. From Food Management Systems, the ability to create labels based on product data as currently when taking inventory on incomin g stock, labels are written to indicate what the product is and the date of the inventory. Food Management systems also highlighted the importance of allergens “ 44% of British adults now suffer from at least one allergy ” (allergyuk.org) therefore it is imp ortant to consider implementing a function to compare member allergens to product ingredients and alert if there is a match. Product ingredients data, name, quantity, and category can be returned by an HTTP get request to Open Food Facts' API with the prod uct barcode in the query. 2016525 Sebastian Prentice 10 3. User Requirement Collection and Analysis 3.1 Requirement c ollection To gather information and the user requirements with no bias as to what I wanted to achieve on the project, I constructed open - ended interviews with the key stakeholders of the project, admins, volunteers, and members. Using open - ended questions allowed me to understand the stakeholders' pain points and areas that were working well. From my research, I was able to create a list of goals and frustrations for the key stakeholders in the project. 3. 2 User r esearch: TowFood app has three possible types of user s. Admins, Volunteers, and Members. Upon constructing my research I asked one person from each user type what their goals and frustrations were with the current system. Admin: - Long - standing volunteers or members of the board who are key decision makers. Admins apply for grants and manage overall stock and the management of the TowFood Larder network. At the moment they collect food from all over the county every day and store it in various locations. It is difficult to have a snapshot, at any one point to know what is available to share with all our members • Goals o Being able to quickly check stock for future orders fulfillment from suppliers o To create reports on food usage and member data o Improve efficiency through delegation by having information accessib le all in one place • Frustrations o Duplication of effort looking for information in lots of different places o Lack of data formatting consistency o Inability to check current stock o Failure to keep in contact with subscribers Volunteer: - Individuals from the co mmunity to participate in, collecting stock from supermarkets, stock organization, collection setups, and transportation. Having volunteered to help the village during lockdown I was approached by the parish clerk to distribute food boxes. In time I have been able to develop this into a sustainable project for all of the villages to benefit from. The feedback I get each week on how this impacts people of all ages is the greatest prize of all. 2016525 Sebastian Prentice 11 • Goals o To be able to understand and communicate what we are doing in contributing to the battle against climate change • Frustrations o Lack of resources in getting systems in place, means there are inefficiencies and anxiety on whether we have enough food to share Member: - Individuals within the community who wish to stretch their food budget further, or members of the community who need food security. “ The Larder has helped tremendously. I have shielded two very vulnerable adults since this started and the boxes have been a lifeline for us. The volunteers have also cheered me up when they deliver which has been really uplifting. ” • Goals o To access food at an affordable price o To maintain a work and family balance o To provide his 3 children with a balanced diet • Frustrations o Not knowing when their subs cription ends o Not knowing what food is available 3. 3 Data r equirements : 1. Data consistency , in the form of a constant data table structure for products, volunteers, members, suppliers, and ingoing and outgoing inventory data records. Constant table structure, assigning each table with attributes once, ensures each row of each table will contain data in the same format with the same attributes as the previous line, no matter where, when, or how the data was recorded. 2. No duplications of data , inventory ingoing, and outgoing functions , or data input, should occur live as the event occurs , resulting in the data only being inputted once. 3. One location for all data , to allow for access to functions and data from anywhere on any device with an in ternet connection. 4. Scalable infrastructure , allowing the database, user application, and functions to work with more members and larders without interference. 3. 4 Functional r equirements: 2016525 Sebastian Prentice 12 1. Volunteers should be able to quickly check the current stock at their specific larder location. 2. Admins should be able to see what essential products need to be ordered in time for the next collection day. 3. Volunteers need to be able to perform functions to track collections from a supplier (ingoing stock). 4. Volunteers need to be able to perform functions to track pickups from a Larder to a Member (outgoing stock). 5. Admins need to be able to see an overview of the total stock at each larder location. 6. Admins need to be able to perform a global product lookup to see where it is and what the quantity of that item is. 7. Admins need to be able to generate reports of food usage, and member, volunteer, and su pplier data 3. 5 Non - Functional r equirements: • The user interface needs to be intuitive to any user, allowing them , with no prior knowledge , to be able to pick up and understand how to use the web app • The user interface allows users to navigate through it with ease. • The user interface needs to be responsive for mobile, tablet, and smartphone use • Without prior knowledge, a volunteer needs to be able to look for a specific product in a larders stock. 3.6 Data operation and analysis: 2016525 Sebastian Prentice 13 2016525 Sebastian Prentice 14 This table indicates all the functions of the TowFood PWA along with which member group has what permissions to that function and data. Members will have very limited access to the data, only being able to see and edit the data on their personal informa tion, with the future possibility of access to payment setup with invoice history along with a dashboard indicating the total collected stock, updated allergens list, next payment date, and next collection date. Volunteers have the same access as the membe rs with the additional access to perform ingoing and outgoing stock management functions from the supplier and to the members. The Volunteers can see all details linked to each collection or gather, but cannot see any total stock data or data on the member s' details. Admins will have access to all data, the ability to see total stock data per location, edit member and volunteer data, and generate reports based on the date range. 2016525 Sebastian Prentice 15 4 Software D esign 4.1 System structure design : There are three key functions to the TowFood PWA, adding products to the stock, removing products from the stock, and generating reports. Each of these functions has a Model View Controller (MVC) architecture designed to break down aspects of development i nto different components : the Model stores and manages data, the View provides a graphical user interface and the Controller converts inputs from the view into data for the model. An MVC architecture allows developers to easily reuse code with higher cohesion which in turn makes it easier to maintain and modify. (edcative.com, 2022) Django, the web framework in which both the backend and front end of the TowFood PWA run provides an MVC pattern. ( Oyom, 2017 ) When using Django, to create a ny function, one must utilize its Model Template View For the adding products to the stock function: Recording outgoing products to members: 2016525 Sebastian Prentice 16 Generating Larder Reports : The Diagram shape is laid out like this due to the relationship between the co ntroller, view, and model. For example, the user navigates to the add product to stock page on the view (user action), the controller comprehends the request and (update)s the view to show the product form, once the user has inputted product information an d submitted the form (user action). The controller will (update) the product model in the database, followed by the model letting the controller know that the product was added successfully (notify), the controller then (update)s the view to indicate the p roduct was added successfully. 2016525 Sebastian Prentice 17 4.2 Database Design: There are 5 entity tables for the database design: Product, Volunteer, Member, Supplier, and Larder. Along with 3 relational tables: Collection (stock in), Gather (stock out) and update On the left, is an Entity relationship diagram and on the right, is a Relational database design diagram The entity relational diagram shows a collection (stock in) has a one - to - many relationship with products, as each collection will consist of multiple products. A collection will have a many - to - one relationship with member, date, and time, as each collection happens on one time on one date, from one larder , with one volunteer. A gather operation (stock out) has a one - to - many relationship with products, a s each gathering contains multiple products, whereas a gather will also occur at one time, on one date, from one supplier with one volunteer. The relational database indicates the relationships between tables with foreign key s and their origin. 4.3 User interface design : Using Adobe XD , a wireframing tool part of the Abode Creative Cloud , I was able to create a full mock - up of the User Interface for mobile devices for a mobile - first design 2016525 Sebastian Prentice 18 My goal when creating the User Interface was to meet th ese nine principles of good design for the web (feelingpeaky, 2021) : 1. Website Purpose Due to the limited data access of a Member I have focused on designing the UI for the Admin and Volunteer. Aside from the data permissions, the only real differ ence between the Admin and Volunteer UI is the Home, for the Volunteers the home page displays a calendar create, to indicate collections or volunteer hours, along with two buttons to start the ingoing and outgoing stock process. Whereas the admin home pag e has more of a data - driven dashboard, indicating total stock and its breakdown by larder location, Number of members, and the number of volunteers . Other main pages include Stock, Members, Scan In, Scan Out, and Report Generation Pages, along with subpage s to display total stock or perform a member lookup. 2016525 Sebastian Prentice 19 2. Simplicity All pages have the same minimalistic layout and position of the navigation, Title , and grid style content in the middle of the page. The Title in the top middle of the page allows the user to select a Larder location to see the data and run the functions relating to that Larder location. To keep consistency within all design aspects, I have chosen to use a dark theme around the Tow Food color scheme, focusing on the color purple. The design al so has one font throughout the User Interface, using font formatting to highlight titles, and form titles vs input areas. 3. Navigation Each page of the PWA has consistent and intuitive navigation at the bottom of each page, which provides the users with easy - to - use app navigation along with helping them indicate where they are on the site, with the icon color correlating to the page they are on. 4. F - shaped Pattern Reading “The F - shaped pattern is the most common way visitors scan text on a website” (fealingpeaky.com, 2021) knowing this , the UI is designed for the user to see the larder location, as that correlates to the rest of the data on the page. Below is the main conten t area, displaying data, and below is the menu. 5. Visual Hierarchy Visual hierarchy is emphasized with text size, weight, and location, relative to its positioning on the page or in a specific content area. For example, the Larder location is located in the top middle of each page as all other data on each page correlates to a Larder location . In our forms the input descriptions are in smaller font size and weight than the user input areas, highlighting the user's focus on the input areas. 6. Content The focus of the TowFood PWA is to be a data - heavy application, with a majority of content being numbers or tables of related data. As the content is numerically focused, means more focus can be spent on design rather than wording. 7. Grid Based Layout