foam3

Overview

Reflow is FOAM’s notebook-style interactive console that enables creation of interactive documents, data analysis workflows, and visual programming environments. It provides a command-line interface where you can execute commands, visualize data, create reusable flows, and build interactive documents similar to Jupyter notebooks.

Core Architecture

The system is built around three main components:

1. Console - The main controller (foam.core.reflow.Console) that manages execution context, scope variables, and flow state. It handles command parsing, execution, and output rendering.

2. Flow Documents - Persistent documents (foam.core.reflow.Flow) that store metadata, access control, and serialized scripts representing the document structure. Flows can be saved, loaded, and shared between users.

3. Blocks - Individual execution units that represent command executions with their output and nested child blocks. Each block is an accordion-style UI element that can contain output, configuration, and hierarchical nested blocks.

Key Features

Interactive Command Execution - The console provides an extensible command system where commands are JavaScript functions or objects executed interactively. Built-in commands include:

Reactive Properties - The system includes reactive detail views with dynamic formulas. Objects can have reactions_: formulas, evaluated in the flow’s scope, that set a property. Each formula is re-evaluated about once a second (it polls; it does not listen for changes), and its errors are reported per property.

Data Visualization - Reflow includes DAO agents for visualizing data through charts and tables. The dashboard system provides bar charts, pie charts, and line charts with customizable colors and layouts.

Hierarchical Structure - The Flowable mixin provides hierarchical organization where blocks can contain nested child blocks. This enables complex document structures with collapsible sections and tree navigation.

Scope Management - The console maintains a combined scope of local and flow variables for command resolution. Commands can access and modify scope variables, enabling stateful interactive sessions.

UI Components

The system includes several specialized UI components:

Notes

Reflow essentially provides an interactive programming environment within FOAM applications, similar to how Jupyter notebooks work for Python. It’s particularly useful for data exploration, prototyping, and creating interactive documentation that combines code execution with rich output visualization. The system integrates deeply with FOAM’s DAO system, allowing direct manipulation and visualization of data collections through the console interface.

Source Files

The code behind each part described above, all under src/foam/core/reflow/ unless noted: