Skip to content

Proof of concept for modern web app

Justin Hester edited this page Jul 25, 2017 · 8 revisions

Features

  • Download a PDF report of meal tallies in specified date range (almost solves #3)
  • Loads libraries dynamically from mongodb collection libraries #4
  • Quick and dirty updates to web design via Ionic 3 #6
  • To view a prototype deployed on heroku, see codeforsanjose's slack channel #treemap.

Meal Tally Tutorial

  1. Select library and meal type; input number of meals received that day and meals leftover from previous meal session.

  2. Tally the meals quickly for the hungry herd!

  3. Input a unique signature and submit.

Screenshots

There are three visual columns in these screenshots. The columns represent the three main pages. From left to right, the pages are:

  1. Home - a tab with a form to input and to submit meal tallies
  2. Log - a tab with a form to input maintenance logs (i.e. food, fridge, etc.)
  3. Report - a tab that reports totals across meal categories and saves a local pdf file

This screenshot shows the initial views loaded on each page.

The home page scrolls down to reveal the remaining meal categories, a signature input, and buttons to reset all the tallies. The log page presents the options available when selecting for the user's current library. The totals are displayed when the user clicks "GET MEALS" and an input for the pdf file name and a "SAVE PDF" button are made available as well.

Confirmation windows appear when the "ADD MEAL", "ADD LOG", and "SAVE PDF" buttons succeed in their respective functionalities. The report page prompts the user on a pc with an option to open or save the generated pdf. The pdf document is automatically downloaded on mobile devices (note: only confirmed on android).

The generated pdfs are rudimentary, I'll admit, so feel free to share some feedback. I'm convinced this software solution can accomplish great things for the San José Public Library and all those people who will receive these free meals!

API Endpoints

Endpoint Method Description
/api/libraries GET Retrieve all library documents
/api/meals/:start/:end GET Retrieves reports of each meal type for each active library in date range [start, end] (e.g. /api/meals/2017-04-23/2017-04-29). See report schema for more info.
/api/meals POST Create a new meal tally entry
/api/log POST Create a new log entry (i.e. food, refrigerator, etc.)

MongoDB Collections

  • libraries: collection of Library documents
  • meals: collection of Meal documents
  • logs: collection of Log documents

MongoDB Document Schema

  • Library:
    • _id - unique document id; created automatically by mongodb
    • name - string of library's name
    • address - string of library's address
    • city - string of library's city
    • state - string of library's state
    • zip_code - string of library's zip code
    • phone_number - string of library's landline telephone
    • longitude - string of library's longitude coordinate
    • latitude - string of library's latitude coordinate
    • isActive - boolean set to true if library is active with meal program
  • Meal:
    • _id - unique document id; created automatically by mongodb
    • date - string of submission time in ISO-8601 format
    • library - string of Library name
    • mealType - string of meal type (e.g. Breakfast, Lunch)
    • numReceivedMeals - number of meals received from vendor
    • numLeftoverMeals - number of leftover meals used
    • numStaffMeals - number of meals served to staff
    • numChildrenMeals - number of meals served to children
    • numAdultMeals - number of meals served to adults
    • numVolunteerMeals - number of meals served to volunteers
    • numWastedMeals - number of non-reimbursable meals (i.e. damaged, spoiled, spilled, misplaced, etc.)
    • signature - string of user's signature
  • Log:
    • _id - unique document id; created automatically by mongodb
    • date - string of submission time in ISO-8601 format
    • library_id - string of Library document id from where a log was submitted
    • logType - string of log type (e.g. Food, Refrigerator)
    • description - string that describes log
    • temperature - number of temperature in units Fahrenheit
    • comment - string of comment with details about log

Report schema

NOTE: Reports are not in the database yet, but this schema has that potential to be stored in say a reports collection once we pin down SJPL's requirements for the PDF layout.

  • Report:
    • _id - json object used for mongo $group call
      • library: string of library name
      • mealType: string of meal type
    • totalReceived - number of total meals received by vendor
    • totalLeftover - number of total leftover meals used
    • totalStaff - number of total meals served to staff
    • totalChildren - number of total meals served to children
    • totalAdult - number of total meals served to adults
    • totalVolunteer - number of total meals served to volunteers
    • totalWasted - number of total meals wasted