Giter Site home page Giter Site logo

calories-api's Introduction

Calories API

Welcome to CaloriesAPI! Here you will find an Application Programming Interface (API) focused on helping people to manage their meals and control the number of calories consumed per day based on NutritionixAPI data that is listed on Public APIs repository.

Description and Technologies

The CaloriesAPI is a TypeScript RESTful API and the main techologies used for its development were:

Running the app

Requirements

How does this project uses NutritionixAPI and a MongoDB ReplicaSet cluster. Thus, you must follow these steps:

  1. Setting up NutritionixAPI's credentials in a .env file

    1. Create a free tier developer account in NutritionixAPI and get your personal credentials
    2. In the project root, copy the content of .env.example, create a file called .env and pass it to your .env file.

    image

  2. Setting up MongoDB You can choose two ways to setup the application's database:

    1. With Docker using docker compose (your don't need to change the copied DATABASE_URL in .env):
    # starts your mongodb replicaset locally
    $ docker compose up mongo -d
    
    # setup the collections and indexes
    $ npx prisma db push
    1. With MongoDB Atlas (free tier): The easiest way to setup a replica set cluster is using MongoDB Atlas. First, create a MongoDB Atlas instance, update the environment variable DATABASE_URL with your instance url adding the paramater authSource=admin (as it is in the .env.example file). To create your instance using atlas see: Get Started with Atlas

All setted up? Let's execute!

  1. With Docker:
# watch mode
$ docker compose up api-dev

# production mode
$ docker compose up api-prod
  1. With a NodeJS package manager:

NOTE: This project was created using the Node package manager Yarn (recommended), but feel free to use NPM or other ones.

# watch mode
$ yarn
$ yarn start:dev

# production mode
$ yarn
$ yarn build
$ yarn start

Test

This project has 100% unit test coverage (ignoring files that cannot be unit tested). To run the tests execute in your command line (CLI):

# unit tests
$ yarn test

# test coverage
$ yarn test:cov

NOTE: If you haven't done before, run yarn to install the dependencies before testing.

Using the app

Seeding

To improve your experience, some simple database seeds of users were created. Run the following command on your CLI:

$ npx prisma db seed

Postman Collection

Thinking on practice, use the url: https://www.getpostman.com/collections/91c478d0c1a7b9fd5d9c to import a collection inside your Postman:

image image

Afther that, you need to set the following globals variables on your workspace environment:

image

Done! Now you are ready to use the API locally. Make requests and change the parameters as you go.

image image

Next steps

  • Save public data from NutritionixAPI when getting a response from an user's input;
  • Implement an own Natural Language Processing (NLP) to avoid calls to NutritionixAPI;

calories-api's People

Contributors

eric-kreis 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.