' ============================================================
' WALKGUIDE — DESIGN PATTERNS (GoF)
' Flutter × Spring Boot × In-Device AI
' Pattern 1 of 7: BUILDER (Creational)
' ============================================================

@startuml WalkGuide_01_Builder

skinparam monochrome false
skinparam shadowing false
skinparam defaultFontName Arial
skinparam defaultFontSize 12
skinparam roundCorner 10
skinparam ArrowColor #555555
skinparam ArrowThickness 1.2

skinparam class {
    BackgroundColor #FAFAFA
    BorderColor #AAAAAA
    HeaderBackgroundColor #E8E8E8
    FontColor #222222
    StereotypeFontColor #666666
    AttributeFontColor #333333
}

skinparam package {
    BackgroundColor #F5F5F5
    BorderColor #888888
    FontColor #333333
    FontStyle bold
}

skinparam note {
    BackgroundColor #FFFDE7
    BorderColor #F9A825
    FontColor #444444
    FontSize 11
}

' ============================================================
' PATTERN 1 — BUILDER (Creational)
' ============================================================

package "①  Builder Pattern  [Creational]" #EEF6EE {

    interface "UserBuilder\n<<Builder>>" as UserBuilder {
        + email(String) : UserBuilder
        + password(String) : UserBuilder
        + displayName(String) : UserBuilder
        + uniqueUserId(String) : UserBuilder
        + fcmToken(String) : UserBuilder
        + role(Role) : UserBuilder
        + build() : User
    }

    class "User\n<<Entity>>" as User {
        - id : Long
        - email : String
        - password : String
        - displayName : String
        - uniqueUserId : String
        - fcmToken : String
        - role : Role
        - createdAt : Timestamp
        + {static} builder() : UserBuilder
    }

    class "FcmService\n<<Service>>" as FcmService {
        + sendPushNotification(userId, payload)
        + sendSosAlert(guardianId, lat, lng)
        - buildMessage(token, title, body) : Message
    }

    class "AuthService\n<<Service>>" as AuthService {
        + register(RegisterRequest) : AuthDataResponse
        + login(LoginRequest) : AuthDataResponse
        - buildAuthResponse(user, tokens) : AuthDataResponse
    }

    UserBuilder ..> User : <<creates>>
    User ..> UserBuilder : <<returns>>
    FcmService ..> "Firebase\nMessage.builder()" : uses
    AuthService ..> "AuthDataResponse\n.builder()" : uses
}

note bottom of UserBuilder
  Lombok @Builder pada User.java
  Memisahkan konstruksi objek kompleks
  dari representasinya. Optional fields
  (displayName, uniqueUserId, fcmToken)
  tidak perlu constructor overloading.
end note

@enduml
