Skip to content

Feat: 카드 저장 API 구현#7

Merged
stoneTiger0912 merged 2 commits intomainfrom
feat/add-save-cardset
Mar 16, 2026
Merged

Feat: 카드 저장 API 구현#7
stoneTiger0912 merged 2 commits intomainfrom
feat/add-save-cardset

Conversation

@stoneTiger0912
Copy link
Member

@stoneTiger0912 stoneTiger0912 commented Mar 16, 2026

📝 변경 내용


✅ 체크리스트

  • 코드가 정상적으로 동작함
  • 테스트 코드 통과함
  • 문서(README 등)를 최신화함
  • 코드 스타일 가이드 준수

💬 기타 참고 사항

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능
    • 카드셋 내 카드 목록 조회 및 저장 기능 추가
    • 실시간 협업을 위한 Yjs 기반 동기화 및 공동 편집 지원 강화
    • Redis 기반 저장소로 문서 지속성 및 성능 최적화
    • 웹소켓 기반 실시간 카드 업데이트 기능 개선

@stoneTiger0912 stoneTiger0912 self-assigned this Mar 16, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9a4b3782-724b-4c84-8cf6-83a8ac4e658e

📥 Commits

Reviewing files that changed from the base of the PR and between 49507ac and 8f331f5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (25)
  • package.json
  • src/app.module.ts
  • src/auth/infrastructure/guard/ws-auth.guard.ts
  • src/cardset/application/cardset.use-case.ts
  • src/cardset/application/dto/response/card.response.ts
  • src/cardset/application/dto/response/yjs-card.response.ts
  • src/cardset/cardset.module.ts
  • src/cardset/domain/repository/card.repository.ts
  • src/cardset/domain/repository/cardset-metadata.repository.ts
  • src/cardset/infrastructure/grpc/reaction-grpc.client.ts
  • src/cardset/infrastructure/grpc/user-grpc.client.ts
  • src/cardset/infrastructure/http/card.controller.ts
  • src/cardset/infrastructure/http/cardset.controller.ts
  • src/cardset/infrastructure/http/group-cardset.controller.ts
  • src/cardset/infrastructure/persistence/card.repository.impl.ts
  • src/cardset/infrastructure/persistence/cardset-metadata.repository.impl.ts
  • src/cardset/infrastructure/persistence/cardset.repository.impl.ts
  • src/collaboration/application/collaboration.use-case.ts
  • src/collaboration/collaboration.module.ts
  • src/collaboration/infrastructure/gateway/collaboration.gateway.ts
  • src/collaboration/infrastructure/persistence/orm/cardset-content.orm-entity.ts
  • src/collaboration/infrastructure/persistence/orm/cardset-incremental.orm-entity.ts
  • src/collaboration/infrastructure/redis/yjs-document.service.ts
  • src/reaction/reaction.consumer.ts
  • src/reaction/reaction.module.ts

워크스루

이 PR은 Redis 기반 Yjs 협업 시스템을 도입하며, ORM 엔티티를 YjsDocumentOrmEntity에서 CardsetContentOrmEntity와 CardsetIncrementalOrmEntity로 대체합니다. CollaborationUseCase와 CollaborationGateway가 Redis 서비스를 통해 실시간 문서 동기화를 관리하도록 리팩토링되었고, 새로운 HTTP 엔드포인트가 카드 목록 조회 및 저장 기능을 추가합니다.

변경 사항

