Skip to content

Revprm/Nutrigrow-Backend

Repository files navigation

Nutrigrow-Backend

Overview

A Backend Repository for Nutrigrow Project. This backend is built with Go, Gin, and GORM, following a Clean Architecture approach. It provides a robust API for managing user data, stunting records, news, food recipes, and their ingredients.

Features

  • User Management: Register, Login, Refresh Token, User Profile (Me), Update/Delete User, Email Verification.
  • Stunting Records: Create, Retrieve (by ID, by User ID, latest by User ID), Update, Delete stunting records.
  • Stunting Prediction: API endpoint to predict stunting status using an external ML model.
  • News Management: Create, Retrieve (by ID, by Category, All with Pagination), Update, Delete news articles.
  • News Category Management: Create, Retrieve (by ID, by Name, All), Update, Delete news categories.
  • Food Recipes Management: Create, Retrieve (by ID, by Name, All with Pagination, by Ingredient), Update, Delete food recipes.
  • Ingredient Management: Create, Retrieve (by ID, by Name, All with Pagination), Update, Delete ingredients.
  • Database Migrations & Seeding: Tools to manage database schema and populate initial data.
  • Authentication: JWT-based authentication for secure API access.
  • Logging: Built-in system for monitoring and tracking system queries with a web interface.

Prerequisite 🏆

  • Go Version >= go 1.20
  • PostgreSQL Version >= version 15.0
  • Docker & Docker Compose (for Dockerized setup)

How To Use

  1. Clone the repository
git clone https://github.com/Revprm/Nutrigrow-Backend.git
  1. Navigate to the project directory:
cd Nutrigrow-Backend
  1. Copy the example environment file and configure it:
cp .env.example .env

There are 2 ways to do running

With Docker

  1. Build Docker
make up
  1. Run Initial UUID V4 for Auto Generate UUID
make init-uuid
  1. Run Migration and Seeder
make migrate-seed

Without Docker

  1. Configure .env with your PostgreSQL credentials:
DB_HOST=localhost
DB_USER=postgres
DB_PASS=
DB_NAME=
DB_PORT=5432
  1. Open the terminal and follow these steps:
  • If you haven't downloaded PostgreSQL, download it first.
  • Run:
    psql -U postgres
  • Create the database according to what you put in .env => if using uuid-ossp or auto generate (check file /entity/user.go):
    CREATE DATABASE your_database;
    \c your_database
    CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; // remove default:uuid_generate_v4() if you not use you can uncomment code in user_entity.go
    \q
  1. Run the application:
go run main.go

Run Migrations and Seeder

To run migrations and seed the database while keeping the application running, use the following command:

go run main.go --migrate --seed --run
  • --migrate will apply all pending migrations.
  • --seed will seed the database with initial data.
  • --run will ensure the application continues running after executing the commands above.

Migrate Database

To migrate the database schema

go run main.go --migrate

This command will apply all pending migrations to your PostgreSQL database specified in .env

Seeder Database

To seed the database with initial data:

go run main.go --seed

This command will populate the database with initial data using the seeders defined in your application.

API Documentation

You can explore the available API endpoints and their usage through the Postman Documentation:

About

A Backend Repository for Nutrigrow Mobile Application Built with Go, Gin and GORM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages