Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

6. Code Flow

Nguyễn Xuân Nhân edited this page Oct 2, 2023 · 1 revision

User Login

sequenceDiagram
  actor User as User
  participant Keycloak as Keycloak
  participant CMS as CMS
  participant API as API

  User->>CMS: Requests login
  CMS ->> CMS: Check login method
  CMS-->>User: Requests email and password
  alt Login via Keycloak:
    User->>Keycloak: Initiates SSO login
  else Login via internal account:
    User->>API: Sends login request
  end

  alt Correct credentials
    User->>CMS: Redirects to /home
    CMS-->>User: Shows CMS home
    User->>CMS: Accesses the CMS
  else Incorrect credentials
    User-->>User: Displays error message
    alt Wrong 5 times
      User-->>User: Locks account
    end
  end
Loading

Order Creation

sequenceDiagram
  actor User as User
  participant CMS as CMS
  participant API as API

  par Enter information:
    alt Customer's not exists:
      User->>CMS: Enter customer information
    end
    User->>CMS: Enter order information
  end
    
  CMS->>API: Send data to Server

  alt Validate data successfully:
    API-->>CMS: Notify error message
  else
    API->>Database: Stored data
    API-->>User: Send invoice via email or sms
  end
Loading

Order Lookup

sequenceDiagram
  actor User as User
  participant Website as Website
  participant API as API

  User->>Website: Enter phone number
  Website->>API: Finding order

  alt Has any order:
    alt Has any current order:
        API-->>Website: Show order tracking page
    else
        API-->>Website: Show history page
    end
    API-->>Website: Display no order message
  end
Loading

Delivery Progress

sequenceDiagram
  actor Driver as Driver
  actor User as User
  participant App as App
  participant CMS as CMS
  participant API as API
  participant Database as Database

  Driver->>App: Using the tracking app
  App->>API: Send GPS Location via MQTT
  API->>Database: Store location after 20 min
  API-->>CMS: Send location result
  User->>CMS: Management order deliver

  alt Has incident:
    App->>API: Notify to server
    API->>Database: Update order status [Incident]
    API-->>User: Send email and notification for warming
    alt Resolved:
      App->>API: Notify to server
      API->>Database: Update order status [Pending]
      API-->>User: Send email notification
    else 
      App->>API: Notify to server
      API->>Database: Update order status [Cancelled]
      API-->>User: Send email notification
    end
  end
Loading