Base Product

Overview Description

The Product List feature retrieves and displays a comprehensive list of products from a specified dataset. It provides essential product information that can be used for analysis and comparison. This feature serves as the foundation for other analytical features by presenting the base product data available in the selected dataset.

Before using this feature, a valid dataset history must be available in the system, and the user must have the appropriate permissions to access it.

Swagger Link

API: Base Products

Case Documentation

Case 1: Successful Base Product List

Description

User successfully retrieves a list of products from a valid dataset.

Sequence Diagram

sequenceDiagram
    participant User
    participant API as ProductAnalyzerController
    participant Service as ProductAnalyzerService
    participant Repo as WishlistDatasetHistoryRepository
    participant DB as Database

    Note over User,DB: Step 1: Request Base Products
    User->>API: GET /api/v1/general/analyzer/{wldh_slug}/products
    
    Note over API,Repo: Step 2: Validate Dataset
    API->>Repo: findBySlug(wldh_slug)
    Repo-->>API: wishlistDatasetHistory
    
    Note over API,Service: Step 3: Retrieve Product Details
    API->>Service: getProductDetailByDatasetId(dataset_id, wishlist_to_group_id, request_data)
    Service->>DB: Query last product details
    DB-->>Service: Product details
    
    Note over Service,API: Step 4: Format Response
    Service-->>API: Product data collection
    
    Note over API,User: Step 5: Return Response
    API-->>User: 200 OK (BaseProductResource collection)

Steps

Step 1: Request Base Products

  • Description: User requests base products for a dataset history
  • Request: GET /api/v1/general/analyzer/{wldh_slug}/products
  • Parameters:
    • Path: wldh_slug
    • Query (optional):
      • search: keyword
      • per_page: integer
      • page: integer

Step 2: Validate Dataset

  • Description: System validates that the requested dataset history exists
  • Action: Find dataset history by slug in the repository
  • Potential errors: Dataset not found

Step 3: Retrieve Product Details

  • Description: System fetches the latest product details
  • Action: Call service to get last product details scoped to dataset config
  • Data retrieved:
    • Basic product information
    • Product attributes
    • Associated metadata

Step 4: Format Response

  • Description: System formats the product data for response
  • Action: Transform product models to BaseProductResource collection
  • Transformation:
    • Normalize attributes and include dataset-specific metadata
    • Structure according to API resource specification

Step 5: Return Response

  • Description: System returns formatted product list to user
  • Response:
    • Success: 200 OK with collection of product resources
    • Error: Appropriate error message and status code

Activity Diagram

---
config:
  theme: base
  layout: dagre
  flowchart:
    curve: linear
    htmlLabels: true
  themeVariables:
    edgeLabelBackground: "transparent"
---
flowchart TB
    Client[Client Application]
    API[ProductAnalyzerController]
    Dataset[Dataset Validation]
    Service(ProductAnalyzerService)
    DB[(Database)]

    Client --- 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'>Send GET Request</p>
      </div>
    ]
    Step1 --> API

    API --- 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'>Validate Dataset</p>
      </div>
    ]
    Step2 --> Dataset

    API --- 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'>Query Products</p>
      </div>
    ]
    Step3 --> Service
    Service --> DB
    DB --> Service

    Service --- 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'>Format Response</p>
      </div>
    ]
    Step4 --> API

    API --- Step5[
      <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'>5</span>
        <p style='margin-top: 8px'>Send JSON Response</p>
      </div>
    ]
    Step5 --> Client

    %% Styling
    style Client fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style API fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style Dataset fill:#f0f8e6,stroke:#339933,stroke-width:2px
    style Service fill:#f0f8e6,stroke:#339933,stroke-width:2px
    style DB fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
    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
    style Step5 fill:transparent,stroke:transparent,stroke-width:1px

Error Handling

Status Code Error Message Description
404 "Dataset not found" When the specified wldh_slug does not exist
400 Generic error with exception message When unexpected errors occur during processing

Additional Notes

  • Supports search and pagination via query params
  • Returns BaseProductResource collection including dataset-scoped metadata

Database Related Tables & Fields

erDiagram
    products {
        bigint id PK
        string mall_product_id "External product identifier (Amazon/Rakuten/JAN)"
        bigint category_id FK "Reference to category"
        timestamp created_at
        timestamp updated_at
    }
    product_details {
        bigint id PK
        bigint product_id FK "Reference to products"
        string title "Latest product title"
        string image "Main image URL"
        int price "Current price (nullable)"
        int num_reviews "Total review count (nullable)"
        timestamp crawl_created_at "Crawl timestamp for detail"
        timestamp created_at
        timestamp updated_at
    }

    products ||--o{ product_details : has

Error Handling

  • Log

    • Product list retrieval failures logged to application log
  • Error Detail:

    Status Code Error Message Description
    404 "Dataset not found" When the specified dataset slug does not exist
    400 Generic error with exception message When unexpected errors occur during processing

Additional Notes

  • The product list can be filtered and paginated using query parameters
  • Large datasets may require pagination for optimal performance
  • This endpoint forms the basis for more detailed product analysis features