PT-XYZ Finance

Description

PT XYZ Multifinance adalah salah stau perusahaan pembiayaan motor dan mobil di indonesia, yang mempunyai komitmen menyediakan solusi pembiayaan terhadap masyarakat melalui teknologi untuk meningkatkan kualitas hidup masyarakat umum.

Berdasarkan background multifinance, kita akan membuat server kecil yang membutuhkan environment yang scalable, maintanable, testable dll.

Installation

Use the makefile syntax to install dependencies

make clean && make install

After install, set up configuration file on app.yaml (conf/app.yaml)

Usage

Run migration using goose as migration tools.

note: Please create database first !

go run main.go db:migrate up

Build docker images

docker build -t {image_name} -f deployment/Dockerfile .

REST API:

POST :8000/api/v1/customer

--header 'Content-Type: application/json' \
--data '{
    "identity_number": "",
    "full_name": "",
    "legal_name": "",
    "place_of_birth": "",
    "date_of_birth": "",
    "salary": 0
}'

POST :8000/api/v1/customer/limit

curl --location ':8000/api/v1/customer/limit' \
--header 'Content-Type: application/json' \
--data '{
    "customer_id": 1,
    "tenor": 1,
    "limit_amount": 1000000
}'

POST :8000/api/v1/customer/transaction

curl --location ':8000/api/v1/customer/transaction' \
--header 'Content-Type: application/json' \
--data '{
    "customer_id": 1,
    "otr": 6000000,
    "admin_fee": 25000,
    "installment_amount": 650000,
    "interest_amount": 10000
}'

For handling concurrency on this service, we implement some method on endpoint PUT :8000/api/v1/customer/transaction/:contract_number :

curl --location --request PUT ':8000/api/v1/customer/transaction/018d545a-f120-7d9b-816e-5f23eba70da2' \
--header 'Content-Type: application/json' \
--data '{
    "admin_fee": 2000
}'
  • Optimistic Locking
  • Using mutex

System Architecture

Its using hexagonal architecture as base structure

alt text


Example common architecture

alt text


Database Diagram

alt text