본문으로 건너뛰기

사용자 프로필 서비스 (User Profile)

개요

사용자 프로필 서비스는 회원의 개인정보, 배송지 주소, 선호 설정을 관리합니다. 회원 등급 시스템(브론즈/실버/골드/플래티넘)을 통해 차별화된 혜택을 제공합니다.

항목
언어Python 3.11
프레임워크FastAPI
데이터베이스DocumentDB (MongoDB 호환)
네임스페이스mall-services
포트8000
헬스체크GET /health

아키텍처

API 엔드포인트

프로필 API

메서드경로설명
GET/api/v1/profiles/{user_id}프로필 조회
PUT/api/v1/profiles/{user_id}프로필 수정
GET/api/v1/profiles/{user_id}/addresses배송지 목록 조회
POST/api/v1/profiles/{user_id}/addresses배송지 추가
PUT/api/v1/profiles/{user_id}/addresses/{address_id}배송지 수정
DELETE/api/v1/profiles/{user_id}/addresses/{address_id}배송지 삭제

요청/응답 예시

프로필 조회

요청:

GET /api/v1/profiles/user_001

응답:

{
"user_id": "user_001",
"phone": "010-1234-5678",
"date_of_birth": "1990-05-15",
"avatar_url": "https://cdn.example.com/avatars/user_001.jpg",
"preferences": {
"language": "ko",
"currency": "KRW",
"categories": ["electronics", "fashion"],
"tier": "gold",
"notification_email": true,
"notification_push": true
},
"addresses": [
{
"id": "addr_001",
"label": "집",
"street": "강남대로 123",
"city": "서울",
"state": "서울특별시",
"postal_code": "06000",
"country": "KR",
"is_default": true
}
],
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-15T10:00:00Z"
}

프로필 수정

요청:

PUT /api/v1/profiles/user_001
Content-Type: application/json

{
"phone": "010-9876-5432",
"preferences": {
"language": "ko",
"currency": "KRW",
"categories": ["electronics", "sports"],
"notification_push": false
}
}

응답:

{
"user_id": "user_001",
"phone": "010-9876-5432",
"date_of_birth": "1990-05-15",
"avatar_url": "https://cdn.example.com/avatars/user_001.jpg",
"preferences": {
"language": "ko",
"currency": "KRW",
"categories": ["electronics", "sports"],
"tier": "gold",
"notification_email": true,
"notification_push": false
},
"addresses": [],
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-15T11:00:00Z"
}

배송지 추가

요청:

POST /api/v1/profiles/user_001/addresses
Content-Type: application/json

{
"label": "회사",
"street": "테헤란로 456",
"city": "서울",
"state": "서울특별시",
"postal_code": "06100",
"country": "KR",
"is_default": false
}

응답 (201 Created):

{
"id": "addr_002",
"label": "회사",
"street": "테헤란로 456",
"city": "서울",
"state": "서울특별시",
"postal_code": "06100",
"country": "KR",
"is_default": false
}

데이터 모델

UserProfile

class UserProfile(BaseModel):
user_id: str
phone: Optional[str] = None
date_of_birth: Optional[str] = None
avatar_url: Optional[str] = None
preferences: dict = {}
addresses: list[Address] = []
created_at: datetime
updated_at: datetime

Address

class Address(BaseModel):
id: str
label: str # 예: "집", "회사", "부모님 댁"
street: str
city: str
state: str
postal_code: str
country: str = "KR"
is_default: bool = False

회원 등급 시스템

등급조건혜택
브론즈 (Bronze)기본기본 적립률 1%
실버 (Silver)누적 구매 50만원적립률 2%, 무료배송 쿠폰
골드 (Gold)누적 구매 200만원적립률 3%, 우선 배송
플래티넘 (Platinum)누적 구매 500만원적립률 5%, VIP 전용 상품

선호 설정 (Preferences)

{
"language": "ko", // 언어: ko, en, ja, zh
"currency": "KRW", // 통화: KRW, USD, JPY
"categories": ["electronics", "fashion"], // 관심 카테고리
"tier": "gold", // 회원 등급
"notification_email": true, // 이메일 알림
"notification_push": true, // 푸시 알림
"notification_sms": false // SMS 알림
}

이벤트 (Kafka)

발행 토픽

토픽이벤트설명
users.profile-updated프로필 수정프로필 정보 변경 시 발행
users.address-added배송지 추가새 배송지 등록 시 발행
users.tier-changed등급 변경회원 등급 변경 시 발행

구독 토픽

토픽이벤트설명
orders.completed주문 완료등급 산정을 위한 구매 금액 집계

환경 변수

변수명설명기본값
SERVICE_NAME서비스 이름user-profile
PORT서비스 포트8080
AWS_REGIONAWS 리전us-east-1
REGION_ROLE리전 역할 (PRIMARY/SECONDARY)PRIMARY
DB_HOST데이터베이스 호스트localhost
DB_PORT데이터베이스 포트27017
DB_NAME데이터베이스 이름user_profiles
DB_USER데이터베이스 사용자mall
DB_PASSWORD데이터베이스 비밀번호-
DOCUMENTDB_HOSTDocumentDB 호스트localhost
DOCUMENTDB_PORTDocumentDB 포트27017
KAFKA_BROKERSKafka 브로커 주소localhost:9092
LOG_LEVEL로그 레벨info

서비스 의존성

의존하는 서비스

  • DocumentDB: 프로필/주소 데이터 저장

의존받는 서비스

  • Auth Service: 로그인 시 프로필 정보 조회
  • Order Service: 주문 시 배송지 선택
  • Shipping Service: 배송 주소 확인
  • Notification Service: 알림 채널 선호도 확인