외부 시퀀스 설계 완료

- 3개 핵심 비즈니스 플로우별 외부 시퀀스 다이어그램 작성
  - 사용자인증플로우.puml: UFR-AUTH-010, UFR-AUTH-020 반영
  - 요금조회플로우.puml: UFR-BILL-010~040 반영
  - 상품변경플로우.puml: UFR-PROD-010~040 반영

- 논리아키텍처와 참여자 완전 일치
- UI/UX 설계서 사용자 플로우 100% 반영
- 클라우드 패턴 적용 (API Gateway, Cache-Aside, Circuit Breaker)
- PlantUML 문법 검사 통과 (mono 테마 적용)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
hiondal
2025-09-08 10:27:39 +09:00
parent db7d66a9fc
commit 7ec8a682c6
27 changed files with 1904 additions and 0 deletions
@@ -0,0 +1,213 @@
# 통신요금 관리 서비스 - 논리아키텍처 설계서
**최적안**: 이개발(백엔더)
---
## 개요
### 설계 원칙
- **마이크로서비스 아키텍처**: 서비스별 독립성 보장, 독립적 배포/확장
- **클라우드 네이티브 패턴 적용**: API Gateway, Cache-Aside, Circuit Breaker 패턴 적용
- **캐시 우선 전략**: 성능 최적화를 위한 Redis 기반 캐싱
- **외부 시스템 안정성**: Circuit Breaker를 통한 장애 격리
### 핵심 컴포넌트 정의
1. **API Gateway**: 단일 진입점, 인증/인가, 라우팅
2. **마이크로서비스**: Auth, Bill-Inquiry, Product-Change 서비스
3. **캐시 레이어**: Redis 기반 캐시-어사이드 패턴
4. **외부 연동**: KOS-Order 시스템과 Circuit Breaker 패턴 연동
---
## 서비스 아키텍처
### 서비스별 책임
#### 1. Auth Service
- **핵심 책임**: 사용자 인증 및 인가 처리
- **주요 기능**:
- JWT 토큰 발급/검증
- 사용자 세션 관리
- 서비스별 접근 권한 확인
- 로그인 실패 처리 (5회 실패 시 계정 잠금)
- **데이터**: 사용자 정보, 권한 정보, 세션 데이터
#### 2. Bill-Inquiry Service
- **핵심 책임**: 요금 조회 및 KOS 연동 처리
- **주요 기능**:
- 요금 조회 메뉴 제공
- 조회월 선택 처리 (당월 또는 특정 월)
- KOS-Order 시스템 연동 (Circuit Breaker 적용)
- 조회 결과 캐싱 및 MVNO AP 전송
- 요청/처리 이력 관리
- **데이터**: 요금 조회 이력, KOS 연동 결과
#### 3. Product-Change Service
- **핵심 책임**: 상품 변경 요청 및 처리
- **주요 기능**:
- 상품 변경 메뉴 제공
- 고객/상품 정보 조회 (KOS 연동)
- 상품 변경 사전 체크
- 상품 변경 처리 및 결과 전송
- 변경 이력 관리
- **데이터**: 상품 변경 이력, 고객 정보 캐시, 상품 정보 캐시
### 서비스 간 통신 전략
#### 동기 통신
- **API Gateway를 통한 서비스 라우팅**: 모든 클라이언트 요청
- **서비스 간 직접 통신 최소화**: 캐시를 통한 데이터 공유
#### 캐시 우선 전략
- **사용자 세션**: Auth 서비스에서 Redis 캐시 활용 (TTL: 30분)
- **요금 조회 결과**: 1시간 캐싱으로 KOS 부하 감소
- **상품 정보**: 24시간 캐싱으로 반복 조회 최적화
#### 비동기 처리
- **로그/이력 처리**: 응답 성능에 영향 없는 백그라운드 처리
---
## 주요 사용자 플로우
### 1. 인증 플로우
```
[클라이언트] → [API Gateway] → [Auth Service] → [Redis(세션)] → [PostgreSQL(사용자)]
[JWT 토큰 발급] ← [Auth Service] ← [API Gateway] ← [클라이언트]
```
### 2. 요금 조회 플로우
```
[클라이언트] → [API Gateway] → [Bill-Inquiry Service]
[1. Redis 캐시 확인]
[2. 캐시 Miss 시 KOS 연동 (Circuit Breaker)]
[3. 결과 캐싱 후 반환]
[4. MVNO AP 전송]
[5. 이력 DB 저장]
```
### 3. 상품 변경 플로우
```
[클라이언트] → [API Gateway] → [Product-Change Service]
[1. 상품정보 캐시 확인/KOS 조회]
[2. 변경 사전 체크]
[3. KOS 상품 변경 처리 (Circuit Breaker)]
[4. 결과 처리 및 전송]
```
---
## 데이터 흐름 및 캐싱 전략
### 데이터 흐름
1. **클라이언트 요청** → API Gateway (인증/라우팅)
2. **서비스 처리** → 캐시 확인 → 외부/DB 조회 (필요시)
3. **응답 처리** → 캐시 업데이트 → 클라이언트 응답
4. **이력 저장** → 비동기 처리
### 캐싱 전략 (Cache-Aside 패턴)
#### 캐시 대상 및 TTL
- **사용자 세션**: 30분 (로그인 유지 시간)
- **요금 조회 결과**: 1시간 (KOS 부하 감소)
- **상품 정보**: 24시간 (변경 빈도 낮음)
- **고객 정보**: 4시간 (상품 변경 시 필요)
#### 캐시 무효화 정책
- **사용자 로그아웃**: 즉시 세션 삭제
- **상품 변경 완료**: 해당 고객 상품 정보 캐시 삭제
- **TTL 만료**: 자동 삭제 후 다음 조회 시 갱신
#### 캐시 성능 목표
- **캐시 적중률**: 85% 이상
- **응답 시간 개선**: 80% (1000ms → 200ms)
- **외부 시스템 부하**: 85% 감소
---
## 확장성 및 성능 고려사항
### Horizontal Scaling 전략
- **API Gateway**: 로드 밸런서 뒤에 다중 인스턴스 배치
- **마이크로서비스**: 서비스별 독립적 확장 (CPU/메모리 사용량 기준)
- **Redis 클러스터**: 캐시 부하 분산 및 고가용성
- **데이터베이스**: 읽기 전용 복제본을 통한 읽기 성능 향상
### 성능 목표
- **API 응답 시간**:
- 일반 조회: 200ms 이내
- 외부 연동: 3초 이내 (Circuit Breaker 타임아웃)
- **동시 사용자**: 1,000명 (Peak 시간대)
- **처리량**: API Gateway 1,000 TPS
### 병목점 해결 방안
- **KOS 연동 지연**: Circuit Breaker + 캐시 활용
- **데이터베이스 부하**: 캐시-어사이드 패턴으로 85% 부하 감소
- **인증 처리**: JWT 토큰으로 상태 정보 분산
---
## 보안 고려사항
### 인증/인가 체계
- **JWT 기반 토큰**: 서버 상태 비저장으로 확장성 확보
- **토큰 만료**: Access Token(30분) + Refresh Token(24시간)
- **권한 기반 접근 제어**: 서비스별 권한 확인
### 데이터 보호
- **전송 중 암호화**: HTTPS 적용, API Gateway에서 SSL 종료
- **저장 중 암호화**: 민감 데이터(개인정보) DB 레벨 암호화
- **세션 보안**: Redis AUTH, TTL 기반 자동 만료
### 외부 연동 보안
- **KOS 연동**: 전용 네트워크 또는 VPN 연결
- **API 키 관리**: 환경 변수로 분리, 주기적 로테이션
- **요청/응답 로깅**: 개인정보 마스킹 처리
### 보안 모니터링
- **이상 트래픽 탐지**: API Gateway Rate Limiting
- **로그인 시도 추적**: 5회 실패 시 계정 잠금
- **접근 로그**: 모든 API 요청/응답 로그 수집
---
## 논리아키텍처 다이어그램
상세한 논리아키텍처 다이어그램은 [logical-architecture.mmd](logical-architecture.mmd) 파일을 참조하세요.
---
## 검토 결과
### 유저스토리 매칭 검토 ✅
- UFR-AUTH-010, UFR-AUTH-020: Auth Service에서 완전 처리
- UFR-BILL-010, UFR-BILL-020, UFR-BILL-030, UFR-BILL-040: Bill-Inquiry Service에서 완전 처리
- UFR-PROD-010, UFR-PROD-020, UFR-PROD-030, UFR-PROD-040: Product-Change Service에서 완전 처리
- 총 10개 유저스토리 100% 반영, 불필요한 추가 설계 없음
### 아키텍처 패턴 적용 검토 ✅
- **API Gateway 패턴**: 단일 진입점, 인증/라우팅 중앙 관리
- **Cache-Aside 패턴**: Redis 기반 캐싱으로 성능 최적화
- **Circuit Breaker 패턴**: KOS 연동 안정성 확보
### 사용자 플로우 반영 검토 ✅
- UI/UX 설계서의 8개 화면 플로우와 일치
- 메인 플로우와 오류 처리 플로우 모두 반영
- 화면 전환과 서비스 호출 흐름이 일치
---
**작성자**: 이개발(백엔더), 김기획(기획자)
**작성일**: 2025-01-08
**검토자**: 최운영(데옵스), 정테스트(QA매니저), 박화면(프론트)
@@ -0,0 +1,72 @@
graph TB
subgraph ClientLayer ["Client Layer"]
Client[MVNO Frontend<br/>React SPA]
end
subgraph GatewayLayer ["API Gateway Layer"]
Gateway[API Gateway<br/>Authentication/Authorization<br/>Rate Limiting Load Balancing<br/>Request Routing<br/>Logging Monitoring]
end
subgraph MicroservicesLayer ["Microservices Layer"]
Auth[Auth Service<br/>JWT Management<br/>User Sessions<br/>Role-based Access Control<br/>Login Failure Handling]
BillQuery[Bill-Inquiry Service<br/>Query Menu Processing<br/>KOS Integration<br/>Cache Management<br/>History Tracking]
ProdChange[Product-Change Service<br/>Change Menu Screen<br/>Pre-check Processing<br/>KOS Integration<br/>Change History]
end
subgraph CachingLayer ["Caching Layer"]
Redis[Redis Cache<br/>User Sessions 30min TTL<br/>Bill Query Results 1hr TTL<br/>Product Information 24hr TTL<br/>Customer Data 4hr TTL]
end
subgraph DataLayer ["Data Layer"]
AuthDB[(Auth Database<br/>PostgreSQL<br/>User Information<br/>Access Rights<br/>Login History)]
BillDB[(Bill History DB<br/>PostgreSQL<br/>Query History<br/>KOS Integration Logs)]
ProdDB[(Product Change DB<br/>PostgreSQL<br/>Change History<br/>Processing Logs)]
end
subgraph ExternalSystems ["External Systems"]
KOS[KOS-Order System<br/>Legacy Backend<br/>Bill Query API<br/>Product Change API<br/>Customer Info API]
MVNO[MVNO AP Server<br/>Frontend API<br/>Result Transmission<br/>Screen Updates]
end
%% Client to Gateway
Client -->|HTTPS Request| Gateway
%% Gateway to Services (API Gateway Pattern)
Gateway -->|Auth Login Request| Auth
Gateway -->|Bill Query Menu| BillQuery
Gateway -->|Product Change Request| ProdChange
%% Services to Cache (Cache-Aside Pattern)
Auth -.->|Session Cache<br/>Cache-Aside| Redis
BillQuery -.->|Query Result Cache<br/>Cache-Aside| Redis
ProdChange -.->|Product Info Cache<br/>Cache-Aside| Redis
%% Services to Databases
Auth --> AuthDB
BillQuery --> BillDB
ProdChange --> ProdDB
%% External System Connections (Circuit Breaker Pattern)
BillQuery -->|KOS Bill Query<br/>Circuit Breaker| KOS
ProdChange -->|Product Change Process<br/>Circuit Breaker| KOS
BillQuery -->|Query Result Send| MVNO
ProdChange -->|Process Result Send| MVNO
%% Service Dependencies (Token Validation via Gateway)
BillQuery -.->|Token Validation<br/>via Gateway| Auth
ProdChange -.->|Token Validation<br/>via Gateway| Auth
%% Styling
classDef gateway fill:#e1f5fe,stroke:#01579b,stroke-width:3px
classDef service fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
classDef cache fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef database fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
classDef external fill:#ffebee,stroke:#b71c1c,stroke-width:2px
class Gateway gateway
class Auth,BillQuery,ProdChange service
class Redis cache
class AuthDB,BillDB,ProdDB database
class KOS,MVNO external
+184
View File
@@ -0,0 +1,184 @@
# 외부 시퀀스 설계서 - 통신요금 관리 서비스
**최적안**: 이개발(백엔더)
---
## 개요
통신요금 관리 서비스의 3개 핵심 비즈니스 플로우에 대한 외부 시퀀스 설계입니다.
각 플로우는 UI/UX 설계서의 사용자 플로우와 논리아키텍처의 참여자를 기반으로 설계되었습니다.
---
## 설계 파일 목록
### 1. 사용자 인증 플로우
- **파일**: `사용자인증플로우.puml`
- **관련 유저스토리**: UFR-AUTH-010, UFR-AUTH-020
- **관련 화면**: SCR-001 (로그인), SCR-002 (메인 화면)
- **주요 기능**: 로그인, 권한 확인, 세션 관리, JWT 토큰 처리
### 2. 요금조회 플로우
- **파일**: `요금조회플로우.puml`
- **관련 유저스토리**: UFR-BILL-010, UFR-BILL-020, UFR-BILL-030, UFR-BILL-040
- **관련 화면**: SCR-003 (요금조회 메뉴), SCR-004 (요금조회 결과)
- **주요 기능**: 요금조회 메뉴, KOS 연동, 결과 캐싱, 이력 관리
### 3. 상품변경 플로우
- **파일**: `상품변경플로우.puml`
- **관련 유저스토리**: UFR-PROD-010, UFR-PROD-020, UFR-PROD-030, UFR-PROD-040
- **관련 화면**: SCR-005 (상품변경 메뉴), SCR-006 (상품변경 화면), SCR-007 (상품변경 요청), SCR-008 (처리결과)
- **주요 기능**: 상품변경 메뉴, 사전체크, KOS 변경처리, 성공/실패 처리
---
## 설계 원칙 준수 현황
### ✅ 유저스토리 매칭
- **총 10개 유저스토리 100% 반영**
- 불필요한 추가 설계 없음
- 각 플로우별 관련 유저스토리 완전 반영
### ✅ 논리아키텍처 일치
- **모든 참여자가 논리아키텍처와 일치**
- 서비스 간 통신 방식 일치 (동기/비동기)
- 아키텍처 패턴 적용 (API Gateway, Cache-Aside, Circuit Breaker)
### ✅ UI/UX 플로우 반영
- **사용자 플로우와 외부 시퀀스 일치**
- 화면 전환과 서비스 호출 순서 일치
- 오류 처리 플로우 반영
### ✅ 기술적 고려사항
- **Cache-Aside 패턴**: 성능 최적화
- **Circuit Breaker 패턴**: KOS 연동 안정성
- **비동기 처리**: 이력 저장 성능 최적화
- **보안 처리**: JWT 토큰 기반 인증/인가
---
## 참여자 및 역할
### Frontend Layer
- **MVNO Frontend (React SPA)**: 사용자 인터페이스 제공
### Gateway Layer
- **API Gateway**: 인증/라우팅, Rate Limiting, Load Balancing
### Microservices Layer
- **Auth Service**: 인증/인가, 세션 관리, JWT 처리
- **Bill-Inquiry Service**: 요금조회 로직, KOS 연동, 캐싱
- **Product-Change Service**: 상품변경 로직, 사전체크, KOS 연동
### Infrastructure Layer
- **Redis Cache**: 세션, 조회결과, 상품정보 캐싱 (Cache-Aside)
- **PostgreSQL**: Auth DB, Bill History DB, Product Change DB
### External Systems
- **KOS-Order System**: 통신사 백엔드 시스템 (Circuit Breaker 적용)
- **MVNO AP Server**: 프론트엔드 API 서버
---
## 기술 패턴 적용
### API Gateway 패턴
- **단일 진입점**: 모든 클라이언트 요청 처리
- **인증/인가 중앙화**: JWT 토큰 검증
- **서비스별 라우팅**: 요청을 적절한 마이크로서비스로 전달
### Cache-Aside 패턴
- **세션 캐싱**: 30분 TTL, Auth Service에서 활용
- **조회결과 캐싱**: 1시간 TTL, Bill-Inquiry Service에서 활용
- **상품정보 캐싱**: 24시간 TTL, Product-Change Service에서 활용
- **성능 향상**: DB/외부 시스템 부하 85% 감소
### Circuit Breaker 패턴
- **KOS 연동 보호**: 외부 시스템 장애 시 서비스 보호
- **자동 복구**: 타임아웃/오류 발생 시 자동 차단 및 복구
- **안정성 확보**: 99.9% 서비스 가용성 목표
---
## 통신 방식
### 동기 통신 (실선 →)
- **사용자 요청/응답**: 즉시 응답이 필요한 모든 처리
- **서비스 간 호출**: API Gateway를 통한 서비스 라우팅
- **캐시 조회**: Redis Cache 조회/저장
- **외부 시스템 연동**: KOS-Order, MVNO AP Server 호출
### 비동기 통신 (점선 --)
- **이력 저장**: 응답 성능에 영향 없는 백그라운드 처리
- **로그 처리**: 모니터링/감사를 위한 로그 수집
---
## 오류 처리 전략
### 인증/인가 오류
- **401 Unauthorized**: JWT 토큰 만료/유효하지 않음
- **403 Forbidden**: 서비스 접근 권한 없음
- **계정 잠금**: 5회 로그인 실패 시 30분 잠금
### 외부 연동 오류
- **Circuit Breaker 동작**: KOS 시스템 장애 시 차단
- **타임아웃 처리**: 3-5초 내 응답 없을 시 오류 처리
- **오류 메시지**: 사용자 친화적 메시지 제공
### 시스템 오류
- **캐시 장애**: DB 조회로 폴백
- **DB 장애**: 적절한 오류 메시지 반환
- **서비스 장애**: API Gateway에서 헬스체크 및 라우팅 제어
---
## 성능 최적화
### 캐시 전략
- **Cache Hit**: 캐시된 데이터로 즉시 응답 (< 50ms)
- **Cache Miss**: 원본 조회 후 캐싱 (< 3초)
- **캐시 적중률**: 목표 85% 이상
### 응답 시간 목표
- **인증 처리**: < 200ms
- **요금 조회**: < 1초 (캐시 히트 시 < 200ms)
- **상품 변경**: < 3초 (KOS 연동 포함)
---
## 품질 검증
### PlantUML 문법 검사
-**사용자인증플로우.puml**: 문법 검사 통과
-**요금조회플로우.puml**: 문법 검사 통과
-**상품변경플로우.puml**: 문법 검사 통과
### 설계 품질
-**유저스토리 매핑**: 10개 스토리 100% 반영
-**논리아키텍처 일치**: 모든 참여자 매칭
-**UI/UX 플로우 반영**: 8개 화면 플로우 일치
-**기술 패턴 적용**: 3개 클라우드 패턴 완전 적용
---
## 팀 검토 결과
### 김기획(기획자)
"비즈니스 요구사항이 정확히 반영되었고, 사용자 시나리오가 완벽하게 구현되었습니다."
### 박화면(프론트)
"UI/UX 설계서의 사용자 플로우와 완벽하게 일치하며, 프론트엔드 구현에 필요한 모든 API 호출이 명시되었습니다."
### 최운영(데옵스)
"인프라 컴포넌트와의 상호작용이 잘 설계되었고, 운영 관점에서 모니터링 포인트가 명확합니다."
### 정테스트(QA매니저)
"오류 처리와 예외 상황이 체계적으로 설계되어, 테스트 시나리오 작성에 충분한 정보가 제공됩니다."
---
**작성자**: 이개발(백엔더)
**작성일**: 2025-01-08
**검토자**: 김기획(기획자), 박화면(프론트), 최운영(데옵스), 정테스트(QA매니저)
Binary file not shown.

After

Width:  |  Height:  |  Size: 363 KiB

@@ -0,0 +1,192 @@
@startuml 사용자인증플로우
!theme mono
title 사용자 인증 플로우 - 외부 시퀀스
actor "MVNO 고객" as User
participant "Frontend\n(React SPA)" as Frontend
participant "API Gateway" as APIGateway
participant "Auth Service" as AuthService
participant "Redis Cache" as Redis
participant "Auth DB\n(PostgreSQL)" as AuthDB
== 1. 로그인 요청 처리 (UFR-AUTH-010) ==
User -> Frontend: ID/Password 입력
note right of User
SCR-001: 로그인 화면
- ID, Password 입력
- 자동 로그인 옵션
end note
Frontend -> Frontend: 입력값 유효성 검사
Frontend -> APIGateway: POST /auth/login\n{userId, password, autoLogin}
APIGateway -> APIGateway: 요청 라우팅 및 기본 검증
APIGateway -> AuthService: POST /login\n{userId, password, autoLogin}
AuthService -> AuthService: 로그인 시도 횟수 확인
AuthService -> AuthDB: SELECT user_info\nWHERE user_id = ?
alt 계정이 5회 연속 실패로 잠긴 경우
AuthDB --> AuthService: 계정 잠금 상태 반환
AuthService --> APIGateway: 401 Unauthorized\n"30분간 계정 잠금"
APIGateway --> Frontend: 401 Error Response
Frontend --> User: "계정이 잠금되었습니다.\n30분 후 다시 시도해주세요."
else 정상 계정인 경우
AuthDB --> AuthService: 사용자 정보 반환
AuthService -> AuthService: 비밀번호 검증
alt 인증 실패
AuthService -> AuthDB: UPDATE login_attempt_count\nSET attempt_count = attempt_count + 1
AuthDB --> AuthService: 업데이트 완료
alt 5회째 실패
AuthService -> AuthDB: UPDATE user_status\nSET locked_until = NOW() + INTERVAL 30 MINUTE
AuthService --> APIGateway: 401 Unauthorized\n"5회 실패로 계정 잠금"
APIGateway --> Frontend: 401 Error Response
Frontend --> User: "5회 연속 실패하여\n30분간 계정이 잠금되었습니다."
else 1~4회 실패
AuthService --> APIGateway: 401 Unauthorized\n"ID 또는 비밀번호를 확인해주세요"
APIGateway --> Frontend: 401 Error Response
Frontend --> User: "ID 또는 비밀번호를 확인해주세요"
end
else 인증 성공
AuthService -> AuthDB: UPDATE login_attempt_count\nSET attempt_count = 0
AuthDB --> AuthService: 초기화 완료
== 2. 세션 생성 및 토큰 발급 ==
AuthService -> AuthService: JWT Access Token 생성\n(만료: 30분)
AuthService -> AuthService: JWT Refresh Token 생성\n(만료: 24시간)
AuthService -> Redis: SETEX user_session:{userId}\n{sessionData} TTL=1800
note right of Redis
Cache-Aside 패턴
- 세션 데이터 캐싱
- TTL: 30분
- 자동 로그인 시: TTL=24시간
end note
Redis --> AuthService: 세션 저장 완료
AuthService -> AuthDB: INSERT INTO login_history\n(user_id, login_time, ip_address)
AuthDB --> AuthService: 로그인 이력 저장 완료
AuthService --> APIGateway: 200 OK\n{accessToken, refreshToken, userInfo}
APIGateway --> Frontend: 200 OK Response
Frontend -> Frontend: 토큰 로컬 저장\n(localStorage or sessionStorage)
Frontend --> User: 메인 화면으로 이동
end
end
== 3. 메인 화면 권한 확인 (UFR-AUTH-020) ==
User -> Frontend: 메인 화면 접근
note right of User
SCR-002: 메인 화면
- 사용자 정보 표시
- 서비스 메뉴 권한별 표시
end note
Frontend -> APIGateway: GET /auth/user-info\nAuthorization: Bearer {accessToken}
APIGateway -> APIGateway: JWT 토큰 검증
alt 토큰 유효하지 않음
APIGateway --> Frontend: 401 Unauthorized
Frontend -> Frontend: 로그인 페이지로 리다이렉트
Frontend --> User: 로그인 페이지 표시
else 토큰 유효함
APIGateway -> AuthService: GET /user-info\n{decodedTokenData}
AuthService -> Redis: GET user_session:{userId}
alt 세션이 Redis에 존재
Redis --> AuthService: 세션 데이터 반환
note right of Redis
캐시 히트
- 빠른 응답 (< 50ms)
- DB 부하 감소
end note
else 세션이 Redis에 없음 (캐시 미스)
Redis --> AuthService: null
AuthService -> AuthDB: SELECT user_info, permissions\nWHERE user_id = ?
AuthDB --> AuthService: 사용자 정보 및 권한 반환
AuthService -> Redis: SETEX user_session:{userId}\n{userData} TTL=1800
Redis --> AuthService: 세션 재생성 완료
end
AuthService --> APIGateway: 200 OK\n{userInfo, permissions}
APIGateway --> Frontend: 200 OK Response
Frontend -> Frontend: 권한 기반 메뉴 렌더링
Frontend --> User: 메인 화면 표시\n(권한별 메뉴)
end
== 4. 서비스별 접근 권한 검증 ==
User -> Frontend: 요금조회/상품변경 메뉴 클릭
Frontend -> APIGateway: GET /auth/check-permission/{serviceType}\nAuthorization: Bearer {accessToken}
APIGateway -> APIGateway: JWT 토큰 검증
APIGateway -> AuthService: GET /check-permission\n{userId, serviceType}
AuthService -> Redis: GET user_session:{userId}
Redis --> AuthService: 세션 데이터 반환 (권한 포함)
AuthService -> AuthService: 서비스별 권한 확인\n- BILL_INQUIRY\n- PRODUCT_CHANGE
alt 접근 권한 있음
AuthService --> APIGateway: 200 OK\n{permission: granted}
APIGateway --> Frontend: 200 OK Response
Frontend --> User: 해당 서비스 화면 표시
else 접근 권한 없음
AuthService --> APIGateway: 403 Forbidden\n{permission: denied}
APIGateway --> Frontend: 403 Error Response
Frontend --> User: "서비스 이용 권한이 없습니다"
end
== 5. 토큰 갱신 처리 ==
note over Frontend, AuthService
Access Token 만료 시 (30분)
자동으로 토큰 갱신 처리
end note
Frontend -> APIGateway: POST /auth/refresh\n{refreshToken}
APIGateway -> AuthService: POST /refresh-token\n{refreshToken}
AuthService -> AuthService: Refresh Token 검증
alt Refresh Token 유효함
AuthService -> Redis: GET user_session:{userId}
Redis --> AuthService: 세션 확인
AuthService -> AuthService: 새로운 Access Token 생성
AuthService -> Redis: SETEX user_session:{userId}\n{updatedSessionData} TTL=1800
AuthService --> APIGateway: 200 OK\n{newAccessToken}
APIGateway --> Frontend: 200 OK Response
Frontend -> Frontend: 새 토큰으로 업데이트
else Refresh Token 무효함
AuthService --> APIGateway: 401 Unauthorized
APIGateway --> Frontend: 401 Error Response
Frontend -> Frontend: 로그인 페이지로 리다이렉트
Frontend --> User: 재로그인 필요
end
== 6. 로그아웃 처리 ==
User -> Frontend: 로그아웃 버튼 클릭
Frontend -> APIGateway: POST /auth/logout\nAuthorization: Bearer {accessToken}
APIGateway -> AuthService: POST /logout\n{userId}
AuthService -> Redis: DEL user_session:{userId}
Redis --> AuthService: 세션 삭제 완료
AuthService -> AuthDB: INSERT INTO logout_history\n(user_id, logout_time)
AuthDB --> AuthService: 로그아웃 이력 저장 완료
AuthService --> APIGateway: 200 OK
APIGateway --> Frontend: 200 OK Response
Frontend -> Frontend: 로컬 토큰 삭제
Frontend --> User: 로그인 페이지로 이동
@enduml
@@ -0,0 +1,127 @@
@startuml
!theme mono
title 통신요금 관리 서비스 - 상품변경 플로우 (외부 시퀀스)
actor "MVNO 고객" as User
participant "Frontend\n(MVNO Web)" as Frontend
participant "API Gateway" as Gateway
participant "Auth Service" as Auth
participant "Product-Change\nService" as ProductService
participant "Redis Cache" as Redis
participant "Product DB" as ProductDB
participant "KOS-Order\nSystem" as KOS
participant "MVNO AP\nServer" as MVNO
== 1. 상품변경 메뉴 접근 (UFR-PROD-010) ==
User -> Frontend : 상품변경 메뉴 요청
Frontend -> Gateway : GET /product/menu
Gateway -> Auth : 권한 확인 요청
Auth -> Gateway : 권한 확인 응답
note right : UFR-AUTH-020\n서비스 접근권한 확인
alt 권한 있음
Gateway -> ProductService : GET /menu
ProductService -> Redis : 고객정보 조회 (Cache-Aside)
alt 캐시 Miss
ProductService -> KOS : 고객정보 조회
note right : Circuit Breaker 적용\n타임아웃: 3초
KOS -> ProductService : 고객정보 응답
ProductService -> Redis : 고객정보 캐싱 (TTL: 4시간)
end
Redis -> ProductService : 고객정보 반환
ProductService -> Gateway : 메뉴 데이터 응답
Gateway -> Frontend : 메뉴 화면 데이터
Frontend -> User : 상품변경 메뉴 표시
else 권한 없음
Gateway -> Frontend : 권한 오류 응답
Frontend -> User : "서비스 이용 권한이 없습니다"
end
== 2. 상품변경 화면 (UFR-PROD-020) ==
User -> Frontend : 상품변경 화면 요청
Frontend -> Gateway : GET /product/change
Gateway -> ProductService : GET /change
ProductService -> Redis : 상품정보 조회 (Cache-Aside)
alt 캐시 Miss
ProductService -> KOS : 상품정보 조회
note right : Circuit Breaker 적용
KOS -> ProductService : 상품정보 응답
ProductService -> Redis : 상품정보 캐싱 (TTL: 24시간)
end
Redis -> ProductService : 상품정보 반환
ProductService -> Gateway : 상품목록 데이터
Gateway -> Frontend : 변경가능 상품목록
Frontend -> User : 상품변경 화면 표시
== 3. 상품변경 요청 및 사전체크 (UFR-PROD-030) ==
User -> Frontend : 상품 선택 및 변경 요청
Frontend -> Gateway : POST /product/request
Gateway -> ProductService : 상품변경 요청\n{회선번호, 변경전상품코드, 변경후상품코드}
ProductService -> ProductService : 사전체크 수행
note right : 1. 판매중인 상품 확인\n2. 사업자 일치 확인\n3. 회선 사용상태 확인
alt 사전체크 성공
ProductService -> Gateway : 사전체크 성공
Gateway -> Frontend : 변경 요청 접수
Frontend -> User : "상품 변경이 진행되었다"
else 사전체크 실패
ProductService -> Gateway : 사전체크 실패\n{실패사유}
Gateway -> Frontend : 체크 실패 응답
Frontend -> User : "상품 사전 체크에 실패하였다"
note left : 실패사유별 안내메시지 표시
end
== 4. KOS 상품변경 처리 (UFR-PROD-040) ==
alt 사전체크 통과한 경우
ProductService -> KOS : 상품변경 처리 요청
note right : Circuit Breaker 적용\n타임아웃: 5초
alt KOS 상품변경 성공
KOS -> ProductService : 변경 완료 응답\n{변경후상품코드, 처리결과:정상}
ProductService -> MVNO : 변경완료 결과 전송
note right : 성공 메시지:\n"상품 변경이 완료되었다"
ProductService -> ProductDB : 변경 이력 저장 (비동기)
note left : 변경 이력:\n- 회선번호, 변경전/후상품코드\n- 생성일시, 처리결과
ProductService -> Redis : 고객 상품정보 캐시 무효화
ProductService -> Gateway : 변경 성공 응답
Gateway -> Frontend : 처리 완료 데이터
Frontend -> User : 변경 완료 화면
else KOS 상품변경 실패
KOS -> ProductService : 변경 실패 응답\n{처리결과:실패, 실패메시지}
ProductService -> MVNO : 변경실패 결과 전송
note right : 실패 메시지:\n"상품 변경에 실패하여\n실패 사유에 따라 문구를 화면에 출력한다"
ProductService -> ProductDB : 실패 이력 저장 (비동기)
ProductService -> Gateway : 변경 실패 응답
Gateway -> Frontend : 처리 실패 데이터
Frontend -> User : 변경 실패 화면
end
else Circuit Breaker Open (KOS 장애)
ProductService -> MVNO : 시스템 장애 안내
ProductService -> Gateway : 시스템 오류 응답
Gateway -> Frontend : 시스템 오류
Frontend -> User : "시스템 일시 장애, 잠시 후 재시도"
end
== 5. 처리결과 화면 (UFR-PROD-040) ==
User -> Frontend : 처리결과 확인
note right : SCR-008: 처리결과 화면\n- 성공/실패 상태 표시\n- 처리내용 또는 실패사유\n- 후속 액션 버튼
@enduml
@@ -0,0 +1,134 @@
@startuml
!theme mono
title 통신요금 관리 서비스 - 요금조회 플로우
actor "MVNO 고객" as Client
participant "MVNO Frontend" as Frontend
participant "API Gateway" as Gateway
participant "Auth Service" as Auth
participant "Bill-Inquiry Service" as BillService
participant "Redis Cache" as Cache
participant "Bill DB" as BillDB
participant "KOS-Order" as KOS
participant "MVNO AP Server" as MVNOServer
== 요금조회 메뉴 접근 (UFR-BILL-010) ==
Client -> Frontend: 요금조회 메뉴 요청
activate Frontend
Frontend -> Gateway: GET /api/bill/menu
activate Gateway
Gateway -> Auth: JWT 토큰 검증 및 권한 확인
activate Auth
Auth --> Gateway: 권한 확인 완료
deactivate Auth
Gateway -> BillService: 요금조회 메뉴 요청
activate BillService
BillService -> Cache: 고객 정보 캐시 조회
activate Cache
Cache --> BillService: 고객 정보 반환 (회선번호)
deactivate Cache
BillService --> Gateway: 요금조회 메뉴 데이터
deactivate BillService
Gateway --> Frontend: 요금조회 메뉴 응답
deactivate Gateway
Frontend --> Client: 요금조회 메뉴 화면 표시\n(회선번호, 조회월 선택 옵션)
deactivate Frontend
== 요금조회 신청 (UFR-BILL-020) ==
Client -> Frontend: 조회월 선택 후 조회 신청\n(당월 또는 특정월)
activate Frontend
Frontend -> Gateway: POST /api/bill/inquiry\n{lineNumber, inquiryMonth}
activate Gateway
Gateway -> Auth: JWT 토큰 검증
activate Auth
Auth --> Gateway: 인증 확인
deactivate Auth
Gateway -> BillService: 요금조회 요청
activate BillService
== Cache-Aside 패턴 적용 ==
BillService -> Cache: 조회 결과 캐시 확인\nKey: "bill:lineNumber:month"
activate Cache
alt 캐시 Hit (1시간 TTL 내)
Cache --> BillService: 캐시된 요금 정보 반환
deactivate Cache
note right: 성능 최적화\nKOS 호출 없이 즉시 응답
else 캐시 Miss
Cache --> BillService: 캐시 데이터 없음
deactivate Cache
== Circuit Breaker 패턴 적용 (UFR-BILL-030) ==
BillService -> KOS: 요금조회 API 호출\n{회선번호, 조회월}
activate KOS
alt Circuit Breaker - 정상 상태
KOS --> BillService: 요금 정보 응답\n{상품명, 청구월, 요금, 할인정보,\n사용량, 예상해지비용, 단말기할부금,\n청구/납부정보}
deactivate KOS
BillService -> Cache: 조회 결과 캐싱 (TTL: 1시간)
activate Cache
Cache --> BillService: 캐싱 완료
deactivate Cache
else Circuit Breaker - 장애 상태
KOS --> BillService: 연동 실패 (타임아웃/오류)
deactivate KOS
BillService --> Gateway: 서비스 장애 응답\n"일시적으로 서비스 이용이 어렵습니다"
Gateway --> Frontend: 오류 응답
Frontend --> Client: 오류 메시지 표시
note right: Circuit Breaker로\n서비스 안정성 확보
[-> BillService: 장애 로그 기록
end
end
== 요금조회 결과 전송 (UFR-BILL-040) ==
BillService -> MVNOServer: 조회 결과 전송\n(상품명, 청구월, 요금 등 전체 정보)
activate MVNOServer
MVNOServer --> BillService: 전송 완료 확인
deactivate MVNOServer
BillService -> BillDB: 요금 조회 이력 저장 (비동기)
activate BillDB
note right: 비동기 처리로\n응답 성능에 영향 없음
BillDB --> BillService: 이력 저장 완료
deactivate BillDB
BillService --> Gateway: 요금조회 결과
deactivate BillService
Gateway --> Frontend: 조회 결과 응답
deactivate Gateway
Frontend --> Client: 요금조회 결과 화면 표시\n{상품명, 청구월, 요금, 할인정보,\n사용량, 예상해지비용, 단말기할부금,\n청구/납부정보}
deactivate Frontend
== 오류 처리 흐름 ==
note over Frontend, BillService
각 단계별 오류 처리
- 권한 없음: 서비스 이용 권한이 없습니다
- 메뉴 로딩 실패: 요금 조회 메뉴 로딩에 실패하였습니다
- 조회 신청 실패: 요금 조회 신청에 실패하였습니다
- KOS 연동 실패: Circuit Breaker로 장애 격리
end note
@enduml