2024.07 - ing
https://github.com/TaeGyeong115/spring-commerce-api
https://github.com/TaeGyeong115/kotlin-commerce-api
https://github.com/TaeGyeong115/nestjs-commerce-api
Spring Boot
Java
JPA
Docker
MySQL
JWT
QueryDSL
Spring Boot
Kotlin
Docker
MySQL
Nest.js
TypeScript
Docker
PostgreSQL
MikroORM
MongoDB
sequenceDiagram
actor User as 판매자(Client)
box API Server
participant Resolver as Auth Resolver
participant Controller as API Controller
participant Service as Business Logic Service
participant Repository as Data Access Layer
end
participant DB as Database
User->>Resolver: POST /api/products<br>Authorization: Bearer <token>
note right of User: 제품 등록 요청
alt 유효한 토큰 (Valid Token)
note right of Resolver: Authorization 헤더 토큰 검증
Resolver->>Controller: Forward Request (사용자 정보, 제품 정보)
note right of Resolver: 제품 등록 요청
Controller->>Service: Process Product Registration (제품 정보)
note right of Controller: 제품 등록을 위한 비즈니스 로직 호출
Service->>Repository: Save Product (제품 정보)
note right of Service: 제품 정보 전달
Repository->>DB: INSERT INTO products...
note right of Repository: 제품 정보 저장
alt 저장 성공 (201 Created)
DB-->>Repository: 저장 성공 응답
note right of DB: 제품 정보 저장 완료
Repository-->>Service: 저장 성공 응답
Service-->>Controller: Product Registration Successful
Controller-->>Resolver: 201 Created
Resolver-->>User: 201 Created (제품 등록 성공)
note right of Resolver: 제품 등록 성공 알림
else 저장 실패 (500 Internal Server Error)
DB-->>Repository: 저장 실패 응답
note right of DB: 제품 정보 저장 중 오류 발생
Repository-->>Service: 저장 실패 응답
Service-->>Controller: Registration Failed
Controller-->>Resolver: 500 Internal Server Error
Resolver-->>User: 500 Internal Server Error (제품 등록 실패)
note right of Resolver: 제품 등록 실패 알림
end
else 유효하지 않은 토큰 (Invalid Token)
Resolver-->>User: 401 Unauthorized (유효하지 않은 토큰)
note right of Resolver: 유효하지 않은 토큰 알림
end
sequenceDiagram
actor Buyer as 구매자(Client)
box API Server
participant Resolver as Auth Resolver
participant Controller as API Controller
participant Service as Business Logic Service
participant Repository as Data Access Layer
end
participant DB as Database
Buyer->>Resolver: POST /api/products/{productId}/orders<br>Authorization: Bearer <token>
note right of Buyer: 제품 주문 요청
alt 유효한 토큰 (Valid Token)
note right of Resolver: Authorization 헤더 토큰 검증
Resolver->>Controller: Forward Request (사용자 정보, 구매 정보)
note right of Resolver: 제품 구매 요청
Controller->>Service: Process Purchase (구매 정보)
note right of Controller: 구매를 위한 비즈니스 로직 호출
Service->>Repository: Check Product Availability (제품 ID)
note right of Service: 구매 가능 가격/상태/재고 확인
Repository->>DB: SELECT * FROM products WHERE id = 제품 ID
note right of Repository: 제품 정보 조회
DB-->>Repository: 제품 정보 반환
Repository-->>Service: 제품 확인 결과 전달
alt 상태/가격/재고 확인 성공 (200 OK)
Service->>Repository: Save Purchase (구매 정보)
note right of Service: 구매 정보 전달
Repository->>DB: INSERT INTO purchases...
note right of Repository: 구매 정보 저장
alt 저장 성공 (201 Created)
DB-->>Repository: 저장 성공 응답
Repository-->>Service: 저장 성공 응답
Service-->>Controller: Purchase Successful
Controller-->>Resolver: 201 Created
Resolver-->>Buyer: 201 Created (구매 성공)
note right of Resolver: 구매 성공 알림
else 저장 실패 (500 Internal Server Error)
DB-->>Repository: 저장 실패 응답
Repository-->>Service: 저장 실패 응답
Service-->>Controller: Purchase Failed
Controller-->>Resolver: 500 Internal Server Error
Resolver-->>Buyer: 500 Internal Server Error (구매 실패)
note right of Resolver: 오류 메시지 알림
end
else 재고 없음 (404 Not Found)
Service-->>Controller: Purchase Failed
Controller-->>Resolver: 404 Not Found
Resolver-->>Buyer: 404 Not Found (재고 부족)
note right of Resolver: 재고 부족 메시지 알림
else 가격 변동 (404 Not Found)
Service-->>Controller: Purchase Failed
Controller-->>Resolver: 404 Not Found
Resolver-->>Buyer: 404 Not Found (가격 변동)
note right of Resolver: 가격 변동 메시지 알림
end
else 유효하지 않은 토큰 (Invalid Token)
Resolver-->>Buyer: 401 Unauthorized (유효하지 않은 토큰)
note right of Resolver: 유효하지 않은 토큰 알림
end
erDiagram
members {
long id PK "아이디"
string name "이름"
string nick_name "닉네임"
string email "이메일"
string password "비밀번호"
timestamp created_date "생성일시"
timestamp modified_date "수정일시"
}
products {
long id PK "아이디"
long provider_id FK "판매자 아이디"
string name "이름"
int total_quantity "총 수량"
int sold_quantity "판매 수량"
decimal price "가격"
int status "제품 판매 상태"
timestamp created_date "제품 등록일시"
timestamp modified_date "제품 수정일시"
}
orders {
long id PK "아이디"
long customer_id FK "구매자 아이디"
int status "주문 상태"
decimal price "가격"
decimal total_price "결제 비용"
long quantity "수량"
timestamp created_date "주문 생성일시"
timestamp modified_date "주문 수정일시"
}
logs {
long id PK "아이디"
long member_id FK "멤버 아이디"
long target_id "대상 아이디"
int target_type "대상 타입"
int action_type "행동 타입"
timestamp created_date "주문 생성일시"
timestamp modified_date "주문 수정일시"
}
members ||--|{ products : manages
products ||--|{ orders : contains
members ||--|{ orders : places
members ||--|{ logs : manages
flowchart TB
start(((시작))) --비회원--> Join[회원가입]
start --비회원--> Login[로그인]
start --> ProductList[제품 리스트 조회]
start --회원--> ProductCreate[제품 등록]
start --회원--> OrderList[주문 리스트 조회]
start --회원--> LogList[활동 로그 조회]
start --회원--> Logout[로그아웃]
ProductList --> Product[제품 상세 조회]
ProductList --회원--> ProductOwned[등록 제품 리스트 조회]
Product --회원--> ProductOrder[제품 주문]
ProductOwned --회원--> ProductOrderList[특정 제품 주문 리스트 조회]
ProductOrderList --회원--> ProductStatue[제품 상태 변경]
ProductOrderList --회원--> OrderStatue[주문 상태 변경]
OrderList --회원--> Order[주문 상세 조회]
Order --회원--> OrderStatus[주문 상태 변경]
Product Status - 판매중(FOR_SALE)
판매완료(SOLD_OUT)
Order Status - 주문 중(IN_PROGRESS)
주문 완료(COMPLETED)
주문 취소(CANCELED)
Target Type - 제품(PRODUCT)
주문(ORDER)
Action Type - 생성(CREATE)
수정(UPDATE)
삭제(DELETE)
완료(COMPLETE)
활성화(ACTIVATE)
비활성화(DEACTIVATE)
Key | Value |
---|---|
Authorization | Bearer {access token} |
Content-Type | application/json |