AI 기반 웨딩 드레스 추천 서비스
OpenAI GPT-4를 활용하여 신부의 체형에 맞는 최적의 드레스를 추천합니다.
┌──────────────┐
│ Client │ (HTTP)
└──────┬───────┘
│
↓
┌─────────────────────────────────────┐
│ API Layer (FastAPI) │
│ └─ Routes (recommend, stats) │
└──────┬──────────────────────────────┘
│
↓
┌─────────────────────────────────────┐
│ Services Layer │
│ ├─ Recommender (AI Logic) │
│ └─ Schemas (Pydantic) │
└──────┬──────────────────────────────┘
│
┌──────┴──────┬──────────────┐
│ Database │ Config │
│ Layer │ Layer │
├─────────────┼──────────────┤
│ • Session │ • Settings │
│ • Models │ • Redis │
│ • Repos │ │
└─────────────┴──────────────┘
│
↓
┌──────────────┐ ┌──────────────┐
│ MySQL │ │ Redis │
│ (L2 Cache) │ │ (L1 Cache) │
└──────────────┘ └──────────────┘
API Layer (src/api/)
- FastAPI 기반 REST API
- 요청 검증 및 응답 포맷팅
- Routes: recommend, stats
Services Layer (src/services/)
- 비즈니스 로직 (AI 추천 엔진)
- Pydantic 스키마 정의
- 도메인 모델
Database Layer (src/database/)
- SQLAlchemy 세션 관리
- DB 모델 정의
- Repository 패턴 (데이터 접근)
Config Layer (src/config/)
- 환경 설정 관리
- Redis 클라이언트
wedding-dress-api/
├── src/
│ ├── api/ # FastAPI REST API
│ │ ├── main.py # FastAPI app
│ │ └── routes/ # API routes
│ │ ├── recommend.py # 드레스 추천 엔드포인트
│ │ └── stats.py # 통계 엔드포인트
│ │
│ ├── services/ # 비즈니스 로직
│ │ ├── schemas.py # Pydantic 스키마
│ │ └── recommender.py # AI 추천 엔진
│ │
│ ├── database/ # 데이터베이스
│ │ ├── session.py # DB 세션
│ │ ├── models.py # SQLAlchemy 모델
│ │ └── repositories/ # Repository 패턴
│ │ └── recommendation.py
│ │
│ └── config/ # 설정
│ ├── settings.py # 환경 설정
│ └── redis.py # Redis 클라이언트
│
├── scripts/ # 유틸리티
│ └── init.sql # DB 초기화 스크립트
│
├── Dockerfile # Docker 이미지
├── docker-compose.yaml # 로컬 개발 환경
├── requirements.txt # Python 의존성
└── README.md
- Python 3.11+
- Docker & Docker Compose
- OpenAI API Key
# 1. 환경 변수 설정
cp .env.example .env
# .env 파일에서 OPENAI_API_KEY와 MYSQL_PASSWORD 설정
# 2. 서비스 시작
docker-compose up -d
# 3. 로그 확인
docker-compose logs -f api
# 4. 테스트
curl http://localhost:18000/health드레스 추천 (기본 3개)
curl -X POST http://localhost:18000/recommend \
-H "Content-Type: application/json" \
-d '{
"arm_length": "보통",
"leg_length": "긴",
"neck_length": "보통",
"face_shape": "달걀"
}'추천 개수 변경 (1-5개)
# 1개만 추천받기
curl -X POST http://localhost:18000/recommend \
-H "Content-Type: application/json" \
-d '{
"arm_length": "보통",
"leg_length": "긴",
"neck_length": "보통",
"face_shape": "달걀",
"num_recommendations": 1
}'
# 5개 추천받기
curl -X POST http://localhost:18000/recommend \
-H "Content-Type: application/json" \
-d '{
"arm_length": "보통",
"leg_length": "긴",
"neck_length": "보통",
"face_shape": "달걀",
"num_recommendations": 5
}'응답 예시
{
"request_params": {
"arm_length": "보통",
"leg_length": "긴",
"neck_length": "보통",
"face_shape": "달걀"
},
"recommendations": [
{
"style_name": "A라인 드레스",
"description": "상체는 슬림하게, 하체는 풍성하게...",
"why_recommended": "긴 다리를 돋보이게 하며...",
"styling_tips": [
"하이힐을 신어 다리 라인을 더욱 강조",
"심플한 목걸이로 얼굴형을 살림"
]
}
],
"overall_advice": "달걀형 얼굴과 긴 다리를 가진 신부님께는...",
"cached": false,
"source": "ai_generated"
}| 메서드 | 경로 | 설명 |
|---|---|---|
| GET | /health |
상세 헬스 체크 |
| POST | /recommend |
드레스 추천 (메인) |
| 파라미터 | 옵션 | 조합 |
|---|---|---|
| arm_length | 짧은, 보통, 긴 | 3 |
| leg_length | 짧은, 보통, 긴 | 3 |
| neck_length | 짧은, 보통, 긴 | 3 |
| face_shape | 달걀, 넓은, 각진, 긴 | 4 |
| num_recommendations | 1, 2, 3, 4, 5 (기본값: 3) | 5 |
총 조합: 3 × 3 × 3 × 4 × 5 = 540가지
| 레벨 | 저장소 | 속도 | 용도 |
|---|---|---|---|
| L1 | Redis | ~1ms | 초고속 응답 |
| L2 | MySQL | ~10ms | 영구 저장 + 통계 |
플로우:
- Redis Hit → 즉시 반환 ✅
- Redis Miss → MySQL Hit → Redis 저장 → 반환
- MySQL Miss → AI 생성 → 양쪽 저장 → 반환