!theme mono

skinparam componentStyle rectangle
skinparam componentFontSize 12
skinparam arrowFontSize 11
skinparam arrowThickness 2

title HealthSync 역설계 - Azure Cloud 물리 아키텍처

' 외부 사용자 및 시스템
package "External Systems" as external #lightgray {
    [모바일 사용자] as MobileUser
    [Google OAuth] as GoogleOAuth
    [Claude AI API] as ClaudeAPI
    [건강보험공단\n데이터] as NhisData
}

' Azure Front Door & CDN
package "Global Network" as global #lightblue {
    [Azure Front Door] as FrontDoor
    [Azure CDN] as CDN
}

' Azure Application Gateway & Load Balancer
package "Load Balancing" as lb #lightyellow {
    [Application Gateway\n(WAF 포함)] as AppGateway
    [Azure Load Balancer] as LoadBalancer
}

' AKS Cluster
package "Azure Kubernetes Service (AKS)" as aks #lightgreen {
    package "Ingress Controller" as ingress {
        [NGINX Ingress\nController] as IngressController
    }
    
    package "Application Pods" as pods {
        [Gateway Pod] as GatewayPod
        [User Service Pod] as UserPod
        [Health Service Pod] as HealthPod
        [Goal Service Pod] as GoalPod
        [Intelligence Service Pod] as IntellPod
        [Batch Service Pod] as BatchPod
    }
    
    package "Supporting Services" as support {
        [Istio Service Mesh] as ServiceMesh
        [Prometheus\n& Grafana] as Monitoring
        [FluentD] as Logging
    }
}

' Azure Database Services
package "Database Services" as database #lightpink {
    [Azure Database\nfor PostgreSQL\n(Flexible Server)] as PostgreSQL
    [Azure Cache\nfor Redis\n(Premium)] as Redis
    [Azure Blob Storage\n(Hot Tier)] as BlobStorage
}

' Azure Messaging & Events
package "Messaging & Events" as messaging #lightsalmon {
    [Azure Service Bus\n(Standard)] as ServiceBus
    [Azure Event Hub\n(Standard)] as EventHub
}

' Azure Security & Identity
package "Security & Identity" as security #orange {
    [Azure Key Vault] as KeyVault
    [Azure Active Directory\nB2C] as AzureAD
    [Azure Application\nInsights] as AppInsights
}

' Azure DevOps & CI/CD
package "DevOps & CI/CD" as devops #lightsteelblue {
    [Azure DevOps\nPipelines] as AzureDevOps
    [Azure Container\nRegistry (ACR)] as ACR
    [GitHub Repository] as GitHub
    [Azure Monitor] as AzureMonitor
}

' Azure Backup & Recovery
package "Backup & DR" as backup #thistle {
    [Azure Backup] as AzureBackup
    [Azure Site Recovery] as SiteRecovery
    [Geo-Redundant\nStorage] as GeoStorage
}

' === 외부 접근 및 CDN (1-3) ===
MobileUser -[#blue,thickness=3]-> FrontDoor : "1. 모바일 앱 접근"
FrontDoor -[#blue,thickness=2]-> CDN : "2. 정적 자원 캐싱"
CDN -[#blue,thickness=2]-> AppGateway : "3. 동적 요청 라우팅"

' === 로드밸런싱 및 보안 (4-5) ===
AppGateway -[#green,thickness=2]-> LoadBalancer : "4. WAF 보안 필터링"
LoadBalancer -[#green,thickness=2]-> IngressController : "5. AKS 클러스터 진입"

' === AKS 내부 라우팅 (6-8) ===
IngressController -[#purple,thickness=2]-> GatewayPod : "6. API Gateway 라우팅"
GatewayPod -[#purple,thickness=2]-> ServiceMesh : "7. Service Mesh 통신"
ServiceMesh -[#purple,thickness=2]-> UserPod : "8a. User Service 호출"
ServiceMesh -[#purple,thickness=2]-> HealthPod : "8b. Health Service 호출"
ServiceMesh -[#purple,thickness=2]-> GoalPod : "8c. Goal Service 호출"
ServiceMesh -[#purple,thickness=2]-> IntellPod : "8d. Intelligence Service 호출"

' === 데이터베이스 연결 (9-11) ===
UserPod -[#red,thickness=2]-> PostgreSQL : "9a. 사용자 데이터 처리"
HealthPod -[#red,thickness=2]-> PostgreSQL : "9b. 건강검진 데이터 처리"
GoalPod -[#red,thickness=2]-> PostgreSQL : "9c. 목표/미션 데이터 처리"
IntellPod -[#red,thickness=2]-> PostgreSQL : "9d. AI 분석/채팅 데이터 처리"

' === 캐싱 및 스토리지 (10-11) ===
HealthPod -[#orange,thickness=2]-> Redis : "10a. 건강검진 결과 캐싱"
IntellPod -[#orange,thickness=2]-> Redis : "10b. AI 응답 캐싱"
GoalPod -[#orange,thickness=2]-> Redis : "10c. 활성 미션 캐싱"
HealthPod -[#brown,thickness=2]-> BlobStorage : "11. 건강검진 파일 저장"

' === 메시징 및 이벤트 (12-13) ===
UserPod -[#magenta,thickness=2]-> ServiceBus : "12a. 사용자 이벤트 발행"
HealthPod -[#magenta,thickness=2]-> ServiceBus : "12b. 건강데이터 이벤트 발행"
GoalPod -[#magenta,thickness=2]-> ServiceBus : "12c. 목표달성 이벤트 발행"
IntellPod -[#magenta,thickness=2]-> EventHub : "13. 대량 이벤트 스트리밍"

' === 외부 API 연동 (14-16) ===
UserPod -[#navy,thickness=2]-> GoogleOAuth : "14. Google SSO 인증"
IntellPod -[#navy,thickness=2]-> ClaudeAPI : "15. AI 분석/채팅 요청"
HealthPod -[#darkgreen,thickness=2]-> NhisData : "16. 건강보험공단 데이터 연동"

' === 배치 처리 (17) ===
BatchPod -[#darkred,thickness=2]-> ServiceBus : "17a. 배치 이벤트 구독"
BatchPod -[#darkred,thickness=2]-> IntellPod : "17b. 주기적 AI 알림 요청"
BatchPod -[#darkred,thickness=2]-> ClaudeAPI : "17c. 배치 AI 메시지 생성"

' === 보안 및 키 관리 (18-20) ===
GatewayPod -[#darkgray,thickness=1,dotted]-> KeyVault : "18a. Gateway 설정"
UserPod -[#darkgray,thickness=1,dotted]-> KeyVault : "18b. JWT Secret"
HealthPod -[#darkgray,thickness=1,dotted]-> KeyVault : "18c. DB 연결 정보"
IntellPod -[#darkgray,thickness=1,dotted]-> KeyVault : "18d. Claude API Key"
BatchPod -[#darkgray,thickness=1,dotted]-> KeyVault : "18e. 스케줄러 설정"

' === 모니터링 및 로깅 (19-20) ===
Monitoring -[#cyan,thickness=1,dashed]-> AppInsights : "19. 메트릭 수집"
Logging -[#cyan,thickness=1,dashed]-> AzureMonitor : "20. 로그 집계"

' === CI/CD 파이프라인 (21-25) ===
GitHub -[#teal,thickness=2]-> AzureDevOps : "21. 코드 푸시 트리거"
AzureDevOps -[#teal,thickness=2]-> ACR : "22. 컨테이너 빌드 & 푸시"
AzureDevOps -[#teal,thickness=2]-> GitHub : "23. 배포 YAML 업데이트"
GitHub -[#teal,thickness=2]-> aks : "24. GitOps 배포 동기화"
AzureDevOps -[#teal,thickness=2]-> AzureMonitor : "25. 배포 모니터링"

' === 백업 및 재해복구 (26-28) ===
PostgreSQL -[#purple,thickness=1,dashed]-> AzureBackup : "26. 데이터베이스 백업"
BlobStorage -[#purple,thickness=1,dashed]-> GeoStorage : "27. 파일 지역 복제"
aks -[#purple,thickness=1,dashed]-> SiteRecovery : "28. 클러스터 재해복구"

' === 주요 특징 및 처리 흐름 설명 ===
note top of FrontDoor
  **글로벌 진입점**
  • 전 세계 사용자 접근 최적화
  • DDoS 보호 및 SSL 터미네이션
  • 지연시간 최소화
end note

note top of AKS
  **컨테이너 오케스트레이션**
  • 마이크로서비스 자동 스케일링
  • Service Mesh로 서비스 간 통신
  • 무중단 배포 및 롤백
  • 리소스 효율적 관리
end note

note top of PostgreSQL
  **통합 데이터베이스**
  • 단일 PostgreSQL로 모든 서비스 데이터 통합
  • Flexible Server로 성능 최적화
  • 자동 백업 및 포인트-인-타임 복구
  • Read Replica로 읽기 성능 향상
end note

note top of Redis
  **고성능 캐싱**
  • Premium 티어로 99.9% 가용성
  • 클러스터링으로 확장성 확보
  • 영구 저장으로 데이터 보호
  • 지역 복제로 재해 대비
end note

note top of ServiceBus
  **신뢰성 있는 메시징**
  • 이벤트 기반 아키텍처 구현
  • 메시지 순서 보장
  • Dead Letter Queue로 실패 처리
  • Auto-scaling으로 부하 대응
end note

note top of KeyVault
  **중앙 보안 관리**
  • 모든 시크릿 중앙 관리
  • 하드웨어 보안 모듈 (HSM)
  • 액세스 정책 세밀 제어
  • 감사 로그 자동 기록
end note

note bottom of AzureDevOps
  **완전 자동화 CI/CD**
  • 코드 커밋 → 자동 빌드
  • 컨테이너 이미지 스캔
  • 단계별 배포 승인
  • Blue-Green 배포 지원
  • 자동 롤백 기능
end note

note bottom of AzureMonitor
  **통합 모니터링**
  • 실시간 성능 메트릭
  • 사용자 정의 대시보드
  • 자동 알림 및 경고
  • 로그 분석 및 검색
  • 비용 최적화 인사이트
end note

note bottom of external
  **외부 시스템 연동**
  • Google OAuth: 안전한 사용자 인증
  • Claude AI: 고품질 AI 분석
  • 건강보험공단: 신뢰성 있는 건강 데이터
  • Circuit Breaker 패턴으로 안정성 확보
end note