Git Product home page Git Product logo

calorie-counter's Introduction

calorie-counter

A project to learn about REST

Abstract

An API where users can register and signin. They can add meals with the calorie information and if that info is not present nutritionix API is used to auto-populate calorie details. This API supports different roles, pagination and advanced searching capabilites.

Techical Learnings

  • Implemented authentication and authorization using Spring security.
  • Created REST resources using Spring boot.
  • Used Spring-Data and Hibernate for database related things.
  • Used Spring REST client to consume an external API.
  • Created Hibernate criteria queries using Specifications.
  • Implemetned pagination using Pageable.
  • API testing using Spring MockMvc.
  • Repository testing using DataJpaTest.
  • Unit and Integration testing with Spring.
  • Used Swagger for API documentation.

Could be better

  • Login/Register is implemented using traditional POST request could be done with JSON.
  • User can apply calorie limit but it is for all entries(BLUNDER). This should be a daily limit. Simple change is query.
  • PUT is creating resource if not present. I found on some places that it is okay but it is a doubt.
  • In user roles there is a loop hole where one role which manages users can downgrade admin.

How to run

  • Pull the repo.
  • Create a postgres database and update the details in src/main/resources/application.properties.
  • Uncomment spring.jpa.hibernate.ddl-auto=create so that it will create all the tables for you.
  • Create an API key at https://developer.nutritionix.com/ and update the details in src/main/resources/nutritionix.properties.
  • Run the spring boot application from src/main/Application.java.
  • Check the available API endpoints at http://localhost:8080/swagger-ui.html.

calorie-counter's People

Contributors

pc9795 avatar dependabot[bot] avatar

Watchers

James Cloos 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.