Wishlist Category Management

Description

The Wishlist Category Management feature provides comprehensive category management capabilities within the official wishlist context, enabling users to view and manage categories associated with their wishlist groups. This system integrates with summary tables for optimized data access and provides category ranking information through analyzer database integration.

This feature focuses on production-ready category analysis with:

  • Category listing within wishlist context with pagination
  • Integration with summary tables for optimized category data access
  • Category ranking integration from analyzer database
  • Group-based access control and filtering
  • Real-time category status tracking and management
  • Mall-specific category name resolution

The system ensures data consistency through proper relationship management and provides efficient access to category data for comprehensive analysis and strategic insights.

Activity Diagram

---
config:
  theme: base
  layout: dagre
  flowchart:
    curve: linear
    htmlLabels: true
  themeVariables:
    edgeLabelBackground: "transparent"
---
flowchart TB
    %% Main components
    UserRequest[User Request]
    Database[(Database)]
    
    subgraph Controllers
        CategoryController[WishlistCategoryController]
    end
    
    subgraph Repositories
        CategoryRepo[[SummaryWishlistCategoryRepository]]
        WishlistRepo[[WishlistToGroupRepository]]
        RankingRepo[[CategoryRankingRepository]]
    end
    
    subgraph Middleware
        AuthMiddleware{AuthMiddleware}
    end
    
    UserRequest --- Step1[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>1</span>
            <p style='margin-top: 8px'>Authentication & Wishlist Validation</p>
        </div>
    ]
    Step1 --> AuthMiddleware
    AuthMiddleware --> CategoryController

    CategoryController --- Step2[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>2</span>
            <p style='margin-top: 8px'>Category Data Retrieval & Summary Integration</p>
        </div>
    ]
    Step2 --> WishlistRepo
    WishlistRepo --> CategoryRepo

    CategoryRepo --- Step3[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>3</span>
            <p style='margin-top: 8px'>Category Ranking Integration & Name Resolution</p>
        </div>
    ]
    Step3 --> RankingRepo
    CategoryRepo --> Database
    RankingRepo --> Database

    RankingRepo --- Step4[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>4</span>
            <p style='margin-top: 8px'>Data Formatting & Response Generation</p>
        </div>
    ]
    Step4 --> CategoryController

    %% Styling
    style UserRequest fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style Database fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
    style Controllers fill:#e6f3ff
    style Repositories fill:#fff0f5
    style Middleware fill:#f5f0ff
    style Step1 fill:transparent,stroke:transparent,stroke-width:1px
    style Step2 fill:transparent,stroke:transparent,stroke-width:1px
    style Step3 fill:transparent,stroke:transparent,stroke-width:1px
    style Step4 fill:transparent,stroke:transparent,stroke-width:1px

Detail Dataflow Dependency

Step-by-Step Process

Step 1: Authentication & Wishlist Validation

  • Description: Validates user authentication and wishlist access for category operations
  • Action: Authenticate user session, validate wishlist ownership, check wishlist existence
  • Input: User credentials, wishlist slug
  • Output: Validated user context with wishlist access confirmation
  • Dependencies: User authentication service, wishlist repository
  • External Services: Authentication provider

Step 2: Category Data Retrieval & Summary Integration

  • Description: Retrieves wishlist information and processes category data with group-based filtering
  • Action: Find wishlist by slug, query summary categories with group filtering, apply pagination
  • Input: Wishlist slug, pagination parameters, group context
  • Output: Paginated category data with summary information and group filtering
  • Dependencies: Wishlist repository, summary category repository, group validation
  • External Services: Database cluster, group management services

Step 3: Category Ranking Integration & Name Resolution

  • Description: Integrates category ranking data from analyzer database to resolve category names
  • Action: Extract category IDs, query category rankings, map category names to category data
  • Input: Category IDs from summary data, ranking query parameters
  • Output: Enhanced category data with resolved category names from analyzer database
  • Dependencies: Category ranking repository, analyzer database integration
  • External Services: Analyzer database, category mapping services

Step 4: Data Formatting & Response Generation

  • Description: Formats category data for API response with proper structure and pagination
  • Action: Transform data to API format, apply category name mapping, generate response structure
  • Input: Enhanced category data, pagination metadata, response format requirements
  • Output: Formatted API response with pagination and category names
  • Dependencies: Data transformation services, response formatting
  • External Services: API response services, data serialization

