Lesson 5: User Scenarios
Modeling user flows and interactions.
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.
import { * } from 'sruja.ai/stdlib'
R1 = requirement functional "User can buy a ticket"
R2 = requirement performance "Process payment in < 2s"
// Define the actors and systems first
User = person "Ticket Buyer"
TicketingApp = system "Ticketing Platform" {
WebApp = container "Web Frontend"
PaymentService = container "Payment Processor"
EmailService = container "Notification Service"
WebApp -> PaymentService "Process payment"
PaymentService -> EmailService "Trigger confirmation"
}
// Define the scenario
BuyTicket = scenario "User purchases a concert ticket" {
User -> TicketingApp.WebApp "Selects ticket"
TicketingApp.WebApp -> TicketingApp.PaymentService "Process payment"
TicketingApp.PaymentService -> TicketingApp.EmailService "Trigger confirmation"
TicketingApp.EmailService -> User "Send email"
}
view index {
include *
}
By defining scenarios, you can automatically generate sequence diagrams or flowcharts that map directly to your code.