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:
- a Personal Knowledge Management system running on both desktop and Android, syncing with a PostgreSQL database;
- an ESP32-S3 smart watch running its own application on the embedded build of the engine. It records voice notes and uploads them to my server, where an AI transcribes them, and they appear in the Inbox of the Personal Knowledge Management system;
- a rapid application development database application, in progress;
- more generated applications used to test and harden the framework: Email, Calendar, Contacts and an AI Client.
What You Get Without Writing Code For It
Menus and buttons
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:
- show or hide the form with its state;
- collect the field values into the declared payload;
- route submit and cancel to state machine events;
- enable submit only when the event is legal, required fields are valid and the dirty rules are met;
- reset or keep the values according to the declared policy.
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
- The user submits the form.
- The declared submit signal emits an event into the state machine.
- The framework collects the declared fields and builds the payload.
- The state machine checks whether the event is legal in the current state.
- Declared payload keys are copied into typed workflow variables.
- Optional declared transforms normalize, combine, split or reshape the data, with no custom Python.
- A data-access method is called with the declared typed inputs.
- 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:
- l1_ui: passive widgets and screens that display state and emit user signals. No business logic.
- l2_bridge: transport adapters, one per platform.
- l2_facade: a thin, stateless entry point into the runtime.
- l2_runtime: the platform-neutral runtime. It carries signals between the user interface and the state machine, sequences them and manages sessions. It owns no workflow.
- l3_fsm: the hierarchical state machine engine, the authority for workflow, events, transitions and orchestration.
- l4_muscle: the actions and guards the state machine calls, plus the compile-time checks that block a release when a workflow fails them.
- l5_dal: the data-access layer for database reads and writes.
- l6_infra: infrastructure boundaries such as logging, files, authentication, network and platform APIs.
- l7_model: frozen typed data shapes that cross layer boundaries.
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
- A database pane: define tables, generate data-entry screens, and get list views with filtering and sorting automatically.
- A workflow pane.
- Security managed at the database and framework boundaries, not scattered through application code.
- More of an application's behavior defined as metadata in the database and executed by the framework.
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.