front#
A toolkit for building UI frameworks: it compiles Python functions plus a short configuration into a spec and a tree of UI elements, and the framework renders it.
Want a UI for your functions right now? Use a concrete framework built on front, such as streamlitfront (pip install streamlitfront):
# app.py, run with: streamlit run app.py
from streamlitfront import mk_app
def add(a: int, b: int = 2):
"""Adds a and b."""
return a + b
mk_app([add])()
To build such a framework yourself, install front and read on.
pip install front
Quick example#
A minimal in-memory framework, whose “app” is a container rendering each function’s docstring:
from collections.abc import Callable
from front import SpecMakerBase, APP_KEY, OBJ_KEY, RENDERING_KEY, ELEMENT_KEY, AppMaker
from front.elements import FrontContainerBase, FrontComponentBase
from front.util import dflt_trans
class App(FrontContainerBase):
def render(self):
return {child.name: child() for child in self.children}
class Doc(FrontComponentBase):
def render(self):
return self.obj.__doc__
class SpecMaker(SpecMakerBase):
@property
def _dflt_convention(self):
return {
APP_KEY: {"title": "Untitled"},
OBJ_KEY: {"trans": dflt_trans},
RENDERING_KEY: {ELEMENT_KEY: App, Callable: {ELEMENT_KEY: Doc}},
}
def foo(a, b):
"Adds a and b."
return a + b
app_maker = AppMaker(spec_maker_factory=SpecMaker)
app = app_maker.mk_app([foo], config={APP_KEY: {"title": "My App"}})
app.name
# 'My App'
app()
# {'foo': 'Adds a and b.'}
The three-step workflow#
SpecMakerBase.mk_speccompiles a short-language configuration (plus a convention of defaults) into a long-languageFrontSpec(app_spec,obj_spec,rendering_spec).ElementTreeMaker.mk_treebuilds a composite tree ofFrontElementBaseelements from the rendering spec: a root container (e.g.FrontContainerBase) with one child per object, built fromFrontComponentBase/InputBase/OutputBasesubclasses.AppMaker.mk_appchains the two and returns the root element, callable as the app.
To implement a concrete front framework, subclass SpecMakerBase to supply the concrete element classes as the default convention, and hand it to AppMaker (see the example above, and streamlitfront for a real one).
Crudifying functions#
Crudifier/prepare_for_crude_dispatch (in front.crude) let functions with complex arguments (objects that don’t fit in a text box or URL) be dispatched through string keys into stores instead — the “CRUD-Execution” pattern. front.dag applies the same crudification to the variable nodes of a meshed DAG.
Docs#
Rendered documentation · flat front.md for a single-file view.
For AI agents#
front publishes its documentation in forms made for coding agents. If you are one, start here.
The documentation, machine-readable: llms.txt indexes every page; front.md is the whole documentation in one file; every page has a .md twin; objects.inv maps symbols to URLs.
If you are a control freak, the rest of this README is written for you, starting at the top of the page.
This documentation as a single file: front.md (Markdown, for agents).
built 2026-11-22 23:48 UTC from 31b9866 (master) · front 0.1.115 · about this build