Git Product home page Git Product logo

week-10-gkorompis's Introduction

Building MERN stack m-banking APP using AWS resources.

1. Project Overview

2. Contents

  1. Documentation Contents
  2. Contents
  3. API Documentation
  4. Server-side Build and Deployment
    1. Setting up virtual machine AWS EC2 and Docker
    2. Build connection to mongodb with Docker

3. API Documentation

FULL openapi documentation can be found here

3.1 Dependencies

The server-side application is hosted by AWS API Gateway, and follows this requirement:

 "dependencies": {
    "@types/body-parser": "^1.19.2",
    "@types/cors": "^2.8.13",
    "@types/express": "^4.17.17",
    "@types/jsonwebtoken": "^9.0.2",
    "body-parser": "^1.20.2",
    "cors": "^2.8.5",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "ioredis": "^5.3.2",
    "jsonwebtoken": "^9.0.1",
    "mysql2": "^3.6.0",
    "serverless-http": "^3.2.0",
    "typescript": "^5.1.6"
}

3.2 BaseURL and Resources

General Syntax

<base URL>/<resource>
//header required for all header except for post users
{
    "Authorization": "bearer <jwt_token>"
}

Base URL

https://kmaww9zbl5.execute-api.ap-southeast-3.amazonaws.com/prod

Request JWT Token

POST /auth/login
//body
{
    "username": string,
    "password": string
}
//response EXPIRES IN 30 MINUTES
{
    "token": string,
}

Sign up for username

POST /users
//body
{
    "name": string,
    "email": string,
    "username": string,
    "password": string, /* alphanumeric, <8 */
    "role": string, /* maker, approver, admin */
}

Resources

Resource Status Description Fields
users prod Collection of user accounts {_id, created, name, email, username, password }
transactionsRequest prod Collection of transaction records {_id, username, type, amount, status, timestamp}
transactions prod Collection of transaction records {_id, username, type, amount, created}

Summary

Users

Route Endpoint UniqueID Query Header Request Body Response Description
POST one /users - - Required. Authorization Required. JSON Status of the POST operation
GET many /users - - Required. Authorization - Array of transaction documents
GET one /users/{id} Required. id - Required. Authorization - Single transaction document
PATCH one /users/{id} Required. id - Required. Authorization Required. JSON Status of the PATCH operation
Delete one /users/{id} Required. id - Required. Authorization - Status of the DELETE operation

4. Server-side Build and Deployment

4.1 Setting up virtual machine AWS EC2 and Docker

To set up EC2 instance follow this workflow:

  1. Login to AWS console, and then access "EC2" resource in Service bar.
  2. Once EC2 dashboard is fully rendered, click "Launch Instance"
  3. Provide name to label EC2 Instance
  4. Select the desired amazon machine image (AMI) to build the virtual machine, in this project "Ubuntu Server 22.04 LTS (HVM)" image is selected.
  5. Select the type of image architecture, in this project "64bit(x86)" is selected.
  6. Select instance type, in this project "t3.micro" is selected. This instance type caters to 2 vCPU and 1 GiB Memory.
  7. Create new key pair to login, in this project ".pem" file is created.
  8. Configure security group to network setting depending on the use case, in this project only SSH traffic from anywhere is allowed as default.
  9. Lastly, configure storage to be provisioned, in this project 8 GiB gp2 is selected. Finally click launch instance.
  10. Once has been launched, EC2 can be access using SSH protocol via Public IPv4 address
chmod 400 <pem_file_name>.pem
ssh -i <pem_file_name>.pem ubuntu@<ipv4_address>
  1. Once set up, you can download this repository into your EC2 instance.
git clone https://github.com/RevoU-FSSE-2/week-9-gkorompis
cd week-10-gkorompis
  1. Install Docker
# assuming you git clone the repository into your user's home directory (~), and you are using linux operation system Ubuntu from AWS EC2
chmod 777 ~/week-10-gkorompis/workflow/install_docker.sh
~/week-10-gkorompis/workflow/install_docker.sh
sudo usermod -aG docker $USER
sudo service docker restart

4.2 Build connection to mongodb with Docker

  1. Direct to working directory
cd ~/week-10-gkorompis/workflow/BuildMongoDB
  1. Build Image
docker build . -t w10-mongo:1.0
docker run -p 3002:3002 w10-mongo:1.0
  1. on new terminal tab, stop the container manuall once new collection creation is successful
docker stop <container_id>

sudo usermod -aG docker $USER sudo service docker restart

week-10-gkorompis's People

Contributors

gkorompis avatar github-classroom[bot] avatar

Watchers

Alvian Zachry Faturrahman avatar

Forkers

gkorompis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.