Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.
/ mybudget-backend Public archive

A personal budget management REST API built in Nodejs, Express, Sequelize.

Notifications You must be signed in to change notification settings

n-caro/mybudget-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mybudget-api

Overview

A personal budget management 💸 REST API built in Nodejs, Express, Sequelize. AlkemyLabs JS Challenge resolution.

This is the backend (server side) of the myBudget app. To see the frontend (client side) visit the repository: github.com/n-caro/mybudget-frontend

baboon with money 😆

Table of contents

1. About API

  • API RESTFul level 2, node.js (express)
  • N-Layer architecture
    • routes
    • controllers
    • services
    • repositories
  • SQL Database, with Sequelize ORM
  • Authentication: JWT (Json Web Token) and bcrypt for password encryption.
  • Dependency injection: (awilix)
  • Docs: Swagger

Database model

diagram database

2. Install and usage

Preparing the database

You must create a database and import/run the SQL scripts from folder /database. In the following order

  1. mybugdetDB-DDL.sql : script for database structure creation (Data Definition Language)
  2. mybugdetDB-DML.sql : script to add data: types of operations and categories (Data Manipulation Language)

Example with mysql command-line client:

mysql -u username -p myBudgetDB < mybudgetDB-DDL.sql
mysql -u username -p myBudgetDB < mybudgetDB-DML.sql

Install dependencies

npm install

Setting environment variables

Create a .env file into the root folder. You can edit the .env.example file and rename it.

.env

APPLICATION_NAME = mybudget-api
DB_CONNECTIONURI=mysql://user:password@localhost:3306/mybudgetDB
JWT_SECRET = 'jwt_secret_key'
JWT_EXPIRATIONTIME = 24h
PORT = 4000

Usage

Run script:

npm start

165 / 5000 Resultados de traducción After seeing the message that the application is running, you can see the documentation and use the endpoints from swagger. http://localhost:/{PORT}/api-docs (example: http://localhost:4000/api-docs)

3. Screenshots

swagger documentation with all endpoints