Database Related Tables & Fields

Database: gb_console, gb_analyzer

erDiagram
    "gb_console.wishlist_categories" {
        bigint id PK
        bigint group_id FK
        bigint wishlist_to_group_id FK
        bigint summary_wishlist_category_id FK
        integer status "0: Inactive, 1: Active"
    }
    
    "gb_console.summary_wishlist_categories" {
        bigint id PK
        string category_id "The id of the category in the mall"
        bigint mall_id FK
        integer sending_status "The status of the sending to crawler"
        integer crawl_status "The status of the crawling"
        integer status "The status of the product"
    }
    
    "gb_analyzer.category_rankings" {
        bigint id PK
        string mall_category_id
        string mall_category_name
        integer mall_id
    }
    
    "gb_console.wishlist_to_groups" {
        bigint id PK
        string name "Name of the wishlist"
        string slug "Slug of the wishlist"
        integer status "0: Inactive, 1: Active, 3: Canceled"
    }
    
    "gb_console.malls" {
        bigint id PK
        string name
    }
    
    "gb_console.wishlist_categories" }|--|| "gb_console.wishlist_to_groups" : "belongs to"
    "gb_console.wishlist_categories" }|--|| "gb_console.summary_wishlist_categories" : "references"
    "gb_console.summary_wishlist_categories" }|--|| "gb_console.malls" : "belongs to"

Case Documentation

Case 1: List Wishlist Categories

API: List Wishlist Categories

Sequence Diagram

sequenceDiagram
    participant Client
    participant Controller as WishlistCategoryController
    participant WishlistRepo as WishlistToGroupRepository
    participant CategoryRepo as SummaryWishlistCategoryRepository
    participant RankingRepo as CategoryRankingRepository
    participant Database
    
    Note over Client,Database: List Wishlist Categories Flow
    
    rect rgb(255, 255, 200)
    Note right of Client: Authentication Phase
    Client->>Controller: GET /api/v1/wishlist-to-group/{slug}/wishlist-category
    Controller->>Controller: Authenticate User
    end
    
    rect rgb(200, 230, 255)
    Note right of Controller: Wishlist Validation
    Controller->>WishlistRepo: findBySlug(slug)
    WishlistRepo->>Database: SELECT from wishlist_to_groups
    Database-->>WishlistRepo: Wishlist Record
    WishlistRepo-->>Controller: Wishlist or null
    end
    
    rect rgb(200, 255, 255)
    Note right of Controller: Category Data Retrieval
    alt Wishlist Found
        Controller->>CategoryRepo: serverPaginationFilteringFor(params, wishlistId)
        CategoryRepo->>Database: SELECT with group filtering and pagination
        Database-->>CategoryRepo: Paginated Categories
        CategoryRepo-->>Controller: Category Collection
    else Wishlist Not Found
        Controller-->>Client: Error Response
    end
    end
    
    rect rgb(255, 230, 200)
    Note right of Controller: Category Name Resolution
    Controller->>Controller: Extract category IDs
    Controller->>RankingRepo: Query category rankings by IDs
    RankingRepo->>Database: SELECT from category_rankings
    Database-->>RankingRepo: Category Rankings
    RankingRepo-->>Controller: Category Name Mapping
    end
    
    rect rgb(230, 200, 255)
    Note right of Controller: Data Enhancement
    Controller->>Controller: Map category names to categories
    Controller->>Controller: Enhance category data
    end
    
    rect rgb(200, 255, 200)
    Note right of Controller: Success Response
    Controller->>Controller: Transform to Resources
    Controller-->>Client: JSON Response with Enhanced Categories
    end

Steps

  1. Authentication: Validate user session
  2. Wishlist Validation: Find wishlist by slug and validate existence
  3. Category Data Retrieval: Query summary categories with group filtering and pagination
  4. Category Name Resolution: Extract category IDs and query analyzer database for category names
  5. Data Enhancement: Map category names to category data
  6. Response Generation: Transform to API resources and return formatted response

Error Handling

  • 401 Unauthorized: Invalid authentication
  • 404 Not Found: Wishlist not found
  • 500 Internal Server Error: Database or system errors