Skip to content
프로젝트

tomoyane/springboot-bestpractice

GitHub에서 보기

소개

SpringBoot best practice architecture. This repository describes multiple data connections with a architecture in mind. RDBMS/Mongo/Cassandra/Redis

데이터 및 분석

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

SpringBoot best practice

springboot-bestpractice Apache License

About Spring Boot architecture.

This repository support multiple database by SPRING_PROFILES_ACTIVE

  • RDBMS
  • MongoDB
  • Cassandra
  • Redis

Requirements

  • Docker engine
  • Docker Compose
  • OpenJDK 17
  • Spring Boot 2

Docker database

MySQL8

  • Standalone

MongoDB

  • Standalone

Cassandra cluster.

  • 3 Nodes

Architecture

The "app" package holds controllers for API endpoints and provides interception. The "app" package can depend on the "domain" package.

The "domain" package provides business logic and holds Spring Component Beans or Service Beans. It cannot depend on the "app" package but relies on the "infrastructure" package.

The "infrastructure" package provides data storage by holding Spring Repository Beans. It is independent and cannot depend on the "app" and "domain" packages.

The "common" package offers generic functions.

Initialization processes during server startup depend on "SPRING_PROFILES_ACTIVE" and assume the specified data store's Bean as a prerequisite for the initial startup.

Directory structure

java
    │   │   └── com
    │   │       └── bestpractice
    │   │           └── api
    │   │               ├── Application.java
    │   │               ├── app
    │   │               │   ├── AdviceController.java
    │   │               │   ├── AppBean.java
    │   │               │   ├── InterceptorController.java
    │   │               │   ├── v1
    │   │               │   │   ├── AuthController.java
    │   │               │   │   ├── HelloController.java
    │   │               │   │   ├── RdbmsController.java
    │   │               │   │   └── UserController.java
    │   │               │   └── v2
    │   │               │       └── AuthorizationController.java
    │   │               ├── common
    │   │               │   ├── exception
    │   │               │   │   ├── BadRequest.java
    │   │               │   │   ├── Conflict.java
    │   │               │   │   ├── Forbidden.java
    │   │               │   │   ├── InternalServerError.java
    │   │               │   │   ├── NotFound.java
    │   │               │   │   ├── RequestTimeout.java
    │   │               │   │   ├── ServiceUnavailable.java
    │   │               │   │   └── UnAuthorized.java
    │   │               │   ├── property
    │   │               │   │   └── CredentialProperty.java
    │   │               │   └── util
    │   │               │       └── Util.java
    │   │               ├── domain
    │   │               │   ├── DomainBean.java
    │   │               │   ├── component
    │   │               │   │   ├── AuthComponent.java
    │   │               │   │   ├── BCryptPasswordEncryptionComponent.java
    │   │               │   │   └── RequestInfoComponent.java
    │   │               │   ├── model
    │   │               │   │   ├── AuthByEmailRequest.java
    │   │               │   │   ├── AuthByRefreshTokenRequest.java
    │   │               │   │   ├── AuthResponse.java
    │   │               │   │   ├── Credential.java
    │   │               │   │   ├── ErrorResponse.java
    │   │               │   │   ├── InfoRequest.java
    │   │               │   │   ├── InfoResponse.java
    │   │               │   │   ├── UserRequest.java
    │   │               │   │   └── UserResponse.java
    │   │               │   └── service
    │   │               │       ├── AuthService.java
    │   │               │       ├── AuthServiceImpl.java
    │   │               │       ├── InfoService.java
    │   │               │       ├── InfoServiceImpl.java
    │   │               │       ├── UserService.java
    │   │               │       └── UserServiceImpl.java
    │   │               └── infrastrucuture
    │   │                   ├── InfrastructureBean.java
    │   │                   ├── cache
    │   │                   │   ├── CacheRepository.java
    │   │                   │   ├── local
    │   │                   │   │   └── LocalCacheRepository.java
    │   │                   │   └── redis
    │   │                   │       ├── RedisCacheRepository.java
    │   │                   │       └── RedisProperty.java
    │   │                   ├── entity
    │   │                   │   ├── Info.java
    │   │                   │   ├── SharedData.java
    │   │                   │   └── User.java
    │   │                   └── persistent
    │   │                       ├── InfoPersistentRepository.java
    │   │                       ├── UserPersistentRepository.java
    │   │                       ├── cassandra
    │   │                       │   ├── CassandraInfoPersistentRepository.java
    │   │                       │   ├── CassandraUserPersistentRepository.java
    │   │                       │   └── property
    │   │                       │       └── CassandraProperty.java
    │   │                       ├── local
    │   │                       │   ├── LocalInfoPersistentRepository.java
    │   │                       │   └── LocalUserPersistentRepository.java
    │   │                       ├── mongo
    │   │                       │   ├── MongoInfoPersistentRepository.java
    │   │                       │   ├── MongoUserPersistentRepository.java
    │   │                       │   ├── entity
    │   │                       │   │   ├── MongoInfoEntity.java
    │   │                       │   │   └── MongoUserEntity.java
    │   │                       │   └── property
    │   │                       │       └── MongoProperty.java
    │   │                       └── rdbms
    │   │                           ├── RdbmsInfoPersistentRepository.java
    │   │                           └── RdbmsUserPersistentRepository.java

Interceptor JWT verification

  • app/InterceptorController.java

MySQL Repository injection

  • infrastructure/persistent/rdbms/RdbmsUserPersistentRepository.java
  • infrastructure/persistent/rdbms/RdbmsInfoPersistentRepository.java

MongoDB Repository injection

  • infrastructure/persistent/mongo/RdbmsUserPersistentRepository.java
  • infrastructure/persistent/mongo/RdbmsInfoPersistentRepository.java

Cassandra Repository injection

  • infrastructure/persistent/cassandra/RdbmsUserPersistentRepository.java
  • infrastructure/persistent/cassandra/RdbmsInfoPersistentRepository.java

Redis Repository injection

  • infrastructure/cache/redis/RedisCacheRepository.java

Getting Started

Start database process

# RDBMS
docker-compose run -p 3306:3306 mysql_db

# Mongo
docker-compose run -p 27017:27017 mongo_db

# Cassandra
docker-compose up cassandra_01 cassandra_02 cassandra_03

Start api server via script

# RDBMS
./scripts/start_server.sh --spring_profile=local,db_rdbms

# Mongo
./scripts/start_server.sh --spring_profile=local,db_mongo

# Cassandra
./scripts/start_server.sh --spring_profile=local,db_cassandra

License

Apache-2.0

관련 프로젝트 살펴보기

불러오는 중…