Skip to content

Feat/147/book#148

Closed
millkk04 wants to merge 2 commits into
devfrom
feat/147/book
Closed

Feat/147/book#148
millkk04 wants to merge 2 commits into
devfrom
feat/147/book

Conversation

@millkk04
Copy link
Copy Markdown
Collaborator

@millkk04 millkk04 commented Feb 9, 2026

Summary by CodeRabbit

  • New Features

    • AI-powered book enrichment with generated taste comments, mood/style/immersion analysis, and table of contents summaries
    • Automatic intelligent tagging system that categorizes books based on their content
    • Enhanced book detail pages displaying enriched metadata and insights
    • Book search results now display tags for improved discoverability
  • Refactor

    • Repository structure optimization

@millkk04 millkk04 self-assigned this Feb 9, 2026
@millkk04 millkk04 linked an issue Feb 9, 2026 that may be closed by this pull request
18 tasks
@millkk04 millkk04 added the enhancement New feature or request label Feb 9, 2026
@millkk04 millkk04 closed this Feb 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 9, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces AI-enriched book data and automatic tag mapping. New fields (shortIntro, aiTasteComment, tasteAnalysis, tableOfContents) are added to the Books entity and DTOs. BookEnrichmentService generates enriched content; BookTagAutoMappingService auto-assigns tags using weighted keyword scoring. BookQueryServiceImpl orchestrates these services, and converters/DTOs updated accordingly.

Changes

Cohort / File(s) Summary
Entity & Field Enrichment
booklog/src/main/java/com/example/booklog/domain/library/books/entity/Books.java
Added four new private fields (shortIntro, aiTasteComment, tasteAnalysis, tableOfContents) with @Column/@lob mappings. Extended constructor to initialize new fields. Added public updateEnrichedInfo() method to atomically update enriched data and lastSyncedAt.
Enrichment Service Logic
booklog/src/main/java/com/example/booklog/domain/library/books/service/BookEnrichmentService.java
New Spring service generating AI-enriched book data: derives shortIntro from description, generates taste comments/analysis from tags, synthesizes table of contents. Includes helper methods for JSON serialization, error handling with logging, and transactional resilience.
Auto-Tagging Service
booklog/src/main/java/com/example/booklog/domain/library/books/service/BookTagAutoMappingService.java
New Spring service auto-mapping books to tags via weighted keyword scoring (3 points for title matches, 1 for description). Includes cache initialization, default tag seeding, tag selection logic per category (MOOD, STYLE, IMMERSION), and normalization utilities.
Query Service Integration
booklog/src/main/java/com/example/booklog/domain/library/books/service/BookQueryServiceImpl.java
Injected BookEnrichmentService and BookTagAutoMappingService dependencies. getBookDetail() now executes tag auto-mapping and AI enrichment within writable transaction; added try-catch for graceful error handling and persistence context flush.
DTO & Response Objects
booklog/src/main/java/com/example/booklog/domain/library/books/dto/BookDetailResponse.java, booklog/src/main/java/com/example/booklog/domain/library/books/dto/BookSearchItemResponse.java, booklog/src/main/java/com/example/booklog/domain/search/dto/BookSearchItemResponse.java
BookDetailResponse: added shortIntro, aiTasteComment, tasteAnalysis, tableOfContents fields plus nested AiTasteComment, TasteAnalysis, TasteDetail record types. Both BookSearchItemResponse files: added tags field and @Schema Swagger annotations for API documentation.
Converter & Transformation
booklog/src/main/java/com/example/booklog/domain/library/books/converter/BookConverter.java, booklog/src/main/java/com/example/booklog/domain/library/books/converter/BookSearchConverter.java
BookConverter: added Jackson ObjectMapper via @RequiredArgsConstructor; implemented parseAiTasteComment(), parseTasteAnalysis(), parseTableOfContents() helpers with null/empty checks and error handling. BookSearchConverter: extended BookSearchItemResponse constructor with empty tags list parameter.
Search Service & Repository
booklog/src/main/java/com/example/booklog/domain/search/service/BookSearchService.java, booklog/src/main/java/com/example/booklog/domain/tags/repository/BookTagsRepository.java
BookSearchService: injected BookTagsRepository; enhanced convertToSearchItem() to fetch and attach book tags (formatted with '#' prefix). BookTagsRepository: relocated to new package com.example.booklog.domain.tags.repository with added import for BookTags.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant QueryService as BookQueryServiceImpl
    participant TagMapper as BookTagAutoMappingService
    participant Enrichment as BookEnrichmentService
    participant Converter as BookConverter
    participant DB as Database
    
    Client->>QueryService: getBookDetail(bookId)
    QueryService->>DB: Load Book entity
    DB-->>QueryService: Book data
    
    Note over QueryService: Tag Auto-Mapping
    QueryService->>TagMapper: autoMapTags(book)
    TagMapper->>DB: Query existing tags
    DB-->>TagMapper: Tags & keyword map
    TagMapper->>TagMapper: Calculate weighted scores<br/>(title: 3pts, desc: 1pt)
    TagMapper->>DB: Persist BookTags associations
    DB-->>TagMapper: Success
    TagMapper-->>QueryService: Complete
    
    Note over QueryService: AI Enrichment
    QueryService->>Enrichment: enrichBookInfo(bookId)
    Enrichment->>DB: Reload Book with tags
    DB-->>Enrichment: Book + tags
    Enrichment->>Enrichment: Generate shortIntro<br/>aiTasteComment<br/>tasteAnalysis<br/>tableOfContents
    Enrichment->>DB: updateEnrichedInfo()
    DB-->>Enrichment: Updated
    Enrichment-->>QueryService: Complete
    
    Note over QueryService: Transform to Response
    QueryService->>Converter: toBookDetailResponse(book)
    Converter->>Converter: Parse JSON fields<br/>with null checks
    Converter-->>QueryService: BookDetailResponse
    QueryService-->>Client: Enriched book details
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Feat/reading status/1 #130: Reading status and key screen services consume the tag data and AI-enriched fields (mood tags, AI summaries) added by this PR.

Suggested labels

enhancement

Suggested reviewers

  • jaehyeon4406
  • icarus0616
  • ktg3891

Poem

🐰 A rabbit's ode to enriched tomes so fine,
With weighted tags and AI thoughts that shine,
From mood to style, through immersion's gate,
Each book now blooms with knowledge ornate!
Auto-mapped treasures in a cache so bright,
Making every search a pure delight! 📚✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/147/book

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 책 상세정보 API 리팩토링

1 participant