kirsing / sbank

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Boot Microservice SBank example(Eureka Server, Config Server, API Gateway, Services , Kafka, Keycloak)

About the project

  • User can't register himself (not implemented yet) but you can add users using the KeyCloak console and login through Keycloak
  • It's possible to give ROLEs to the users
  • Admin can approve and reject advertisement from advertisement service to report service by using management service through API Gateway
  • User can create/update/delete/fetch account details including card, loan details, through API Gateway
  • User can create/update/delete/fetch card details, through API Gateway
  • User can create/update/delete/fetch loan details, through API Gateway

7 services whose name are shown below have been devised within the scope of this project.

  • Config Server
  • Eureka Server
  • API Gateway
  • Account Service
  • Card Service
  • Loan Service
  • Message Service

Explore Rest APIs

Method Url Description Valid Request Body Valid Request Params Valid Request Params and Body No Request or Params
POST /create Create Account Info
POST /create?mobileNumber={mobileNumber} Create Card for Client Info
POST /create?mobileNumber={mobileNumber} Create Loan for Client Info
GET /fetchCustomerDetails?mobileNumber={mobileNumber} Fetch Customer details based on a mobile number Info
GET /build-info Get Build information (implemented Retry pattern - Recilience4j) Info
GET /java-version Get Java versions details (implemented Redis RateLimiter - Recilience4j) Info
GET /contact-info Contact info details Info
GET /fetch?mobileNumber={mobileNumber} Fetch card details based on a mobile number Info
GET /fetch?mobileNumber={mobileNumber} Fetch loan details based on a mobile number Info
PUT /update Update Customer & Account details Info
PUT /update Update card details Info
PUT /update Update loan details Info
DELETE /delete?mobileNumber{mobileNumber} Delete Customer & Account details based on the mobile number Info
DELETE /delete?mobileNumber{mobileNumber} Delete Card details based on a mobile number Info
DELETE /delete?mobileNumber{mobileNumber} Delete Loan details based on a mobile number Info

Used Dependencies

  • Core
    • Spring
      • Spring Boot
      • Spring Security
      • Spring Web
      • Spring Data
        • Spring Data JPA
      • Spring Cloud
        • Spring Cloud Gateway Server
        • Spring Cloud Config Server
        • Spring Cloud Config Client
        • OpenFeign
    • Netflix
      • Eureka Server
      • Eureka Client
  • Database
    • Mysql
  • Message Broker
    • Kafka
  • Security
    • Keycloak Server
    • Keycloak OAuth2
    • Keycloak REST API

