Skip to content

An API was developed (using the TDD method) and also integrated through docker-compose the applications so that they work consuming a MySQL database. In this project, a dockerized back-end was built using data modeling through Sequelize.

Notifications You must be signed in to change notification settings

m4rcos-dev/FullStack-project-trybe-futebol-clube

Repository files navigation

🎉 Welcome to my TFC - Trybe Futebol Clube project repository

swagger documetation blogs api

flag tools flag tools flag tools flag database flag ormflag architecture flag desingflag test

Project developed during the back-end module of the Trybe full-stack web development course.

TFC is an informational website about football matches and rankings!⚽

An API was developed (using the TDD method) and also integrated through docker-compose the applications so that they work consuming a MySQL database.

In this project, a dockerized back-end was built using data modeling through Sequelize. Business rules were respected for the API to connect correctly with the Front-End.

To add a match you need a token, so the person must be logged in to make the changes. It has a relationship between teams and matches tables to make updates to matches

The backend follows business rules to properly populate the table available in the frontend that will be displayed to the person using the system

🔨 Project Resources

    The project is composed of 4 important entities for its structure

    1️⃣Database

  • ✅It's a dockerMySQL container already configured in docker-compose through a service defined as db.
  • ✅Has the role of providing data to the backend service.

  • 2️⃣Back-End

  • ✅EndPoint for user to login with their email and password validated by token via Jwt
  • ✅EndPoint to list all registered matches, using the GET method
  • ✅EndPoint to register a new game, using the POST method.
  • ✅EndPoint to update the goals of a match, using the PATCH method.
  • ✅EndPoint to update the status of a match, using the PATCH method.
  • ✅EndPoint for lists the information of the matches played at home by the teams and their classification in the general scoreboard, using the GET method
  • ✅EndPoint for lists information on matches played away by teams and their ranking on the overall scoreboard, using the GET method
  • ✅EndPoint for lists the information of all matches and the ranking of teams on the overall scoreboard, using the GET method

  • 3️⃣Front-End

  • ✅Developed in React
  • ✅Communicates with the backend service via the url http://localhost:3001 through the endpoints created in the backend.

  • 4️⃣Docker

  • ✅docker-compose is responsible for uniting all containerized services (backend, frontendb) and uploading the complete project with the command npm run compose:up or npm run compose:up:dev

▶️ Running application

🐋 Running on Docker

ℹ️ Install dependencies with npm run install:apps.

⚠️ Before starting, your docker-compose needs to be at version 1.29 or higher. See here ou in the documentation how to install it. In the first article, you can replace where you are with 1.26.0 with 1.29.2.

ℹ️ Run the backend, frontend and db services with the docker-compose up -d --build command.

  • Remember to stop mysql if you are using it locally on the default port (3306), or adapt it, if you want to use the application in containers;

  • These services will initialize a container named app-backend, app-frontend and another named db;

  • From here you can access the application at http://localhost:3000;

  • The back-end endpoints are found at http://localhost:3001;

  • ⚠️ Attention: Do not run the npm audit fix command! It updates several project dependencies, and this update causes conflicts.

  • Tip: The Remote - Containers extension is indicated so that you can develop your application in the Docker container directly in VS Code, as you do with your local files.

🎲 ER and Entities Diagram

Entity-Relationship Diagram

der


⚠️ The package.json in the app/backend directory contains a scriptdb:reset which is responsible for "dropping" the database, recreating and executing the migrations and seeders. You can execute it with the command npm run db:reset if for some reason you need to recreate the database.

⚠️ Any execution referring to sequelize-cli must be performed inside the app/backend directory. Make sure that before running sequelize commands there already exists a compiled back-end version (app/build directory), otherwise just run npm run build to compile. Sequelize will only work correctly if the project is compiled .

⚠️ sequelize has already been initialized, so it is NOT necessary to run sequelize init again.


🏦 Users and Passwords

The application has a pre-registered default user and password and with its admin permissions activated in the bank. Use to test the application.

Email: [email protected]

Password: secret_admin


🧪 Running backend coverage tests
To run coverage tests on the backend, use the command: `npm run test:coverage`.

⚠️ For the above command to work locally (outside the container) you must configure the .env file in the root of the back-end with the environment variables below.

   JWT_SECRET =jwt_secret
   APP_PORT=3001
   DB_USER=your_user
   DB_PASS=your_password
   DB_HOST=localhost
   DB_PORT=3306

🧔 Author

About

An API was developed (using the TDD method) and also integrated through docker-compose the applications so that they work consuming a MySQL database. In this project, a dockerized back-end was built using data modeling through Sequelize.

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •