StateSmith is a cross platform, free/open source tool for generating state machines in multiple languages. The generated code is human readable, has zero dependencies and is suitable for use with tiny bare metal microcontrollers, kernels, computers... It avoids dynamic memory allocations for the safety or performance inclined.


Keywords
License
Apache-2.0
Install
Install-Package StateSmith -Version 0.14.0

Documentation

StateSmith

StateSmith is a cross platform, free/open source tool for generating state machines in multiple programming languages. The generated code is human readable, has zero dependencies and is suitable for use with tiny bare metal microcontrollers, video games, apps, web, computers... It avoids dynamic memory allocations for the safety or performance inclined.

pipeline-Page-2

The above is my current plan, but I'll gladly help anyone add a new language. I'm hoping contributors will help me with this effort.


Features and Interactive Examples ๐ŸŒŸ

The fundamentals-1 webpage has simple interactive examples that let you explore most StateSmith features.

interactive-examples-preview-small


Quick Start (all supported languages) ๐Ÿš€

Want to jump right in and just try it!?

๐Ÿ”ฅ Tutorial-3 (recommended) uses new StateSmith features that are easier to use. It is a good starting point for most.
PlantUML CLI no install required

Tutorial-2 uses the older method of C# script (.csx) files which are still actively supported. The .csx approach is more complicated, but also enables advanced features and deep customization for power users. Tutorial 2 also uses draw.io which gives you maximum control, but currently has a few more "gotchas" compared to PlantUML (improvements are coming).
draw.io .csx requires dotnet install


Stay in the Know ๐Ÿ“ฐ

Our announcements discord channel is updated when new tutorials and features are added.

YouTube channel: https://www.youtube.com/@statesmith


Why State Machines and StateSmith? ๐Ÿค”

If you are new to state machines, then prepare to level up your toolbox! They are incredibly helpful for certain applications.

Why StateSmith? I couldn't find a quality state machine code generator that met my needs, had an attractive license, and was enjoyable to use.

The Diagram is Always Accurate! ๐Ÿ“š

Before I created StateSmith, it was always a pain trying to manually synchronize a hand written state machine with a drawing. Urgent client requests come in and you update the code, but do you and your team always remember to update the drawing? Probably not and so the rot begins. Documentation trust issues arise and as designs get larger, the effort to ensure the diagram is accurate starts to become quite punishing.

Now that we use StateSmith at my work, I never have to worry about the above. I love generating fully working code from the documentation. Incredibly helpful for teams and communicating with clients.


More Examples ๐Ÿ”ซ

The StateSmith-examples repo has a growing list of examples showcasing different application uses.

mario-sm


Please Consider Advising/Contributing ๐Ÿ“ˆ

If you like StateSmith and want to help improve it, your help would be very much appreciated! StateSmith is a pretty decent tool right now, but it is going to take a team to elevate it to the next level.

Thanks!


Is StateSmith ready for use? ๐Ÿงช

We use StateSmith in a fair number of production projects at my work. It's been super helpful.

StateSmith is generating working code, and has good test (598+) and behavior specification coverage. There are 45+ specification integration tests that read a diagram file, generate executable state machine code, then compile and execute that code in another process and ensure that the state machine behavior is exactly what was expected. This strong test base gives me confidence. It also allows us to refactor and optimize StateSmith without fear of accidentally breaking specified behavior.

picture 1

Breaking changes and migration steps will be documented in ./CHANGELOG.md and should be pretty minimal.


More Info ๐Ÿ“–

The StateSmith GitHub wiki has a good amount of documentation right now, but always feel free to ask a question.


Need help? Suggestion? Brainstorm? ๐Ÿ™‹

Join us on discord.

Feel free to open a github issue.

Or you can use the project's discussion space.