Skip to content

MatheusSanchez/gym-check-in-api

Repository files navigation

SOLID STUDY

en pt-br

This repository is dedicated to the study of SOLID principles, Design Patterns, unit tests, integration tests, and GitHub Actions.

The structure of this repository includes the development of an API inspired by the GymPass style.

GymPass API

How to Execute

  1. Clone this repository to your local machine using the following command:
$ git clone https://github.com/MatheusSanchez/gym-check-in-api
  1. Navigate to the project directory and install the required dependencies by running:
$ npm install
  1. Create a .env file in the project directory to set the required environment variables. Refer to the provided .env.example file for the necessary variables and their values. .env.example

  2. Use Docker Compose to set up the database container. Run the following command in the terminal:

$ docker compose up -d
  1. Run Prisma migrations to create the database tables:
$ npx prisma migrate dev
  1. Launch the API by running the following command:
$ npm run dev

Check the terminal for the message: 🔥🔥🔥 HTTP Server Running 🔥🔥🔥

How to Test

Executing Unit tests is pretty simple; just run the following command:

$ npm run test

E2E tests

There are two scripts in the package.json file to set up the E2E tests, as the tests shouldn't add data to the real database.

You can execute the E2E tests using the following command:

$ npm run test:e2e

This script will trigger all the setup, and a new database will be generated to run the tests, which will be deleted after the tests are completed.

You can also check the tests through a UI and check the coverage, use the following commands:

$ npm run test:ui
$ npm run test:coverage

Functional Requirements (RFs)

  • User registration should be possible;
  • User authentication should be possible;
  • Retrieving the profile of a logged-in user should be possible;
  • Retrieving the number of check-ins performed by the logged-in user should be possible;
  • The user should be able to retrieve their check-in history;
  • The user should be able to search for nearby gyms (up to 10km);
  • The user should be able to search for gyms by name;
  • The user should be able to check-in at a gym;
  • Validating a user's check-in should be possible;
  • Registering a gym should be possible;

Business Rules (RNs)

  • Users should not be able to register with a duplicated email;
  • A user cannot make 2 check-ins on the same day;
  • A user cannot check in if not within 100 meters of the gym;
  • Check-in validation can only occur up to 20 minutes after its creation;
  • Check-in validation can only be performed by administrators;
  • Gym registration can only be done by administrators;

Non-Functional Requirements (RNFs)

  • User passwords need to be encrypted;
  • Application data must be persisted in a PostgreSQL database;
  • All data lists need to be paginated with 20 items per page;
  • User identification should be done through a JWT (JSON Web Token);

About

SOLID study, check-in-api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published