Unique Product Upload - Import

Overview Description

Upload a CSV containing unique products for processing and registration to the system. The request is authenticated and validated, then the file is parsed and enqueued for background processing.

Activity Diagram

---
config:
  theme: base
  layout: dagre
  flowchart:
    curve: linear
    htmlLabels: true
  themeVariables:
    edgeLabelBackground: "transparent"
---
flowchart TB
    %% Main components
    Client[Client App]
    Controller[UniqueProductWishlistController]
    Service(UniqueProductUploadService)
    Storage[(GCS)]
    Queue[(Queue)]

    %% Steps
    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'>POST CSV</p>
      </div>
    ]
    Step1 --> Controller

    Controller --- 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'>Auth & Validate</p>
      </div>
    ]
    Step2 --> Service

    Service --- Step3[
      <div style='text-align: center'>
        <span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; border-radius: 50%; font-weight: bold'>3</span>
        <p style='margin-top: 8px'>Store File</p>
      </div>
    ]
    Step3 --> Storage

    Service --- Step4[
      <div style='text-align: center'>
        <span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; border-radius: 50%; font-weight: bold'>4</span>
        <p style='margin-top: 8px'>Enqueue Import</p>
      </div>
    ]
    Step4 --> Queue

    Queue --> Service
    Service --> Controller
    Controller --> Client

    %% Styling
    style Client fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style Controller fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style Service fill:#f0f8e6,stroke:#339933,stroke-width:2px
    style Storage fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
    style Queue 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

Swagger Link

API: Unique Product Upload Import

API Endpoint

  • Method: POST
  • Path: /api/v1/general/unique-product-upload/import
  • Auth: Required (General)
  • Content-Type: multipart/form-data

Request

  • Body:
    • file (required): CSV file

Case Documentation

Case 1: Successful Import

Sequence Diagram

sequenceDiagram
    participant Client
    participant Controller as UniqueProductWishlistController
    participant Service as UniqueProductUploadService
    participant Storage as GCS
    participant Queue

    Client->>Controller: POST /unique-product-upload/import (file)
    Controller->>Controller: Validate auth & file
    Controller->>Service: processUpload(file)
    Service->>Storage: Store raw CSV
    Storage-->>Service: URL/Path
    Service->>Queue: Dispatch import job
    Queue-->>Service: Job queued
    Service-->>Controller: Ack import queued
    Controller-->>Client: 200 OK (message)

Steps

  • Validate authentication and input file
  • Store file to GCS
  • Create upload history record (if applicable)
  • Dispatch background job to parse and import
  • Return 200 OK with message/id

Error Handling

Status Code Error Message Description
400 Invalid file Missing file or wrong MIME/type
401 Unauthorized Missing/invalid auth
413 Payload too large File exceeds limit
500 Internal error Unexpected failure when storing/enqueuing

Additional Notes

  • Large files are processed asynchronously via queue
  • Consider size limits and CSV headers contract
  • Track progress via upload histories if exposed by API