/nutrai-api

Get a diet plan using OpenAI's API. Restful API made with Go.

Primary LanguageGo

Nutrai API

This project contains a Go Restful API that helps users manage their diet plans. The diet plan is generated by an AI.

Table of Contents

Requirements

Initial Setup

Clone the repository

git clone https://github.com/christian-gama/nutrai-api.git

Initialize the project (DO NOT SKIP)

The command to initialize the project will automatically create the environment files if they don't exist and also make the git hooks and scripts executable.

make init

How to run

If you opt to run the project locally, without docker, it will start the Postgres image regardless and use it automatically. Both production and development modes does not run migrations automatically. Please refer to the migration section to learn more.

Development mode

The development mode will run the application using air. It will watch for any changes in the project and automatically reload if necessary.

make dev

OR

make docker-dev

Production mode

The production mode will build the project and run the binary that was built. It will also use the production environment variables.

make prod

OR

make docker-prod

Migrations

There are a few commands related to migrations. You can use: up, down, drop, reset, version and step. Each option is documented and explained in the makefile. Migrations never run automatically, you must explicitly run it.

Tests

Tests that contains database connection will automatically migrate the database schema before running the tests.

Run all tests

make test

Run unit tests

make test-unit

Run integration tests

make test-integration

Makefile

The Makefile contains all the commands needed to run the project, tests and build the docker image. Please read the Makefile for more details.

Help command

You can use the help command to see all the available targets with a short description. You can read the Makefile for more details about each target and how to use them.

make help

Code documentation