Code Monkey home page Code Monkey logo

mecash-tc's Introduction

Author

Name: Ikechukwu Michael, Email: [email protected]

Introduction🖖

My solution to meCash technical assessment.

Specification

  • Users are able to sign up using their email and password.
  • On successful profile creation, they are auto (randomly) assigned an account number with a balance in either currency A or B
  • Users are able to log in using a username and password
  • Users are able to transfer money from their account to another account regardless of the currencies
  • Users are able to get their account balance and transaction history
  • There are only 2 currencies, currency A & B, which exchange rate A → B: 1.3455

Step One - Tools and Technologies used 🎼

  • Spring Boot(Latest Version)
  • Spring Data JPA
  • Lombok Library
  • JDK 18
  • Embedded Tomcat
  • Mysql Database(Mysql Workbench)
  • Maven
  • Java IDE (IntelliJ)
  • Postman Client

Step Two - Steps to Run the project Locally ⚙️

MySQL Workbench was used to run the database locally. Navigate to the project application.properties file and modify the database credential per your database server requirement such as username and password

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/maCash?createDatabaseIfNotExist=true&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
    username: #Database-username
    password: #Database-password

Installation

  • Clone this repo:
git clone https://github.com/michaelik/meCash-TC.git
  • Navigate to the root directory of the project.
  • Build the application
./mvnw clean install
  • Run the application
./mvnw spring-boot:run

Usage 🧨

REST APIs for Drone Service Resource

HTTP METHOD ROUTE STATUS CODE DESCRIPTION
POST /api/auth/register 201 Create new user
POST /api/auth/login 200 Login into your newly created account
GET /api/v1/user-detail/{id} 200 Read account detail
GET /api/v1/account-balance/{id} 200 Read account balance
POST /api/v1/transfer/{id} 200 Make transfer
GET /api/v1/transaction-history/{id} 200 Read transaction history
POST /api/v1/fund-account/{id} 200 Fund your newly created account

The Client should be able to:

SignUp

The payload will have the following fields:

  • name:
  • email:
  • password
  • age:
  • gender:
  • accountCurrency:

Request

curl -X POST http://localhost:8080/api/auth/register \
-H 'Content-type: application/json' \
-d '{
    "name": "Ikechukwu Michael",
    "email": "[email protected]",
    "password": "12345",
    "age": 20,
    "gender": "M"
    "accountCurrency": A
}'

SignIn

The payload will have the following field:

  • username:
  • password:

Request

curl -X POST http://localhost:8080/api/auth/register \
-H 'Content-type: application/json' \
-d '{
    "username": "[email protected]",
    "password": "12345"
}'

Response

{
  "token": "eyJhbGciOiJIUzI1NiJ9.eyJzY29wZXMiOlsiUk9MRV9VU0VSIl0sInN1YiI6Im1pa2Vpa2VjaGkzQGdtYWlsLmNvbSIsImlhdCI6MTY5MjIwOTQ2MiwiZXhwIjoxNjkzNTA1NDYyfQ.tWbASUsAzxtOjVCGWB9_dNn6qmm35IATzoNT9QQmmUY",
  "id": 1,
  "name": "michael ikechukwu",
  "email": "[email protected]",
  "gender": "M",
  "age": 20,
  "roles": [
    "ROLE_USER"
  ],
  "username": "[email protected]"
  }
}

Read Account Detail

Request

curl -X GET http://localhost:8080/api/v1/user-detail/1 \
-H 'Content-type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzY29wZXMiOlsiUk9MRV9VU0VSIl0sInN1YiI6Im1pa2Vpa2VjaGkzQGdtYWlsLmNvbSIsImlhdCI6MTY5MjIwOTQ2MiwiZXhwIjoxNjkzNTA1NDYyfQ.tWbASUsAzxtOjVCGWB9_dNn6qmm35IATzoNT9QQmmUY' \

Response

{
  "id": 1,
  "name": "michael ikechukwu",
  "email": "[email protected]",
  "age": 20,
  "gender": "M",
  "accountNumber": "4613455672",
  "accountCurrency": "B"
}

Read Account Balance

Request

curl -X GET http://localhost:8080/api/v1/account-balance/1 \
-H 'Content-type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzY29wZXMiOlsiUk9MRV9VU0VSIl0sInN1YiI6Im1pa2Vpa2VjaGkzQGdtYWlsLmNvbSIsImlhdCI6MTY5MjIwOTQ2MiwiZXhwIjoxNjkzNTA1NDYyfQ.tWbASUsAzxtOjVCGWB9_dNn6qmm35IATzoNT9QQmmUY' \

Response

{
  "accountName": "michael ikechukwu",
  "accountNumber": "4613455672",
  "totalAccountBalance": "B0.00"
}

Make Transfer

The url will have the following request:

  • accountNumber:
  • amount:

Request

curl -X POST http://localhost:8080/api/v1/transfer/1 \
-H 'Content-type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzY29wZXMiOlsiUk9MRV9VU0VSIl0sInN1YiI6Im1pa2Vpa2VjaGkzQGdtYWlsLmNvbSIsImlhdCI6MTY5MjIwOTQ2MiwiZXhwIjoxNjkzNTA1NDYyfQ.tWbASUsAzxtOjVCGWB9_dNn6qmm35IATzoNT9QQmmUY' \
-d '{
    "accountNumber": "{input valid acct}",
    "amount": "50"
}'

Read Transaction History

Request

curl -X GET http://localhost:8080/api/v1/transaction-history/1
-H 'Content-type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzY29wZXMiOlsiUk9MRV9VU0VSIl0sInN1YiI6Im1pa2Vpa2VjaGkzQGdtYWlsLmNvbSIsImlhdCI6MTY5MjIwOTQ2MiwiZXhwIjoxNjkzNTA1NDYyfQ.tWbASUsAzxtOjVCGWB9_dNn6qmm35IATzoNT9QQmmUY' \

Fund Account

The url will have the following request:

  • amount:

Request

curl -X POST http://localhost:8080/api/v1/fund-account/1 \
-H 'Content-type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzY29wZXMiOlsiUk9MRV9VU0VSIl0sInN1YiI6Im1pa2Vpa2VjaGkzQGdtYWlsLmNvbSIsImlhdCI6MTY5MjIwOTQ2MiwiZXhwIjoxNjkzNTA1NDYyfQ.tWbASUsAzxtOjVCGWB9_dNn6qmm35IATzoNT9QQmmUY' \
-d '{
    "amount": "200"
}'

Response

{
  "createdAt": "2023-08-16T19:26:22.4292087",
  "status": "Success"
}

mecash-tc's People

Contributors

michaelik avatar

Watchers

 avatar

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.