Skip to content

[Node.JS] - CRUD API RESTful with ORM (Sequelize) and MySQL, SOLID's principles, layered architecture (Model, Service and Controller) and Object-Oriented Programming - OOP

Notifications You must be signed in to change notification settings

dopimentel/backend-trybe-futebol-clube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Site preview

DigitalOcean Referral Badge

(earn 200 dollars)

💻 What is it about?

TFC is an website about football matches and ranking. If you are logged in, it is possible to edit and register new matches, as long as you are an admin user (authentication and authorization).
It is running on a DigitalOcean Droplet. Three services (backend, frontend, and MySQL database) are running in Docker containers. It was set up using Bash. Link demo: http://projects.pimentel.live/tfc/


URL to the client application: http://projects.pimentel.live/tfc

Use the admin user to login

email: [email protected]
password: secret_admin

Endpoints GET: /teams /teams/:id /matches matches/:id /leaderboard /leaderboard/home /leaderboard/away You also can see the server side running: http://projects.pimentel.live:3001

Endpoints GET: /teams /teams/:id /matches matches/:id /leaderboard /leaderboard/home /leaderboard/away

(e.g. http://projects.pimentel.live:3001/matches)


About Me


Built With

Node.jsDockerExpresssequelizeMySQLTypescriptJWT

Table of Contents

Dockerization

This project utilizes Docker for containerization, including the Dockerization of apps, network, volume, and compose.

Data Modeling

Data modeling is achieved using MySQL in conjunction with Sequelize. This involves the creation and association of tables using Sequelize models.

API RESTful Development

The project involves the construction of a RESTful API with endpoints to consume the models created during data modeling.

CRUD with TypeScript

A CRUD (Create, Read, Update, Delete) functionality is implemented using TypeScript, with the support of an Object-Relational Mapping (ORM) for efficient data manipulation.

SOLID Principles

The project follows the SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) to promote maintainability, >scalability, and readability in the codebase.

Layered Architecture

The project adopts a layered architecture, organizing code into distinct layers (e.g., presentation, business logic, data access) to enhance modularity, flexibility, and >maintainability (Controller, Service and Model).

This project is dockerized and uses data modeling through Sequelize. The API is consumed by a pre-provided front-end.

⚠ Warning

Getting Started

⬇️ Pre-install

Before you begin, ensure you have the following prerequisites installed:

  • Node.js (16.14.0 LTS or higher): bash nvm use 16.14
  • Docker (2.5 or higher): bash docker-compose --version

⬇️ Installation

  1. Choose how to clone the Repository:
    # Clone using HTTPS
    git clone https://github.com/dopimentel/back-end-trybe-futebol-clube.git
    
    # Clone using SSH
    git clone [email protected]:dopimentel/back-end-trybe-futebol-clube.git
    
  2. Acess the project root folder:
    cd back-end-trybe-futebol-clube
    

⚡ Running the Aplication

  1. You can run the entire application with only one command! Open an integrated terminal on root directory and run this command:

    npm run compose:up

Wait a while (to make sure the container has finished loading) then you can access the application in your browser at localhost:3000 to use the client application or localhost:3001 to see the server side through endpoints (/matches, /teams, /leaderboard) (e.g: http://localhost:3001/leaderboard/).

  1. Use this user to log in as an administrator:

    email: [email protected]
    password: secret_admin
  2. When you finish, you can remove these containers with:

    npm run compose:down

🧪 Testing the Aplication

Make sure you are in /backend folder

npm run test

💬 Contact Me