docs: Frontend-Backend user_preferences 연동 불일치 문제 문서화

- ActivityPanel과 user_preferences 테이블 구조 완전 불일치
- 다중 작업 관리, Mock 데이터, API 라우팅 등 다양한 문제점 발견
- 단기/중기/장기 해결 방안 제시
- 기존 문서에 링크 추가
This commit is contained in:
happybell80 2025-08-27 01:05:22 +09:00
parent 9fda6659a1
commit dc4f624408
2 changed files with 207 additions and 0 deletions

View File

@ -87,6 +87,7 @@ CREATE TABLE user_preferences ( -- ✅ 테이블 생성 완료
### 프론트엔드 연동
- ActivityPanel 설정 UI에서도 동일하게 user_preferences 수정
- Gateway API 엔드포인트로 CRUD 구현
- **⚠️ 구조 불일치 문제 발견**: [상세 문서](/home/happybell/projects/ivada/DOCS/troubleshooting/250827_frontend_backend_user_preferences_mismatch.md) 참조
---

View File

@ -0,0 +1,206 @@
# Frontend ActivityPanel과 Backend user_preferences 연동 불일치 문제
## 작성일: 2025-08-27
## 작성자: happybell80
## 상태: 🔴 미해결 - 구조적 재설계 필요
## 영향: 사용자 설정 기능 연동 불가
## 최종 업데이트: 2025-08-27 01:30
---
## 1. 문제 요약
Frontend의 ActivityPanel 컴포넌트가 기대하는 데이터 구조와 Backend의 user_preferences 테이블 구조가 완전히 불일치하여 연동이 불가능한 상태입니다.
---
## 2. 현재 구현 상태
### 2.1 Frontend (ActivityPanel.tsx)
- **위치**: `/frontend-customer/src/components/activity-panel.tsx`
- **구현 완료**: UI 컴포넌트 및 로직
- **데이터 저장**: localStorage (목업)
- **기능**:
- 다중 브리핑 작업 관리 (task.id별)
- 키워드 추가/삭제
- 스케줄 설정 (매일/평일/주말/커스텀)
- 포함 항목 선택 (이메일/뉴스/캘린더/슬랙)
### 2.2 Backend (user_preferences 테이블)
- **위치**: PostgreSQL main_db
- **구조**:
```sql
CREATE TABLE user_preferences (
id SERIAL PRIMARY KEY,
user_id UUID REFERENCES users(id),
slack_user_id VARCHAR(100),
news_keywords VARCHAR(128)[], -- 뉴스 키워드 배열
email_filter VARCHAR(128)[], -- 이메일 필터 (미사용)
briefing_enabled BOOLEAN DEFAULT true,
briefing_time TIME DEFAULT '09:00',
updated_at TIMESTAMP DEFAULT NOW()
);
```
### 2.3 rb8001 사용 현황
- **dm_skill.py**: user_preferences에서 news_keywords 조회
- **사용자별 맞춤 뉴스**: 정상 작동 중
- **브리핑 시간**: briefing_time 사용 중
---
## 3. 핵심 문제점
### 3.1 데이터 모델 불일치
| Frontend TaskSettings | Backend user_preferences | 불일치 내용 |
|---------------------|------------------------|------------|
| keywords: string[] | news_keywords VARCHAR(128)[] | ✅ 호환 가능 |
| scheduleTime: string | briefing_time TIME | ⚠️ 타입 변환 필요 |
| scheduleType: 'everyday' \| 'weekdays' \| ... | - | ❌ 필드 없음 |
| scheduleDays: string[] | - | ❌ 필드 없음 |
| includeEmail: boolean | - | ❌ 필드 없음 |
| includeNews: boolean | - | ❌ 필드 없음 |
| includeCalendar: boolean | - | ❌ 필드 없음 |
| includeSlack: boolean | - | ❌ 필드 없음 |
### 3.2 다중 작업 관리 불가
- **Frontend**: 여러 개의 scheduledTask 관리 (일일 브리핑, 주간 리포트 등)
- **Backend**: 사용자당 1개 설정만 저장 가능
- **영향**: "일일 브리핑", "주간 리포트" 등 구분 불가
### 3.3 Mock 데이터 하드코딩
```typescript
// ActivityPanel.tsx:155-210
const conversations: ConversationSession[] = [...]; // 하드코딩
const activities: ActivityLog[] = [...]; // 하드코딩
const scheduledTasks: ScheduledTask[] = [...]; // 하드코딩
```
- 실제 데이터 조회 API 없음
- conversation_logs 테이블 조회 엔드포인트 필요
### 3.4 API 라우팅 문제
```python
# robeing-gateway/main.py:391
@app.api_route("/api/{path:path}", methods=["GET", "POST", "PUT", "DELETE"])
# 모든 /api/* 요청을 가로챔
# /api/preferences가 어디로 갈지 불명확
```
### 3.5 서버 혼선
- ActivityPanel 주석: "51123 서버 PostgreSQL DB와 연결"
- 실제: 51124 서버의 PostgreSQL 사용 중
- robeing-monitor도 51124 서버에서 실행 중
### 3.6 실시간 동기화 부재
- localStorage 기반으로 다른 디바이스와 동기화 안됨
- WebSocket이나 polling 구현 없음
### 3.7 권한 검증 누락
- user_preferences 수정 시 본인 확인 로직 필요
- 다른 사용자 설정 수정 가능한 보안 문제
---
## 4. 해결 방안
### 4.1 단기 해결책 (최소 수정)
1. **Backend 스키마 확장**
```sql
ALTER TABLE user_preferences ADD COLUMN schedule_type VARCHAR(20);
ALTER TABLE user_preferences ADD COLUMN schedule_days VARCHAR(10)[];
ALTER TABLE user_preferences ADD COLUMN include_email BOOLEAN DEFAULT true;
ALTER TABLE user_preferences ADD COLUMN include_news BOOLEAN DEFAULT true;
ALTER TABLE user_preferences ADD COLUMN include_calendar BOOLEAN DEFAULT false;
ALTER TABLE user_preferences ADD COLUMN include_slack BOOLEAN DEFAULT false;
```
2. **robeing-monitor에 CRUD API 추가**
```python
GET /api/preferences/{user_id}
PUT /api/preferences/{user_id}
GET /api/conversations/{user_id}?limit=10
GET /api/activities/{user_id}?limit=10
```
3. **ActivityPanel localStorage → API 호출 변경**
### 4.2 중기 해결책 (구조 개선)
1. **scheduled_tasks 테이블 생성**
```sql
CREATE TABLE scheduled_tasks (
id SERIAL PRIMARY KEY,
user_id UUID REFERENCES users(id),
task_type VARCHAR(50), -- 'daily_briefing', 'weekly_report' 등
title VARCHAR(255),
schedule_type VARCHAR(20),
schedule_days VARCHAR(10)[],
schedule_time TIME,
settings JSONB, -- 유연한 설정 저장
enabled BOOLEAN DEFAULT true
);
```
2. **Frontend와 Backend 인터페이스 통일**
- 공통 TypeScript 타입 정의
- API 응답 형식 표준화
### 4.3 장기 해결책 (완전 재설계)
1. **마이크로서비스 분리**
- user-preferences-service 별도 구현
- GraphQL 도입 검토
2. **실시간 동기화**
- WebSocket 구현
- 설정 변경 시 실시간 반영
---
## 5. 현재 작동 중인 부분
### ✅ 정상 작동
- rb8001의 news_keywords 조회 및 사용
- 사용자별 맞춤 뉴스 제공
- PostgreSQL user_preferences 테이블 기본 구조
### ❌ 작동 불가
- Frontend ActivityPanel ↔ Backend 연동
- 다중 브리핑 작업 관리
- 실제 대화/활동 데이터 표시
---
## 6. 우선순위 제안
1. **높음**: news_keywords만이라도 연동 (가장 간단)
2. **중간**: scheduled_tasks 테이블 생성 및 연동
3. **낮음**: 실시간 동기화 구현
---
## 7. 관련 파일
### Frontend
- `/home/happybell/projects/ivada/frontend-customer/src/components/activity-panel.tsx`
### Backend
- `/home/happybell/projects/ivada/robeing-monitor/app/api/items.py`
- `/home/happybell/projects/ivada/robeing-gateway/app/main.py`
- `/home/happybell/projects/ivada/rb8001/app/skills/dm_skill.py`
### 문서
- `/home/happybell/projects/ivada/DOCS/troubleshooting/250826_slack_id_column_standardization.md`
---
## 8. 다음 단계
1. 팀 논의: Frontend 요구사항 vs Backend 현실 조율
2. 우선순위 결정: 최소 기능부터 구현
3. API 설계: RESTful vs GraphQL 결정
4. 구현 계획 수립
---
*작성: 2025-08-27 01:30*
*상태: 구조적 문제로 즉시 해결 불가, 팀 논의 필요*