Building MERN stack m-banking APP using AWS resources.
FULL openapi documentation can be found here
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"
}
<base URL>/<resource>
//header required for all header except for post users
{
"Authorization": "bearer <jwt_token>"
}
https://kmaww9zbl5.execute-api.ap-southeast-3.amazonaws.com/prod
POST /auth/login
//body
{
"username": string,
"password": string
}
//response EXPIRES IN 30 MINUTES
{
"token": string,
}
POST /users
//body
{
"name": string,
"email": string,
"username": string,
"password": string, /* alphanumeric, <8 */
"role": string, /* maker, approver, admin */
}
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} |
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 |
To set up EC2 instance follow this workflow:
- Login to AWS console, and then access "EC2" resource in Service bar.
- Once EC2 dashboard is fully rendered, click "Launch Instance"
- Provide name to label EC2 Instance
- Select the desired amazon machine image (AMI) to build the virtual machine, in this project "Ubuntu Server 22.04 LTS (HVM)" image is selected.
- Select the type of image architecture, in this project "64bit(x86)" is selected.
- Select instance type, in this project "t3.micro" is selected. This instance type caters to 2 vCPU and 1 GiB Memory.
- Create new key pair to login, in this project ".pem" file is created.
- Configure security group to network setting depending on the use case, in this project only SSH traffic from anywhere is allowed as default.
- Lastly, configure storage to be provisioned, in this project 8 GiB gp2 is selected. Finally click launch instance.
- 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>
- 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
- 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
- Direct to working directory
cd ~/week-10-gkorompis/workflow/BuildMongoDB
- Build Image
docker build . -t w10-mongo:1.0
docker run -p 3002:3002 w10-mongo:1.0
- 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