- DTO 필드명 통일 (프론트엔드 호환)
- totalParticipants → participants
- channelName → channel
- totalInvestment → totalCost
- 증감 데이터 필드 추가
- participantsDelta: 참여자 증감 (현재 0, TODO)
- targetRoi: 목표 ROI (EventStats에서 가져옴)
- EventStats 엔티티 스키마 변경
- targetRoi 컬럼 추가 (BigDecimal, default: 0)
- Service 로직 수정
- AnalyticsService: 필드명 변경 및 증감 데이터 적용
- ROICalculator: totalCost 필드명 변경
- UserAnalyticsService: 필드명 변경 및 증감 데이터 적용
- 검증 문서 추가
- frontend-backend-validation.md: 수정 내용 및 다음 단계 정리
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
주요 변경사항:
- EventStats 엔티티 storeId → userId 필드 변경
- EventStatsRepository 메소드명 변경 (findAllByStoreId → findAllByUserId)
- MVP 환경 1:1 관계 적용 (1 user = 1 store)
- EventCreatedConsumer에서 storeId → userId 매핑 처리
User 통합 분석 API 4개 신규 개발:
1. GET /api/v1/users/{userId}/analytics - 사용자 전체 성과 대시보드
2. GET /api/v1/users/{userId}/analytics/channels - 채널별 성과 분석
3. GET /api/v1/users/{userId}/analytics/roi - ROI 상세 분석
4. GET /api/v1/users/{userId}/analytics/timeline - 시간대별 참여 추이
기술 스택:
- Spring Boot 3.3.0, Java 21
- JPA/Hibernate, Redis 캐싱 (TTL 30분)
- Kafka Event-Driven 아키텍처
문서:
- test-backend.md: 백엔드 테스트 결과서 작성 완료
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
[문제]
- ParticipantRegistered 이벤트 처리 시 StaleObjectStateException 발생
- 100개의 이벤트가 동시에 발행되어 EventStats 동시 업데이트 충돌
- TransactionRequiredException 발생 (트랜잭션 컨텍스트 부재)
[해결]
1. 비관적 락(Pessimistic Lock) 적용
- EventStatsRepository에 findByEventIdWithLock 메서드 추가
- PESSIMISTIC_WRITE 락으로 읽는 순간부터 다른 트랜잭션 차단
2. 트랜잭션 추가
- 모든 Consumer 메서드에 @Transactional 어노테이션 추가
- EventCreatedConsumer, ParticipantRegisteredConsumer, DistributionCompletedConsumer
3. 이벤트 발행 속도 조절
- SampleDataLoader에서 10개마다 100ms 대기
- 동시성 충돌 빈도 감소
[수정 파일]
- EventStatsRepository.java: 비관적 락 메서드 추가
- ParticipantRegisteredConsumer.java: @Transactional 추가, 락 메서드 사용
- DistributionCompletedConsumer.java: @Transactional 추가, 락 메서드 사용
- EventCreatedConsumer.java: @Transactional 추가
- SampleDataLoader.java: 이벤트 발행 속도 조절
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
변경 사항:
1. EventStats에 totalViews 필드 추가 (모든 채널 노출 수 합계)
2. DistributionCompletedEvent에 expectedViews 필드 추가
3. DistributionCompletedConsumer 개선:
- ChannelStats.impressions에 expectedViews 저장
- updateTotalViews() 메서드로 전체 노출 수 집계
4. SampleDataLoader에 채널별 예상 노출 수 설정:
- 이벤트1: 총 20,000 (우리동네TV 5K, 지니TV 10K, 링고비즈 3K, SNS 2K)
- 이벤트2: 총 14,000
- 이벤트3: 총 6,000
설계 다이어그램과 일치:
- 채널별 예상 노출 수 저장
- 총 노출 수 실시간 집계
- 멱등성 및 캐시 무효화 유지
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- 다른 서비스 개발자들의 운영 토픽과 충돌 방지
- MVP용 샘플 토픽: sample.event.created, sample.participant.registered, sample.distribution.completed
- KafkaTopicConfig, SampleDataLoader, 3개 Consumer 모두 업데이트
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Analytics 5분 단위 배치 스케줄러 추가
- 초기 데이터 로딩 기능 구현 (서버 시작 30초 후)
- Redis 설정 업데이트 (외부 Redis 서버 연결)
- Redis 읽기 전용 오류 처리 추가
- IntelliJ 실행 프로파일 생성
- @EnableScheduling 활성화
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>