Skip to content

nijin39/houseing-finance

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn

Table of Contents

About The Project

해당 어플리케이션은 국낸 주택금융 신용보증 기관으로부터 년도별 각 금융기관(은행)에서 신용보증한 금액을 제공 받아. 현재 현황에 대한 리포팅 및 검색 기능과 과거의 데이터를 기반으로 하여 미래의 특점시점에 신용보증 금액에 대한 예측을 수행하는 것이 목표입니다.

Built With

Getting Started

Prerequisites

  • yarn
yarn install

Installation

  1. Clone the repo
https://github.com/nijin39/houseing-finance.git
  1. Start Backend
./gradlew bootRun
  1. Start Frontend
cd client; yarn start
  1. Build & Packging
./gradlew build clientBuild

Usage

JWT Token

1. Registration Account

curl -X POST \
  http://localhost:8080/register \
  -H 'content-type: application/json' \
  -d '{
	"username":"nijin39",
	"password":"korea123"
}'

2. Singin(publishing token)

curl -X POST \
  http://localhost:8080/authenticate \
  -H 'content-type: application/json' \
  -d '{
	"username":"nijin39",
	"password":"korea123"
}'

3. Refresh Token

curl -X PUT \
  http://localhost:8080/refreshToken \
  -H 'authorization: Bearer Token eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuaWppbjM5IiwiZXhwIjoxNTY2OTMyNzE0LCJpYXQiOjE1NjY5MTQ3MTR9.uFsurKI8VwbE02vz1vdQJNAN7b4_dnorG-5-8CX-C-kCXtFb7bHxWKInV7vtq6y4hNg2h8y6l8bQg44-RrRowA' \
  -H 'content-type: application/json' \
  -d '{
	"username":"nijin39",
	"password":"korea123"
}'

API

Swagger UI 경로

http://localhost:8080/swagger-ui.htm

소스의 /home/tandem6/DEV/housing-finance/src/main/resources/dataFile/sampleData.csv를 사용하시면 정상적인 결과들을 확인할 수 있습니다.

1. Upload CSV(테스트완료)

curl -X POST \
  http://localhost:8080/api/upload \
  -H 'authorization: Bearer  eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuaWppbjM5IiwiZXhwIjoxNTY2OTYxNTE2LCJpYXQiOjE1NjY5NDM1MTZ9.I0QEqKZ8lD1iZMw-NkmneW1E14aIgvuIakdnEsyejvl-lRiHGy5VgNqifO1D32_UJ944qx_SBIEN_w9IPdYKpA' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F file=@aa.csv \
  -F charset=UTF-8

2. Show all institute(테스트완료)

curl -X GET \
  http://localhost:8080/api/institutes \
  -H 'authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuaWppbjM5IiwiZXhwIjoxNTY2NjgxMjI4LCJpYXQiOjE1NjY2NjMyMjh9.A87NDjDHW6x_0AE6IcZMmTiczbIHnHHx-fmDsnhnCGyQYcSE67hPL4Lx4v7EWO6aDBv5w9AzbiErQVkzS_vfhg' \

3. Show Annual Report(테스트완료)

curl -X GET \
  http://localhost:8080/api/creditGuarantee/annualReport \
  -H 'authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuaWppbjM5IiwiZXhwIjoxNTY2NjgxMjI4LCJpYXQiOjE1NjY2NjMyMjh9.A87NDjDHW6x_0AE6IcZMmTiczbIHnHHx-fmDsnhnCGyQYcSE67hPL4Lx4v7EWO6aDBv5w9AzbiErQVkzS_vfhg' \

4. Max Amount Institute(테스트완료)

curl -X GET \
  http://localhost:8080/api/creditGuarantee/institute/max-amount \
  -H 'authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuaWppbjM5IiwiZXhwIjoxNTY2NjgxMjI4LCJpYXQiOjE1NjY2NjMyMjh9.A87NDjDHW6x_0AE6IcZMmTiczbIHnHHx-fmDsnhnCGyQYcSE67hPL4Lx4v7EWO6aDBv5w9AzbiErQVkzS_vfhg' \

5. Average Credit Guarantee by institute(테스트 완료)

curl -X GET \
  http://localhost:8080/api/creditGuarantee/institute/%EC%99%B8%ED%99%98%EC%9D%80%ED%96%89/max-min-average \
  -H 'authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuaWppbjM5IiwiZXhwIjoxNTY2OTM3NzQ4LCJpYXQiOjE1NjY5MTk3NDh9.4iKm9Vhdh7fNq_F2wEcu__IXNn42XemC0GilPb4b_H1o19vyv4EnNDCJgeAcSQ8MgUQqvFDLqDSjopq8gL4SZQ' \
  -H 'content-type: application/json' \
  -d '{
	"username":"nijin39",
	"password":"korea123"
}'

