What I'm Building

I am building StateAtlas: a tool for making tools. It is a Python application framework in which the behavior of an application is declared as a state machine map instead of being written as control flow scattered through the code.

My goal is to be an enabler for small businesses. Many of them have never been able to afford custom software to automate their work. I want to make that software fast enough to build that they can.

What Exists Today

I use the framework to build real applications, which is how I find the bugs and improve it. Currently I have:

What You Get Without Writing Code For It

In imperative code, turning clicks into actions and keeping the right controls enabled is tedious. In StateAtlas, one row in the map database says "this button or menu item emits this event". When the user clicks, the framework emits that event into the state machine.

The event is only legal in certain states, as the map defines. The framework uses that to enable or disable the control: if the event is legal in the current state, the control is enabled, and if not, it is disabled. The user interface does not decide this with custom code.

Forms and dialogs

Forms and dialogs are bound to states. When a bound state is entered, the form is shown. When it is exited, the form is hidden. One row in a database table sets this up.

A form declaration covers the container widget, the fields, the submit and cancel signals, how fields map into the payload, validation rules, dirty tracking, and whether values are reset or kept on close. The framework uses it to:

Fields are declared the same way: which form a field belongs to, which widget supplies its value, which payload key or variable it maps to, its type, and whether it is required.

A typical form submission

  1. The user submits the form.
  2. The declared submit signal emits an event into the state machine.
  3. The framework collects the declared fields and builds the payload.
  4. The state machine checks whether the event is legal in the current state.
  5. Declared payload keys are copied into typed workflow variables.
  6. Optional declared transforms normalize, combine, split or reshape the data, with no custom Python.
  7. A data-access method is called with the declared typed inputs.
  8. The data layer performs the database read or write.

The user interface emits intent. The state machine orchestrates. Declared bindings and transforms prepare typed data. The data layer does the persistence.

How It Is Built

One map, three platforms, and a watch

One application can target a desktop, a phone or a browser by changing only the top two layers: the widgets and the bridge beneath them. There is an adapter for each target, using Qt on the desktop, QML on Android, and FastAPI with HTMX on the web. Everything beneath is shared: the state map, the actions, data access, infrastructure and the typed data models. Testing the map benefits every platform at once.

The ESP32-S3 watch runs a separate, compact state machine runtime written for the microcontroller. It is a separate implementation, not a port, but it is driven by a contract generated from the same map database and uses the same map making and viewing tools.

Maps live in a database

State maps are declared in a database. States, events, transitions, guards, actions, user-interface bindings and forms are all structured relational data, which suits them well. The maps are exported as signed JSON contracts that the runtime consumes. I use AI to help create the maps and the supporting code. It is a great time to be alive!

Seven layers

The architecture has seven layers. Layer 2 is split into three directories, which is why there are nine directories in all:

Dependencies flow downward: upper layers may import lower layers, never the reverse. A linter enforces these rules.

State machines run safety-critical systems such as cars, aircraft, spacecraft, medical equipment, nuclear power plants and industrial controls. They are common in hardware and embedded systems and much less common in the business applications most programmers build. I believe they have strong advantages there too. Why Use State Machines? makes that case.

What Is Planned

The template application currently contains a State Machine Map Viewer pane and a Logging pane.

If you are a developer and this interests you, contact me. I will need beta testers before long.