Giter Site home page Giter Site logo

rsemihkoca / kredinbizdeloanmanagementapp Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 1.76 MB

KredinBizde is a central loan management software, feed loan list from external bank servers and serve your customers. Made with Spring Boot, MicroServices pattern applied.

License: MIT License

Dockerfile 3.78% Java 90.44% Shell 0.41% JavaScript 0.07% HTML 5.31%
aop eureka fintech java kafka loan-management microservice microservices mongodb mysql

kredinbizdeloanmanagementapp's Introduction

Kredinbizde Loan Application

Demonstration

Technologies

  • Java 21, Spring Boot, Microservices, Docker, MySQL, Kafka, Redis, Eureka

Prerequisites

  • Docker/Docker Compose installed on your machine.
  • Git installed on your machine.

Clone the Repository

git clone https://github.com/Definex-Java-Spring-Bootcampp/week-4-rsemihkoca
cd week-4-rsemihkoca

Setup

Just Run the Docker Compose

Execute the following command to bring down existing Docker containers, volumes, and remove orphaned containers, then bring the Docker environment back up:

docker-compose down -v --remove-orphans && docker-compose up

Architecture

Adsız-2024-04-07-1353.png

  • Calculation Servis yapılmadı.
  • En dışarıda bulunan gateway servisi, tüm istekleri karşılar ve ilgili servislere yönlendirir.
  • Discovery servisi, tüm servislerin kayıtlı olduğu servistir. FeignClient ile servisler arası iletişimi sağlar.
  • User servisi, kullanıcılarla ilgili işlemleri yapar.
  • Application servisi, başvurularla ilgili işlemleri yapar.
  • Bank servisi, bankaların sunduğu kredilerin güncel listesini tutar.
  • Kafka asenkron mesajlaşmayı sağlar.
  • Redis cacheleme yapar. Database yükünü azaltır.
  • MySQL servislerin veritabanıdır.
  • Akbank, Garanti gibi entegrasyonlar dış kaynaklardır. Direkt olarak sistemin içinde bulunmazlar.

Api Gateway[:8888]

  • Gateway servisi, tüm istekleri karşılar ve ilgili servislere yönlendirir.
➜  week-4-rsemihkoca git:(main) ✗ curl -X 'GET' \
  'http://localhost:8081/api/v1/user/' \
  -H 'accept: */*'
[{"userId":"1","name":"Cem","age":30},{"userId":"2","name":"Cem","age":25},{"userId":"3","name":"Cem","age":28},{"userId":"4","name":"Cem","age":27},{"userId":"5","name":"Semih","age":24}]%                      
➜  week-4-rsemihkoca git:(main) ✗ curl -X 'GET' \
  'http://localhost:8888/api/v1/user/' \
  -H 'accept: */*'
[{"userId":"1","name":"Cem","age":30},{"userId":"2","name":"Cem","age":25},{"userId":"3","name":"Cem","age":28},{"userId":"4","name":"Cem","age":27},{"userId":"5","name":"Semih","age":24}]%  

Application Service[:8080]

  • Application servisi, başvurularla ilgili işlemleri yapar.

Create Application

Method Path
POST /api/v1/application

Description:

Creates a loan application. Endpoint checks if the user exists, loan id exists, and if the user has an active loan. If all conditions are met, the application is created and notification is sent to the user email.

Get All Applications

Method Path
GET /api/v1/application/

Description:

Retrieve all active loan applications. Deactivated applications are not included in the response.

Get Application By User Email

Method Path
GET /api/v1/application/{email}

Description:

Retrieve all active loan applications by user email. Deactivated applications are not included in the response.

Health Check

Method Path
GET /actuator/health

Description:

Health check endpoint for the application service.

User Service[:8081]

  • User servisi, kullanıcılarla ilgili işlemleri yapar.

Create User

Method Path
POST /api/v1/user

Description:

Creates a user. Example request body:

{
  "name": "string",
  "age": 18,
  "email": "string",
  "address": {
    "addressTitle": "string",
    "addressDescription": "string"
  }
}

Get All Users

Method Path
GET /api/v1/user/

Description:

Retrieve all users.

Get User Detail By User Id

Method Path
GET /api/v1/user/{userId}

Description:

Retrieve user detail by user id.

Delete User By User Email

Method Path
DELETE /api/v1/user/{email}

Description:

Delete user by user email.

Health Check

Method Path
GET /actuator/health

Description:

Health check endpoint for the application service.

Notification Service[:8082]

  • Notification servisi, kullanıcılara bildirim gönderir. Strategy pattern kullanılarak mail ve sms gönderimi yapılır.

Bank Service[:8083]

  • Bank servisi, bankaların sunduğu kredilerin güncel listesini tutar.

Get All Loans

Method Path
GET /api/v1/loan/

Description:

Retrieve all active loans.

Health Check

Method Path
GET /actuator/health

