Examples

Learn StateWalker FSM through practical examples. Each example builds on concepts from the previous one, progressively demonstrating more sophisticated patterns and techniques.

These examples show complete, working applications using the StateWalker orchestrator. You’ll see how to structure FSM definitions, implement handlers, manage context, and integrate with external services. All code follows the best practices and conventions outlined in the documentation.


Light Bulb

The fundamentals of state machines

A simple on/off light bulb that toggles between two states. This example introduces the core concepts: state definitions, transitions, events, handlers, and views. Perfect for understanding how StateWalker FSM works before moving to more complex scenarios.

What you’ll learn:

Complexity: Beginner


Traffic Light

Automatic transitions and cyclic state machines

A traffic light that cycles through red, green, and yellow states automatically. This example demonstrates time-based transitions, cyclic workflows, and exit conditions for continuous processes.

What you’ll learn:

Complexity: Intermediate


User Authentication

Error handling and validation flows

A complete authentication system managing login, session refresh, and logout flows. This example shows how to handle validation, error states, recovery paths, and automatic session management.

What you’ll learn:

Complexity: Intermediate


Order Processing

Complex business workflows

A full e-commerce order processing system handling validation, payment, fulfillment, shipping, and various error scenarios. This is the most sophisticated example, demonstrating enterprise-grade complexity with nested states and comprehensive error handling.

What you’ll learn:

Complexity: Advanced


Learning Path

Start here: Begin with the Light Bulb to understand FSM fundamentals.

Next steps: Move to Traffic Light to learn automatic transitions and cycles.

Add complexity: Study User Authentication for error handling and validation patterns.

Enterprise patterns: Tackle Order Processing to see how everything scales to real business applications.

Each example includes:


Additional Resources

Ready to build your own state machines? These resources will help:

Have questions or want to share your own examples? Visit the community forum or check the GitHub repository.