Java Spring Boot κΈ°λ° μ μμκ±°λ λ°±μλ μλΉμ€.
μ¬μ©μ, μν, μΏ ν°, μμ‘, μ£Όλ¬Έμ μ€μ¬μΌλ‘ λλ©μΈ μ£Όλ μ€κ³(DDD)μ κ³μΈ΅ν μν€ν μ²λ₯Ό μ μ©ν νλ‘μ νΈμ λλ€.
λμμ± μ μ΄, μ΄λ²€νΈ κΈ°λ° μ²λ¦¬, Redis/Kafka νμ©, μ±λ₯ ν μ€νΈ λ± μ€λ¬΄ν μν€ν μ² νμ΅μ μ€μ μ λμμ΅λλ€.
- E-Commerce (Java Backend)
E-Commerce Java λ°±μλ μλΉμ€λ λ€μ κΈ°λ₯λ€μ μ 곡ν©λλ€:
- μ¬μ©μ μ‘°ν λ° κ΄λ¦¬
- μμ‘(Balance) μ‘°ν, μΆ©μ , μ¬μ©
- μν(Product) μ‘°ν, ν΅κ³
- μΏ ν°(Coupon) λ°κΈ / μ¬μ© / μ μ± κ²μ¦
- μ£Όλ¬Έ(Order) μ²λ¦¬: μν μ¬κ³ μμ½, μΏ ν° ν μΈ, μμ‘ μ¬μ©, μ£Όλ¬Έ μλ£ μ΄λ²€νΈ λ°ν
μ£Όμ μꡬμ¬νμΌλ‘λ λλ©μΈ κ° μ± μ λΆλ¦¬, κ³μΈ΅ κ° μμ‘΄μ± μ΅μν, **볡μ‘ν νλ¦(μ: μ£Όλ¬Έ)**μ λͺ νν μ‘°μ¨(Facade κ³μΈ΅) λ±μ΄ μμμ΅λλ€.
Controller β (Facade) β Service β Domain / Repository
- Controller: HTTP μμ²/μλ΅, DTO λ³ν, API λͺ μΈ
- Facade: μ¬λ¬ Serviceλ₯Ό μ‘°ν©ν΄ λ³΅ν© νλ¦(complex business logic) μ²λ¦¬
- Service: λ¨μΌ λλ©μΈμ λΉμ¦λμ€ λ‘μ§
- Domain / Repository: Entity μ μ, DB μ κ·Ό (JPA κΈ°λ°)
κ° λλ©μΈ(User, Product, Coupon, Order, Balance λ±)μ λν΄ λ€μκ³Ό κ°μ΄ κ³μΈ΅μ΄ λΆλ¦¬λμ΄ μμ΅λλ€:
controller: μμ²/μλ΅ μ± μfacade: μ‘°μ¨μ μν , μ¬λ¬ Service κ° νλ¦ μ μ΄application(Service): λλ©μΈ λ¨μ κΈ°λ₯domain: Entity, Repository, μν, λ΄λΆ λ‘μ§exception: λλ©μΈ/κ³μΈ΅λ³ μμΈ μ μdto/common,common: κ³΅ν΅ DTO, μλ¬ νΈλ€λ§ λ±
| λλ©μΈ μ ν | νλ¦ μμ |
|---|---|
| λ¨μ λλ©μΈ | Product β ProductController β ProductService β ProductRepository |
| λ³΅ν© λλ©μΈ | Order λλ©μΈ: OrderController β OrderFacade β (UserService, ProductService, CouponService, BalanceService, OrderService) β κ° Repository |
λ³΅ν© λλ©μΈμ νλ¦μ νΈλμμ κ²½κ³ λ° μμΈ μ²λ¦¬ λ±μ΄ 볡μ‘νλ―λ‘, Facade κ³μΈ΅μμ μ± μμ μ€μ¬ννμ¬ μ μ§λ³΄μμ±κ³Ό νμ₯μ±μ ν보νκ³ μμ.
μλλ κ° λλ©μΈμ ν΅μ¬ μν κ³Ό μ€λΈμ νΈ κ΄κ³/μνΈμμ© μ 리μ λλ€.
- μ¬μ©μ(User)λ μμ‘(Balance)μ κ°μ§
- μμ‘ μΆ©μ λ° μ°¨κ° κΈ°λ₯
- μμ‘ λΆμ‘± μ μμΈ μ²λ¦¬ (InsufficientBalanceException)
- μν μ 보(Product), κ°κ²©, μ¬κ³ (stock)
- μν μ‘°ν, μ¬κ³ κ΄λ¦¬
- μνμ΄ μ‘΄μ¬νμ§ μκ±°λ μ¬κ³ λΆμ‘± μ μμΈ μ²λ¦¬ (ProductNotFoundException λ±)
- μΏ ν° μ μ± (CouponPolicy) μ μ
- μΏ ν° μ¬μ© μ ν¨μ± μ²΄ν¬ (κΈ°κ°, μμ§ μ¬λΆ λ±)
- μ¬μ©μβμΏ ν° μ°κ΄ κ΄λ¦¬
-
μ£Όλ¬Έ μμ± νλ¦:
- μ¬μ©μ μ‘°ν
- μν μ¬κ³ μμ½ (ProductService)
- μ£Όλ¬Έ μμ΄ν μμ±
- μ£Όλ¬Έ κΈμ‘ ν©μ°
- μΏ ν° ν μΈ κ³μ°
- μμ‘ μ¬μ© κ²μ¬ λ° μ°¨κ°
- μ£Όλ¬Έ λ μ½λ μμ±
- μ£Όλ¬Έ μλ£ μ΄λ²€νΈ λ°ν
-
OrderItem, OrderStatus λ±μ μν μ μ
-
μ£Όλ¬Έ μ€ν¨ μ νΈλμμ λ‘€λ°± 보μ₯λ¨ (μ: μ¬κ³ μμ½ μ€ν¨, μμ‘ λΆμ‘± λ±)
μλλ μ£Όμ λλ ν°λ¦¬ ꡬ쑰 (src/main/java κΈ°μ€) μμ½:
kr.hhplus.be.server
βββ balance
β βββ application / BalanceService
β βββ controller / BalanceController, DTO
β βββ domain / Balance, BalanceHistory, Repository
β βββ facade / BalanceFacade
βββ coupon
β βββ application / CouponService
β βββ controller / CouponController, DTO
β βββ domain / Coupon, Policy, Repository
β βββ facade / CouponFacade
βββ order
β βββ application / OrderService
β βββ controller / OrderController, DTO
β βββ domain / Order, OrderItem, Repository
β βββ facade / OrderFacade + Command/Mapper
βββ product
β βββ application / ProductService
β βββ controller / ProductController, DTOs, Statistics API
β βββ domain / Product, Repository
β βββ exception
βββ user
β βββ application / UserService
β βββ controller / (UserController)
β βββ domain / User, Repository
β βββ exception
βββ common
β βββ dto / μλ¬ μλ΅ λ± κ³΅ν΅ DTO
β βββ exception / GlobalExceptionHandler λ±
βββ config / Swagger, JPA λ± μ€μ
μΆκ°λ‘, docker-compose.yml, docker-compose-redis.yml, docker-compose-kafka.yml λ±μ΄ μμ΄ κ°λ°/λ‘컬 νκ²½ κ΅¬μ± μ§μλ¨.
- λ¨μ ν μ€νΈ(Unit Tests): κ° Service, Domain κΈ°λ₯ λ³ ν μ€νΈ
- ν΅ν© ν μ€νΈ(Integration Tests): DB μ°λ, Repository λμ, Facade νλ¦ λ±μ΄ ν¬ν¨λ¨
- ν μ€νΈ 컀λ²λ¦¬μ§ νλ³΄κ° λμ λΆλΆμ΄ μλ€λ©΄ λ³΄κ° κ°λ₯
ν μ€νΈ μ:
ProductServiceTest.javaOrderControllerTest.javaBalanceRepositoryIntegrationTest.javaλ±
μλλ λ‘컬 κ°λ° νκ²½μμ νλ‘μ νΈλ₯Ό μ€ννκΈ° μν κΈ°λ³Έ μλ΄μ λλ€. μ€μ νκ²½μ λ°λΌ νκ²½ λ³μλ μ€μ μ΄ λ€λ₯Ό μ μμΌλ―λ‘ μ°Έκ³ μ©μ λλ€.
- JDK (μ΅μ λ²μ κΆμ₯, μ: Java 17 μ΄μ)
- Gradle (wrapper μ 곡λ¨)
- Docker & Docker Compose (Redis, Kafka λ± λ컀 μλΉμ€ νμ μ)
- λ°μ΄ν°λ² μ΄μ€ (μ: MySQL, PostgreSQL λ±), νΉμ λ΄μ₯ DB μ€μ
-
μ½λ ν΄λ‘ :
git clone https://github.com/hanghae-plus-anveloper/e-commerce.git cd e-commerce -
νκ²½ νμΌ μ€μ :
application.ymlλλ μ μ ν νκ²½ μ€μ νμΌμ DB μ μ μ 보, Redis/Kafka μ€μ λ±μ μ λ ₯- νμ μ
.envνμΌ λλ νκ²½ λ³μ μ¬μ©
-
λ컀 μλΉμ€ μμ (μ΅μ ):
docker-compose up -d # λλ docker-compose -f docker-compose-redis.yml -f docker-compose-kafka.yml up -d -
λΉλ & μ€ν:
./gradlew clean build ./gradlew bootRun
-
API λ¬Έμ νμΈ:
Swagger μ€μ μ΄ μμΌλ―λ‘
http://localhost:8080/swagger-ui.htmlλλ ν΄λΉ μλν¬μΈνΈμμ λ¬Έμ νμΈ κ°λ₯