Coder Social home page Coder Social logo

caloriecounter's Introduction

The Calorie Counter Project (Java Version)

Description

Basic web page of your own fashion that tracks the calories consumed per meal in a persistent way. This runs in a browser and routes with links that route to particular pages, but it also provides an API to be able to communicate with other services. Uploading your project to Heroku should be optional, you can work on your local server with your local MySQL database.

Main Page

There should be a page that is sent as a response to starting up (index). It shows the title, perhaps a background image and then lists the meals in a table.

The table columns shown are:

  • meal date
  • type
  • description
  • calories
  • functions
    • edit
    • delete

Right below the title you can see a short statistic that shows the:

  • number of meals
  • total calories

Above the table you find the Add new meal button that navigates to the Add or Edit meal page

The type of meal comes from a database table:

  • Breakfast
  • Elevenses
  • Lunch
  • Snack
  • Dinner
  • Midnight Snack

Add or Edit meal page

This is a simple page that either adds a new meal definition or edits one.

The page shows the following form:

  • Date: [date field]
  • Type: [select with the values of the possible meal types]
  • Description: [text field]
  • Calories: [numeric entry]
  • Save button
  • Cancel button

Functionality:

  • In case of editing the values of the form elements are automatically filled with its current values.
  • The description field is optional, the others are mandatory.
  • By clicking on the save button:
    • if all mandatory fields are filled, the data gets saved to your database and the page redirects to the Main page
    • if one or more mandatory fields are empty, an error message appears listing the empty required field names
  • The user should be able to cancel: returning to the Main page

Delete a meal

It deletes the meal from your database and removes it from your table.

Create a REST API to your service

GET /getmeals

  • returns the meals list (the same that appears on your Main page) in JSON format

GET /getstats

  • returns the number of meals and the total calories value in JSON format

POST /meal

  • receives meal data in JSON format (e.g. {date : "2017-05-16", type : "Breakfast", description : "ham and eggs", calories : 250})
  • saves the meal as a new meal in the database
  • in case of successfull create, the response is {status : "ok"} JSON

UPDATE /meal

  • receives meal data extended the meal ID in JSON format (e.g. {id : 12, date : "2017-05-16", type : "Breakfast", description : "ham and eggs", calories : 250})
  • updates the meal with the given ID in your database
  • in case of successfull update, the response is {status : "ok"} JSON

DELETE /meal

  • recieves a meal ID in JSON format (e.g. id : 12)
  • deletes the meal with the given ID from your database
  • in case of successfull delete, the response is {status : "ok"} JSON

Endpoint tests

  • create tests for all your REST endpoints using Mock MVC

caloriecounter's People

Contributors

seed0forever avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.