{"id":15056784,"url":"https://github.com/tomoyane/springboot-bestpractice","last_synced_at":"2025-04-09T12:04:08.117Z","repository":{"id":40625526,"uuid":"121870314","full_name":"tomoyane/springboot-bestpractice","owner":"tomoyane","description":"SpringBoot best practice architecture. This repository describes multiple data connections with a architecture in mind. RDBMS/Mongo/Cassandra/Redis","archived":false,"fork":false,"pushed_at":"2024-02-04T07:37:32.000Z","size":393,"stargazers_count":255,"open_issues_count":1,"forks_count":51,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T06:59:38.163Z","etag":null,"topics":["cassandra","clean-architecture","docker","java","mongodb","mysql","redis","restful-api","spring-boot","springboot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomoyane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-17T16:18:31.000Z","updated_at":"2025-04-01T22:44:13.000Z","dependencies_parsed_at":"2024-02-09T01:41:20.598Z","dependency_job_id":null,"html_url":"https://github.com/tomoyane/springboot-bestpractice","commit_stats":{"total_commits":232,"total_committers":2,"mean_commits":116.0,"dds":0.06465517241379315,"last_synced_commit":"40170d2067fc65909cf2f240f01981385cff3824"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomoyane%2Fspringboot-bestpractice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomoyane%2Fspringboot-bestpractice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomoyane%2Fspringboot-bestpractice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomoyane%2Fspringboot-bestpractice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomoyane","download_url":"https://codeload.github.com/tomoyane/springboot-bestpractice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036064,"owners_count":21037092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cassandra","clean-architecture","docker","java","mongodb","mysql","redis","restful-api","spring-boot","springboot"],"created_at":"2024-09-24T21:56:28.229Z","updated_at":"2025-04-09T12:04:08.093Z","avatar_url":"https://github.com/tomoyane.png","language":"Java","readme":"# SpringBoot best practice\n[![springboot-bestpractice](https://github.com/tomoyane/springboot-bestpractice/actions/workflows/ci.yml/badge.svg)](https://github.com/tomoyane/springboot-bestpractice/actions/workflows/ci.yml)\n[![Apache License](https://img.shields.io/badge/license-Apatch-mediumpurple.svg?style=flat)](https://github.com/herts-stack/herts/blob/master/LICENSE)\n\nAbout Spring Boot architecture.\n\nThis repository support multiple database by SPRING_PROFILES_ACTIVE\n* RDBMS\n* MongoDB\n* Cassandra\n* Redis\n\n## Requirements\n * Docker engine\n * Docker Compose\n * OpenJDK 17\n * Spring Boot 2\n\n### Docker database\nMySQL8\n* **Standalone**\n\nMongoDB\n* **Standalone**\n\nCassandra cluster.\n* **3 Nodes**\n\n## Architecture\nThe \"app\" package holds controllers for API endpoints and provides interception. The \"app\" package can depend on the \"domain\" package.\n\nThe \"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.\n\nThe \"infrastructure\" package provides data storage by holding Spring Repository Beans. It is independent and cannot depend on the \"app\" and \"domain\" packages.\n\nThe \"common\" package offers generic functions.\n\nInitialization processes during server startup depend on \"SPRING_PROFILES_ACTIVE\" and assume the specified data store's Bean as a prerequisite for the initial startup.\n\n\n### Directory structure\n\n```bash\njava\n    │   │   └── com\n    │   │       └── bestpractice\n    │   │           └── api\n    │   │               ├── Application.java\n    │   │               ├── app\n    │   │               │   ├── AdviceController.java\n    │   │               │   ├── AppBean.java\n    │   │               │   ├── InterceptorController.java\n    │   │               │   ├── v1\n    │   │               │   │   ├── AuthController.java\n    │   │               │   │   ├── HelloController.java\n    │   │               │   │   ├── RdbmsController.java\n    │   │               │   │   └── UserController.java\n    │   │               │   └── v2\n    │   │               │       └── AuthorizationController.java\n    │   │               ├── common\n    │   │               │   ├── exception\n    │   │               │   │   ├── BadRequest.java\n    │   │               │   │   ├── Conflict.java\n    │   │               │   │   ├── Forbidden.java\n    │   │               │   │   ├── InternalServerError.java\n    │   │               │   │   ├── NotFound.java\n    │   │               │   │   ├── RequestTimeout.java\n    │   │               │   │   ├── ServiceUnavailable.java\n    │   │               │   │   └── UnAuthorized.java\n    │   │               │   ├── property\n    │   │               │   │   └── CredentialProperty.java\n    │   │               │   └── util\n    │   │               │       └── Util.java\n    │   │               ├── domain\n    │   │               │   ├── DomainBean.java\n    │   │               │   ├── component\n    │   │               │   │   ├── AuthComponent.java\n    │   │               │   │   ├── BCryptPasswordEncryptionComponent.java\n    │   │               │   │   └── RequestInfoComponent.java\n    │   │               │   ├── model\n    │   │               │   │   ├── AuthByEmailRequest.java\n    │   │               │   │   ├── AuthByRefreshTokenRequest.java\n    │   │               │   │   ├── AuthResponse.java\n    │   │               │   │   ├── Credential.java\n    │   │               │   │   ├── ErrorResponse.java\n    │   │               │   │   ├── InfoRequest.java\n    │   │               │   │   ├── InfoResponse.java\n    │   │               │   │   ├── UserRequest.java\n    │   │               │   │   └── UserResponse.java\n    │   │               │   └── service\n    │   │               │       ├── AuthService.java\n    │   │               │       ├── AuthServiceImpl.java\n    │   │               │       ├── InfoService.java\n    │   │               │       ├── InfoServiceImpl.java\n    │   │               │       ├── UserService.java\n    │   │               │       └── UserServiceImpl.java\n    │   │               └── infrastrucuture\n    │   │                   ├── InfrastructureBean.java\n    │   │                   ├── cache\n    │   │                   │   ├── CacheRepository.java\n    │   │                   │   ├── local\n    │   │                   │   │   └── LocalCacheRepository.java\n    │   │                   │   └── redis\n    │   │                   │       ├── RedisCacheRepository.java\n    │   │                   │       └── RedisProperty.java\n    │   │                   ├── entity\n    │   │                   │   ├── Info.java\n    │   │                   │   ├── SharedData.java\n    │   │                   │   └── User.java\n    │   │                   └── persistent\n    │   │                       ├── InfoPersistentRepository.java\n    │   │                       ├── UserPersistentRepository.java\n    │   │                       ├── cassandra\n    │   │                       │   ├── CassandraInfoPersistentRepository.java\n    │   │                       │   ├── CassandraUserPersistentRepository.java\n    │   │                       │   └── property\n    │   │                       │       └── CassandraProperty.java\n    │   │                       ├── local\n    │   │                       │   ├── LocalInfoPersistentRepository.java\n    │   │                       │   └── LocalUserPersistentRepository.java\n    │   │                       ├── mongo\n    │   │                       │   ├── MongoInfoPersistentRepository.java\n    │   │                       │   ├── MongoUserPersistentRepository.java\n    │   │                       │   ├── entity\n    │   │                       │   │   ├── MongoInfoEntity.java\n    │   │                       │   │   └── MongoUserEntity.java\n    │   │                       │   └── property\n    │   │                       │       └── MongoProperty.java\n    │   │                       └── rdbms\n    │   │                           ├── RdbmsInfoPersistentRepository.java\n    │   │                           └── RdbmsUserPersistentRepository.java\n```\n\n### Interceptor JWT verification\n\n* app/InterceptorController.java\n\n### MySQL Repository injection\n\n* infrastructure/persistent/rdbms/RdbmsUserPersistentRepository.java\n* infrastructure/persistent/rdbms/RdbmsInfoPersistentRepository.java\n\n### MongoDB Repository injection\n\n* infrastructure/persistent/mongo/RdbmsUserPersistentRepository.java\n* infrastructure/persistent/mongo/RdbmsInfoPersistentRepository.java\n\n### Cassandra Repository injection\n\n* infrastructure/persistent/cassandra/RdbmsUserPersistentRepository.java\n* infrastructure/persistent/cassandra/RdbmsInfoPersistentRepository.java\n\n### Redis Repository injection\n\n* infrastructure/cache/redis/RedisCacheRepository.java\n\n## Getting Started\n\nStart database process\n```bash\n# RDBMS\ndocker-compose run -p 3306:3306 mysql_db\n\n# Mongo\ndocker-compose run -p 27017:27017 mongo_db\n\n# Cassandra\ndocker-compose up cassandra_01 cassandra_02 cassandra_03\n```\n\nStart api server via script\n```bash\n# RDBMS\n./scripts/start_server.sh --spring_profile=local,db_rdbms\n\n# Mongo\n./scripts/start_server.sh --spring_profile=local,db_mongo\n\n# Cassandra\n./scripts/start_server.sh --spring_profile=local,db_cassandra\n```\n\n## License\n[Apache-2.0](https://github.com/tomoyane/springboot-bestpractice/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomoyane%2Fspringboot-bestpractice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomoyane%2Fspringboot-bestpractice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomoyane%2Fspringboot-bestpractice/lists"}