Description:

Health check endpoint for the application service.

Log Consumer Service[:8084]

  • Kafka ile asenkron mesajlaşmayı sağlar. Kafka'dan gelen mesajları dinler ve MongoDB'ye loglar.

Lessons Learned

  • Servisleri docker içine taşıdıktan sonra bir türlü davranış değişmiyorsa image'i silmek gerekli Örneğin gateway bir türlü bağlayamadıysanız ve intellij kullanıyorsanız services altındaki images temizlemek çözüm olabilir. veya endpointleri temizlediğinizde swagger'a yansımıyorsa aynı şekilde imajları temizlemek çözüm olabilir. Bu davranışın sebebi dockerfile'ların cachelenmesi ancak servis sayım fazla olduğu için böyle yapmak zorundaydım diğer türlü multi-stage dockerfile'ları single stage yapıp belleği yormak zorunda kalacaktım.
  • Hibernate ile veritabanı işlemleri yaparken değişikliklerin database'e yansımama problemlerinden biri hibernate'in cacheleme yapmasıdır. Eğer database ile hibernate arasında bir uyumsuzluk varsa hibernate'in cache'ini temizlemek gerekebilir.
  • Kafka advertised listeners konusu çok önemli. Kafka'yı docker içinde çalıştırırken advertised listeners'ı doğru ayarlamak gerekiyor. Aksi takdirde client'lar broker'a bağlanamazlar. Bu konuda çok fazla zaman harcadım. Aşağıdaki makaleyi buldum ve bu makale sayesinde sorunu çözebildim. Bu konuda çok dikkatli olmak gerekiyor. kafka'yı bu makaleye borçluyum: https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
  • .Net'te olduğu gibi Spring boot'ta da aspect yapısı çok değerli günü kurtarıyor gerçekten.
  • Docker içinde databaseleri ayırırken ait oldukları servisle aynı network'e eklemek gerekiyor. Aksi takdirde bağlantı sağlanamaz. Hepsi aynı networkte olursa mysql portları çakışır. Bu yüzden ayrı networklerde olmaları gerekiyor.
  • Mükemmelci anlayış deadline'ı kaçırmana sebep olabilir. Özellikle son haftalarda çok fazla detayla uğraşmak yerine önce işleyişi tamamlamak daha önemli olabilir. Çok fazla detayla uğraştım ve sonuç olarak deadline'ı kaçırdım. Bu yüzden mükemmelci olmak yerine verilen eforu tartarak ilerlemek daha önemli olabilir. Response time'ı header'a ekleme feature'ı buna örnektir.
  • Swot analizi doğru sonuç verdi. Rabbitmq çıkarıp sadece kafka eklemek doğru bir karar oldu. İki başlı çözümden kullanılan tek başlı çözüme geçmek doğru bir karar oldu. Bu sayede daha az servis kullanıldı ve daha az karmaşıklık oluştu.
  • Mikroservisler ile çalışırken karmaşıklık artacağı için feature'ları küçük tutmak ve servisleri küçük tutmak önemli. Diğer türlü servisler arası dengesizlik oluşuyor.

4.Hafta Ödevi

  • Kullanılan servisleri istediğiniz bir database ile bağlayın. (30 PUAN)
    MySQL kullanıldı.

  • Bir uygulama için service katmanına tüm gerekli senaryolar için unit test yazın. (20 PUAN)(Daha fazla yapan bonus 10 PUAN)
    User servisi için unit test yazıldı. Application servisi için yazıldı.

  • Tüm uygulamaları tek bir repo haline getirin.bu repo içerisinde ilgili bütün servisler olmalı. Gw, discovery servis ve diğer servisler(5 PUAN)
    Tüm servisler tek bir repo içerisinde bulunmaktadır.

  • Dokümantasyon ekleyin. projeye dökümantasyon ekleyin. Swagger, read.me dosyası, mimari çizim, servislerin endpointleri(20 PUAN)
    Readme.md dosyası eklendi. Swagger eklendi. Mimari çizim eklendi. Servislerin endpointleri eklendi.

  • Best practices, isimlendirme kurallarına uyum. Unit test isimlendirme(10 PUAN)
    İsimlendirme kurallarına uyuldu. Unit test isimlendirme yapıldı.

  • Uygulamanın doğru çalışması. (15 PUAN)
    Demo videosu eklendi.

BONUS

  • Uygulamaların dockerize edilmesi ve docker compose dosyası yazılması. (10 PUAN)
    Dockerize edildi ve docker-compose dosyası yazıldı.
  • Design Pattern kullanımı. (10 PUAN)
    Interceptor, Strategy, Builder pattern, Singleton pattern, Interface Segregation Principle, Dependency Injection kullanıldı.

kredinbizdeloanmanagementapp's People

Contributors

github-classroom[bot] avatar rsemihkoca avatar

Stargazers

 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.