Wishlist Search Query Management

Description

The Wishlist Search Query Management feature provides comprehensive search query management capabilities within the official wishlist context, enabling users to view and manage search queries associated with their wishlist groups. This system integrates with summary tables for optimized data access and provides keyword-based search functionality with group-based filtering.

This feature focuses on production-ready search query analysis with:

  • Search query listing within wishlist context with pagination
  • Integration with summary tables for optimized search data access
  • Group-based access control and filtering
  • Keyword grouping and deduplication
  • Real-time search query status tracking and management
  • Mall-specific keyword processing

The system ensures data consistency through proper relationship management and provides efficient access to search 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
        SearchQueryController[WishlistSearchQueryController]
    end
    
    subgraph Repositories
        SearchQueryRepo[[SummaryWishlistSearchQueryRepository]]
        WishlistRepo[[WishlistToGroupRepository]]
    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 --> SearchQueryController

    SearchQueryController --- 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'>Search Query Data Retrieval & Processing</p>
        </div>
    ]
    Step2 --> WishlistRepo
    WishlistRepo --> SearchQueryRepo

    SearchQueryRepo --- 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'>Keyword Grouping & Data Processing</p>
        </div>
    ]
    Step3 --> Database

    Database --- 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 --> SearchQueryController

    %% 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 search query 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: Search Query Data Retrieval & Processing

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

Step 3: Keyword Grouping & Data Processing

  • Description: Processes search query data with keyword grouping and deduplication
  • Action: Apply keyword grouping, remove duplicates, process mall-specific keywords
  • Input: Search query data, grouping parameters, keyword processing rules
  • Output: Processed search query data with keyword grouping and deduplication
  • Dependencies: Keyword processing, grouping algorithms, data deduplication
  • External Services: Database query optimization, keyword processing services

Step 4: Data Formatting & Response Generation

  • Description: Formats search query data for API response with proper structure and pagination
  • Action: Transform data to API format, apply pagination metadata, generate response structure
  • Input: Processed search query data, pagination metadata, response format requirements
  • Output: Formatted API response with pagination and keyword data
  • Dependencies: Data transformation services, response formatting
  • External Services: API response services, data serialization

Database Related Tables & Fields

Database: gb_console

erDiagram
    wishlist_search_queries {
        bigint id PK
        bigint group_id FK
        bigint wishlist_to_group_id FK
        bigint summary_wishlist_search_query_id FK
        integer status "0: Inactive, 1: Active"
    }
    
    summary_wishlist_search_queries {
        bigint id PK
        bigint mall_id FK "The id of the mall"
        string keyword "The keyword to search"
        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"
    }
    
    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"
    }
    
    malls {
        bigint id PK
        string name
    }
    
    wishlist_search_queries }|--|| wishlist_to_groups : "belongs to"
    wishlist_search_queries }|--|| summary_wishlist_search_queries : "references"
    summary_wishlist_search_queries }|--|| malls : "belongs to"

Case Documentation

Case 1: List Wishlist Search Queries

API: List Wishlist Search Queries

Sequence Diagram

sequenceDiagram
    participant Client
    participant Controller as WishlistSearchQueryController
    participant WishlistRepo as WishlistToGroupRepository
    participant SearchQueryRepo as SummaryWishlistSearchQueryRepository
    participant Database
    
    Note over Client,Database: List Wishlist Search Queries Flow
    
    rect rgb(255, 255, 200)
    Note right of Client: Authentication Phase
    Client->>Controller: GET /api/v1/wishlist-to-group/{slug}/wishlist-search-query
    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: Search Query Data Retrieval
    alt Wishlist Found
        Controller->>SearchQueryRepo: serverPaginationFilteringFor(params, wishlistId)
        SearchQueryRepo->>Database: SELECT with group filtering and keyword grouping
        Database-->>SearchQueryRepo: Paginated Search Queries
        SearchQueryRepo-->>Controller: Search Query Collection
    else Wishlist Not Found
        Controller-->>Client: Error Response
    end
    end
    
    rect rgb(200, 255, 200)
    Note right of Controller: Success Response
    Controller->>Controller: Transform to Resources
    Controller-->>Client: JSON Response with Search Queries
    end

Steps

  1. Authentication: Validate user session
  2. Wishlist Validation: Find wishlist by slug and validate existence
  3. Search Query Data Retrieval: Query summary search queries with group filtering and keyword grouping
  4. 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