Certainly! We'll enrich the previous scenario with additional detail, adding elements like conditions, loops, and alt fragments to represent different branches of logic. Here's a more advanced PlantUML code for the "book tickets" use case on a travel booking website:
@startuml
!theme plain
title Travel Booking Website - Book Tickets Sequence Diagram
actor User as user
participant "Booking Website\nInterface" as website
participant "Flight Search\nSystem" as flightSystem
participant "Payment\nService" as paymentService
participant "Email\nService" as emailService
user -> website: Access booking site
alt logging in
website -> user: Prompt for login
user -> website: Enter credentials
website -> website: Validate credentials
alt valid credentials
website -> user: Show main page
else invalid credentials
website -> user: Show error
end
end
user -> website: Search for flights (origin, destination, date)
website -> flightSystem: Request available flights
activate flightSystem
flightSystem -> flightSystem: Search for flights
flightSystem -> website: Respond with flight options
deactivate flightSystem
website -> user: Display flight options
user -> website: Select flight and proceed to book
loop Seat Selection
website -> user: Request seat selection
user -> website: Select seat
end
website -> paymentService: Initiate payment
activate paymentService
paymentService -> website: Request payment details
website -> user: Ask for payment information
user -> website: Provide payment information
website -> paymentService: Send payment details
paymentService -> paymentService: Process payment
alt payment successful
paymentService -> website: Confirm payment
deactivate paymentService
website -> emailService: Send confirmation email
emailService -> user: Email ticket and receipt
website -> user: Display booking confirmation
deactivate website
user -> website: Confirm receipt and log out
else payment failed
paymentService -> website: Decline payment
deactivate paymentService
website -> user: Inform payment failure
deactivate website
end
@enduml
In this enhanced sequence diagram, the following elements were included to provide more depth to the scenario:
- Login activity which branches into valid and invalid credentials scenarios.
- The loop construct shows repeated seat selection if needed by the user.
- An alternate (
alt) fragment to account for the outcomes of the payment process, either successful or failed.
- Interaction with an Email service which sends booking confirmation and receipt upon successful payment.
Remember to adapt this PlantUML code further to match the specific logic and possible scenarios pertinent to your actual travel booking website application.