Skip to content

LucasJunio/bank-nest-sqlite-prisma-docker-jest

Repository files navigation

🧪 Backend Test. 💚

🚧 Finished 🚀 🚧

Prerequisites

Before you need install follow tools in your machine: Git, Node.js, Docker. Beyond is good to has an editor for to work with the code like VSCode

Summary

1. Overview

Bank is an API to open a new "current account" of already existing customers

Result:

API

1.1. Stack

1.2. Auxiliary libs

2. 🔬 How To Run

# Clone this repository
$ git clone https://github.com/LucasJunio/bank

# Acces the project folder in your terminal/cmd
$ cd bank

# Copy base.env to .env
$ cp base.env .env

2.1. Containers

# Build the image docker
$ docker build -t bank .

# Run tests
$ docker run -e CI=true bank npm run test

# Build the container docker
$ docker run -p 3000:3000 bank

# Access SWAGGER documentation in:
http://localhost:3000/api

# The aplication going to open in  port:3000 - access http://localhost:3000

Diagram

2.2. Local

Run the development server local with "yarn", "npm", "pnpm" or manager package your preference:

# Create .env file
$ cp base.env .env

# Install dependencies
$ yarn install

# Generate the TypeScript code associated with your database models
$ npx prisma generate

# Building migrations
$ npx prisma migrate dev

# Building mock data
$ npx prisma db seed

# Run the project
$ yarn start

The aplication going to open in port:3000 - access http://localhost:3000

2.3 Evaluating Create New Account and Basic Info about new account

You can login by sending a POST request to the /current-account/ endpoint. Here's an example using cURL:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
  {
  "custumerId": 1,
  "initialCredit": 25.51
  }
}' \
http://localhost:3000/current-account/

The response will be status code 201 created and informations about the new account.

You can evaluate the basic info route by sending a GET request to the http://localhost:3000/current-account/basic-info/:id endpoint. Here's an example using cURL:

curl -X GET
  -H "Content-Type: application/json" \
http://localhost:3000/current-account/basic-info/:id

The response will be status code 200 success and informations about the account {:id}.

2.4 API Endpoints

  • POST http://localhost:3000/current-account/:
  • GET http://localhost:3000/current-account/basic-info/1:

3. Prisma Local Database

You can see the local database Prisma Studio is up on http://localhost:5555.

# Running local database
$ npx prisma studio

Result:

Prisma Local Database

4. How to create a new branch

Ever that's necessary to create a new branch feature, create by [main]branch, implement your development, merge this feature/branch to develop, when all it's ok, give a merge of this feature/branch to main[branch].

Let's go to follow the git flow patterns to create a new branch, to more info browse in link below to learn more how to implement in simple way.

Workflow gitflow: https://www.atlassian.com/br/git/tutorials/comparing-workflows/gitflow-workflow

# Example creating a new branch
$ git checkout -b feature/TASK-1

4.1. Commits

For commit your changes, you can follow the suggestion to use conventional commits [https://www.conventionalcommits.org/en/v1.0.0/] for to improve your commit descriptions and help the understand of the team. Exist a extension in vscode that can help you with this mission.

vscode extension id in .vscode/extensions.json:

"recommendations": ["vivaxy.vscode-conventional-commits"]

5. Software Architecture

Main folder tree.

C:.

  • src
  • ├───core
  • ├───modules
  • │ ├───controller
  • │ ├───inputs
  • │ ├───repository
  • │ ├───schema
  • │ ├───service
  • │ └───validators

6. Documentation

Diagram:

see diagram entity relationship for documentation

Diagram

7. Recommended Extensions

You can check out a list of recommended extensions in the file .vscode/extensions.json, or by opening the "Extensions" Tab in the "Recommended" pane.


🦸 Author


Lucas Junio
🚀

📝 Licence

Made with ❤️ by Lucas Junio 👋🏽 Contact

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published