Statecharts & FSM
Statecharts are what I am spending my free evenings on at the moment. I did not go looking for them. I went looking for a way to stop order fulfilment for Cüte from collapsing under its own edge cases, where payments, shipping, cancellations, refunds, disputes and webhooks all have to cooperate while failing in completely different ways.
I expected a tidy programming pattern. What I found was a whole way of thinking about software, and a surprisingly generous community drawing diagrams and reasoning through hard systems out loud. That part, more than the technique, is what pulled me in.
What actually clicked
The thing I keep turning over is that the diagram does not have to come after the code. It can be the thing that defines how the software is allowed to behave. When I model an order that way, impossible states stay impossible, because every event is judged against the current state instead of a pile of booleans I left lying around the codebase.
The shape I trust so far
If I had to write down what I believe today, it is this. The statechart decides, the workflow executes, the database remembers. For Cüte that means XState for the rules, durable workflows for the calls out to payment and shipping, and Postgres as the source of truth. I reserve the right to be wrong about all of it.
Still drawing
My diagrams change almost every week, and a few of my machines are more complicated than they have any right to be. I do not really mind. I am writing this less to explain statecharts and more to mark where I am with them right now. The people in this corner seem genuinely interested in making hard software easier to understand, and for the moment that is reason enough to keep going.
How can I help
- State machine design
- Interaction architecture
- Frontend engineering