Valid Request Body

    http://localhost:8072/sbank/accounts/api/create
    Bearer Token : Access Token from Keycloak
    {
        "name": "Kirill Yud",
        "email": "kirsing98@gmail.com",
        "mobileNumber": "3754478543"
    }
    http://localhost:8072/sbank/accounts/api/update
    Bearer Token : Access Token from Keycloak
    {
        "name": "Kirill Yud",
        "email": "kirsing98@gmail.com",
        "mobileNumber": "4354437687",
        "accountsDto": {
            "accountNumber": 1105557729,
            "accountType": "Savings",
            "branchAddress": "123 Main Street, New York"
        }
    http://localhost:8072/sbank/cards/api/cards/update
    Bearer Token : Access Token from Keycloak
    {
        "mobileNumber": "3754478543",
        "cardNumber": "100107091026",
        "cardType": "Debit Card",
        "totalLimit": 100000,
        "amountUsed": 10000,
        "availableAmount": 90000
    }
    http://localhost:8072/sbank/loans/api/loans/update
    Bearer Token : Access Token from Keycloak
    {
        "mobileNumber": "3754478543",
        "loanNumber": "10071469799154",
        "loanType": "House Loan",
        "totalLoan": -100000,
        "amountPaid": -10000,
        "outstandingAmount": -90000
    }

Valid Request Params

    http://localhost:8072/eazybank/accounts/api/fetchCustomerDetails?mobileNumber={mobileNumber} 
    Bearer Token : Not required
    http://localhost:8072/sbank/cards/api/cards/fetch?mobileNumber={mobileNumber} 
    Bearer Token : Not required
    http://localhost:8072/sbank/loans/api/loans/fetch?mobileNumber={mobileNumber} 
    Bearer Token : Not required
    http://localhost:8072/eazybank/accounts/api/delete?mobileNumber={mobileNumber} 
    Bearer Token : Access Token from Keycloak
    http://localhost:8072/sbank/cards/api/cards/delete?mobileNumber={mobileNumber} 
    Bearer Token : Access Token from Keycloak
    http://localhost:8072/sbank/loans/api/loans/delete?mobileNumber={mobileNumber} 
    Bearer Token : Access Token from Keycloak
    http://localhost:8072/sbank/cards/api/cards/create?mobileNumber={mobileNumber} 
    Bearer Token : Access Token from Keycloak
    http://localhost:8072/sbank/loans/api/loans/create?mobileNumber={mobileNumber} 
    Bearer Token : Access Token from Keycloak

No Request or Params

    http://localhost:8072/sbank/accounts/api/build-info
    Bearer Token : Not Required
    http://localhost:8072/sbank/accounts/api/java-version
    Bearer Token : Not Required
    http://localhost:8072/sbank/accounts/api/contact-info
    Bearer Token : Not Required

🔨 Run the App

1 ) Download your project from this link https://github.com/kirsing/sbank

2 ) Go to the project's home directory : cd ~/sbank-main

Docker

1 ) Install Docker Desktop. Here is the installation https://www.docker.com/get-started/

2 ) Go to the specific directory: cd ~/sbank-main/docker-compose/prod

3 ) Run all Containers through this command - docker compose up -d

Kubernetes

1 ) Install minikube or enable Kubernetes on Docker Desktop

2 ) Install Helm https://helm.sh/docs/intro/quickstart/

3 ) Go to the directory : cd ~/sbank-main/helm/environments/

4 ) Install all Helm Charts using Helm through this command helm install <your-application-name> dev-env

Implement settings (K8s)

KeyCloak (Get the KeyCloak URL)

    export HTTP_SERVICE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[?(@.name=='http')].port}" services keycloak)
    export SERVICE_IP=$(kubectl get svc --namespace default keycloak -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo "http://${SERVICE_IP}:${HTTP_SERVICE_PORT}/"

KeyCloak (Access the Administration console) - generate credentials:

  echo Username: user
  echo Password: $(kubectl get secret --namespace default keycloak -o jsonpath="{.data.admin-password}" | base64 -d)

Prometheus (Get Access from outside cluster)

  echo "Prometheus URL: http://127.0.0.1:9090/"
   kubectl port-forward --namespace default svc/prometheus-kube-prometheus-prometheus 9090:9090

Grafana (Get Grafana URL)

   echo "Browse to http://127.0.0.1:8080"
   kubectl port-forward svc/grafana 8080:3000 &

Grafana (Credentials)

   echo "User: admin"
   echo "Password: $(kubectl get secret grafana-admin --namespace default -o jsonpath="{.data.GF_SECURITY_ADMIN_PASSWORD}" | base64 -d)"

Implement KeyCloak settings

1 ) Open Keycloak on the Browser through localhost:7080

2 ) Enter username and password (admin : admin)

Authorization code grant flow

Create Client

Save client secret

Create ROLES: ACCOUNTS, CARDS, LOANS

Create users

Assign ROLE to the user

Client credential code grant flow

Attached postman collection

Get Access Token via Client Credentials GRANT FLOW

Separate request or

Get Access Token via Authorize Code GRANT FLOW

"State section" consists of your random symbols/numbers

Screenshots

Click here to show the screenshot of project

Grafana

Kubernetes Dashboard

About


Languages

Language:Java 55.5%Language:Smarty 43.8%Language:Shell 0.7%