6. Credit Guarantee predicat(테스트 완료)

curl -X POST \
  http://localhost:8080/api/creditGuarantee/predicate \
  -H 'authorization: Bearer  eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuaWppbjM5IiwiZXhwIjoxNTY2OTYyMDczLCJpYXQiOjE1NjY5NDQwNzN9.Ab9HY1eY3RDbnxVSXRAwX9L4od6Cq5R_SltHasdPpMHqP9pMpIT59EAf3s6-Adj9uxS5hmuv4rk_CIO06e_n-w' \
  -H 'content-type: application/json' \
  -d '{
	"bank":"국민은행",
	"month" : 3
}'

Architecture

Package

패키징은 기본적으로 DDD Architecture 가이드를 따라 설계되었으며, 아래와 같이 구성된다. 금융기관은 별도로 모델링 되어지도록 제약이 주어졌다. creditguarantee(주택금융 공급)에는 통계 원본 데이터가 적재되며, 추후 연산 요청이 많은 경우를 대비하여 통계에 대한 별도 서머리 엔티디를 만들었다.

CreditGuarantee Domain에 대해 주로 요청되어지는 작업이 조회성 작업이기 때문에 효율성을 고려하여 CQRS를 적용하였다.

.
└── housingfinance
    ├── account(계정)
    │   ├── application
    │   ├── domain
    │   └── ui
    ├── admin(Admin Client)
    │   └── ui
    ├── common
    │   ├── config
    │   ├── domain
    │   └── util
    ├── creditguarantee(주택금융 공급)
    │   ├── command
    │   ├── infra
    │   ├── query
    │   └── ui
    ├── creditguaranteesummary(주택금융 공급 통계)
    │   ├── application
    │   ├── domain
    │   ├── infra
    │   └── ui
    ├── HousingFinanceApplication.java
    └── institute(금융기관)
        ├── application
        ├── domain
        ├── infra
        └── ui

DDD

institute / creditguarantee / creditguaranteesummary를 각각의 도메인으로 정리 하였고, JPA의 관계 설정에서 일어나는 문제(eager, lazy loding, 그래프 검색의 남용에 따른 도메인 로직의 응집도 저하)를 막기 위해 다른 도메인을 참조할 때는 ID 참조를 이용하였다. 또한 creditguarantee, creditguaranteesummary에서는 비즈니스의 의도가 드러나도록 Composite Key를 사용하였다.

CQRS

JPA를 사용한다 하여도, 명령(Command), 조회(Query)에 대해서 효율적인 모델링을 적용할 수 있다. 아래와 같이 동일한 도메인에 대해서 Command, Query에 따라 별도의 모델링을 적용하여 유연하게 시스템을 설계하고자 하였다.

├── command
│   ├── application
│   └── domain
├── infra
│   ├── CreditGuaranteeJpaRepository.java
│   └── CreditGuaranteePredicateApache.java
├── query
│   ├── application
│   ├── dao
│   └── dto
└── ui
    └── CreditGuaranteeRestController.java

Domain Event

현재 어플리케이션에 조회성 기능이 많고 동시에 조회성 기능에 대한 요구가 증가했을 경우 시스템의 부하에 관한 문제를 일으킬 수 있기 때문에 데이터의 변경이 있을 경우에 통계 도메인을 업데이트 하게 하였다. 이 두 도메인의 연동은 JPA의 도메인 이벤트를 활용하여 결합도를 낮추었다.

    @DomainEvents
    Collection<Object> domainEvents() {
        List<Object> result = new ArrayList<Object>();
        result.add(new CreditGuaranteeSavedEvent(this));
        return result;
    }
    
    @EventListener
    public void creditGuaranteeSavedEventHandler(CreditGuaranteeSavedEvent event) {

Roadmap

예측 모델의 고도화

React UI 개발

TODO

  • 개발환경 구성 : Spring Boot2, React
  • 요구사항 분석 및 Domain 파악
  • 각 모듈에 대한 패키지 구성
    • Institute : 금융기관
    • CreditGuarantee : 주택금융지원액
    • CreditGuaranteeSummary : 주택금융지원통계
    • Admin : 사용자 UI
    • Account : 사용자 계정 관련
  • 도메인/도메인 서비스에 대한 단위 테스트 적용
  • CreditGuarantee CQRS 패턴 적용
  • CreditGuarantee qlrm을 통한 조회모델 적용
  • 예측모델 적용(Lianer Reggression)
  • Jwt 인증 적용
    • refresh
  • 통합테스트
  • 예측모델 형변환
  • Readme

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Kim Jong IL - @nijin39 - nijin39@gmail.com

Project Link: https://github.com/nijin39/houseing-finance

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages