Skip to content

GymTrack backend REST API now built with Spring Boot & PostgreSQL

Notifications You must be signed in to change notification settings

giavinh79/GymTrackApiV2

Repository files navigation

GymTrack Spring Boot REST API

Description

This is the second iteration of the API for the GymTrack application built with Java Spring Boot and PostgreSQL. It is currently being built and not close to being production ready.

The front-end repository can be found here: https://github.com/GV79/GymTrack.

See the full-stack application here

The API itself is deployed here and documented here using the OpenApi (Swagger) Specification.

Prerequisites

The following items should be installed in your system:

Running locally

GymTrack is a Spring Boot application built using Maven. It uses PostgreSQL as its data store which can be run locally using Docker (see docker-compose.yml file).

DB

In order to start up PostgreSQL, Redis, and pgAdmin:

test@user:~$ cd db && docker compose up -d

To connect to the PostgreSQL instance from a DB GUI tool (like pgAdmin), create a new server and pass postgres as the network. User credentials can be found in docker-compose.yml.

API

Need to look into handling secrets via AWS Secrets Manager for production deployments i.e. 1 , 2

  • The API will run locally at: http://localhost:3030/
    • Build the project with Maven and run it locally in your favourite IDE
    • Make sure to set environment variable GOOGLE_APPLICATION_CREDENTIALS in your run configuration pointing to the Firebase Private Key file
    • Some routes are protected by Firebase Auth (you can grab the token by logging in to the client app and checking network or alternatively)
  • The API documentation (OpenAPI + Swagger) will run at: http://localhost:3030/swagger-ui.html

Development

  • Using IntelliJ IDE
  • Authentication is currently being powered by Google Firebase
    • Ensure you create and setup different Firebase environments for dev vs. prod
  • MapStruct is used for transforming entities from one type to another
    • Rebuild project / Recompile Mapper file if MapStruct did not automatically update yet
  • Useful local development commands for database & cache
    • docker exec -it redis-container-name redis-cli -a your-password FLUSHALL for clearing local Redis cache
    • mvn flyway:clean to clear all PostgreSQL migrations (and thus delete all db data)

Project Structure

This Spring Boot project follows a typical N-tier architecture and organizes folder firstly by feature/domain (as opposed to type).

Database

The PostgreSQL schema ER diagram can be found here (need to login & could be outdated): https://lucid.app/lucidchart/dd9442a0-7dd9-4202-a0d6-0ac82ad5bff2/edit?invitationId=inv_613c1097-affe-4ccf-9781-51b230058742

GymTrack Schema

The project uses Flyway as version control for the database (managing DB migrations).

CI/CD & Deployment Process (TO DO)

CI/CD to be handled using GitHub actions.

Spring Boot server to be deployed on AWS Lightsail and will use Supabase for a fully-managed PostgreSQL cloud instance.

TO DOs development

For fun

Maybe look into Hexagonal Architecture https://www.youtube.com/watch?v=ujb_O6myknY&t=287s

About

GymTrack backend REST API now built with Spring Boot & PostgreSQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published