Cohort / File(s) 요약
의존성 및 설정
package.json, src/app.module.ts, src/collaboration/collaboration.module.ts
ioredis 의존성 추가, ORM 엔티티 YjsDocumentOrmEntity → CardsetContentOrmEntity 및 CardsetIncrementalOrmEntity로 변경, CollaborationModule에서 새로운 YjsDocumentService 공급자 및 exports 추가
인증 보안
src/auth/infrastructure/guard/ws-auth.guard.ts
SKIP_WS_AUTH 환경 변수를 통한 테스트 모드 바이패스 기능 추가, 더미 사용자 주입 및 로깅
Yjs 협업 인프라
src/collaboration/infrastructure/redis/yjs-document.service.ts, src/collaboration/infrastructure/persistence/orm/cardset-content.orm-entity.ts, src/collaboration/infrastructure/persistence/orm/cardset-incremental.orm-entity.ts
Redis 기반 Yjs 문서 관리 서비스 신규 생성, 증분 업데이트 저장/로드 기능, 자동 플러시 및 클라이언트 추적, CardsetContent 및 CardsetIncremental ORM 엔티티 신규 정의
협업 비즈니스 로직
src/collaboration/application/collaboration.use-case.ts
YjsDocumentService 의존성 주입으로 변경, getOrCreateDocument 리팩토링 (Redis → DB 로드 체인), 새로운 getCards/saveCardsetContent/loadCardsetContentFromDB 메서드 추가, 증분 업데이트 저장 로직 변경
협업 게이트웨이
src/collaboration/infrastructure/gateway/collaboration.gateway.ts
YjsDocumentService 의존성 추가, join-cardset/leave-cardset 핸들러 Yjs 문서 관리로 확장, awareness 및 update 메시지 핸들러 신규 추가, 플러시 스케줄링 및 클라이언트 라이프사이클 관리
카드셋 비즈니스 로직 및 DTO
src/cardset/application/cardset.use-case.ts, src/cardset/application/dto/response/card.response.ts, src/cardset/application/dto/response/yjs-card.response.ts
CollaborationUseCase 의존성 추가, saveCards/findCardsFromYjs 메서드 추가, CardResponse.fromYjs 팩토리 메서드 신규, YjsCardResponse DTO 클래스 신규 생성
저장소 인터페이스 및 구현
src/cardset/domain/repository/card.repository.ts, src/cardset/domain/repository/cardset-metadata.repository.ts, src/cardset/infrastructure/persistence/card.repository.impl.ts, src/cardset/infrastructure/persistence/cardset-metadata.repository.impl.ts
ICardRepository.update에 선택적 manager 파라미터 추가, CardRepositoryImpl에서 manager 기반 저장소 선택 로직 구현, ICardSetMetadataRepository에 upsertAndDecrementBookmark 메서드 추가
HTTP 컨트롤러 및 엔드포인트
src/cardset/infrastructure/http/cardset.controller.ts, src/cardset/cardset.module.ts
CardsetController에 GET /card-sets/:cardsetId/cards (카드 목록), POST /card-sets/:cardsetId (카드 저장) 엔드포인트 추가, YjsCardResponse 매핑, CardsetModule에 CollaborationModule 임포트 추가
마이너 포맷팅
src/cardset/infrastructure/http/card.controller.ts, src/cardset/infrastructure/grpc/..., src/cardset/infrastructure/persistence/cardset.repository.impl.ts, src/cardset/infrastructure/persistence/cardset-metadata.repository.impl.ts, src/cardset/infrastructure/http/group-cardset.controller.ts, src/reaction/reaction.consumer.ts, src/reaction/reaction.module.ts
구조적 기능 변경 없는 포맷팅 및 줄 바꿈 조정

시퀀스 다이어그램

sequenceDiagram
    actor Client
    participant CG as CollaborationGateway
    participant YDS as YjsDocumentService
    participant Redis
    participant DB as CardsetContent<br/>Repository
    
    Client->>CG: join-cardset (cardsetId)
    CG->>YDS: getOrCreateDocument(cardsetId)
    YDS->>Redis: loadDocument(cardsetId)
    alt Document in Redis
        Redis-->>YDS: Y.Doc state
    else Not in Redis
        YDS->>DB: Query CardsetContent
        alt Content in DB
            DB-->>YDS: stored content
            YDS->>YDS: reconstruct Y.Doc
        else No DB content
            YDS->>YDS: create new Y.Doc
            YDS->>Redis: saveDocument(cardsetId, doc)
        end
    end
    YDS-->>CG: Y.Doc
    CG->>Client: emit sync (encoded state)
    
    Client->>CG: update (cardsetId, update payload)
    CG->>YDS: getOrCreateDocument(cardsetId)
    YDS-->>CG: Y.Doc
    CG->>CG: apply update to Y.Doc
    CG->>YDS: saveUpdate(cardsetId, update)
    YDS->>Redis: store incremental update
    YDS->>YDS: scheduleMySqlPersistence(cardsetId)
    CG->>Client: broadcast updated state
    
    Note over CG,DB: On last client disconnect or timeout
    CG->>YDS: flushIncrementalHistory(cardsetId)
    YDS->>DB: persist incremental updates
    YDS->>Redis: clear history key
Loading

예상 코드 리뷰 난이도

🎯 4 (Complex) | ⏱️ ~65분

관련 PR

🐰 Redis의 빠른 손으로, Yjs 문서는 춤을 추네
협업의 마법, 증분 업데이트로 영원히
플러시 스케줄러가 조화를 지키고
카드는 떼 지어 나는 새처럼 흘러간다네
공유의 정원, 이제 더 단단해졌네! 🎯✨

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-save-cardset
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can generate walkthrough in a markdown collapsible section to save space.

Enable the reviews.collapse_walkthrough setting to generate walkthrough in a markdown collapsible section.

@stoneTiger0912 stoneTiger0912 merged commit 35e8a45 into main Mar 16, 2026
1 of 2 checks passed
@stoneTiger0912 stoneTiger0912 deleted the feat/add-save-cardset branch March 16, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant