Lesson 5: User Scenarios#
Understanding User Journeys#
A User Scenario describes the series of steps a user takes to achieve a specific goal within your system. While static architecture diagrams show structure, user scenarios show behavior.
Why Model Scenarios?#
- Validation: Ensures that all components required for a feature actually exist and are connected.
- Clarity: Helps stakeholders understand how the system works from a user’s perspective.
- Testing: Serves as a blueprint for integration and end-to-end tests.
Example Scenario: Buying a Ticket#
- User searches for events.
- User selects a ticket.
- User enters payment details.
- System processes payment.
- System sends confirmation email.
🛠️ Sruja Perspective: Modeling Scenarios#
Sruja provides a dedicated scenario keyword to model these interactions explicitly. This allows you to visualize the flow of data across your defined architecture.
architecture "Ticketing System" {
requirement R1 functional "User can buy a ticket"
requirement R2 performance "Process payment in < 2s"
// Define the actors and systems first
person User "Ticket Buyer"
system TicketingApp "Ticketing Platform" {
container WebApp "Web Frontend"
container PaymentService "Payment Processor"
container EmailService "Notification Service"
WebApp -> PaymentService "Process payment"
PaymentService -> EmailService "Trigger confirmation"
}
// Define the scenario
scenario BuyTicket "User purchases a concert ticket" {
User -> WebApp "Selects ticket"
WebApp -> PaymentService "Process payment"
PaymentService -> EmailService "Trigger confirmation"
EmailService -> User "Send email"
}
}By defining scenarios, you can automatically generate sequence diagrams or flowcharts that map directly to your code.