PeaBox Lab › PeaLang › Learn › Chapter 31 › Lesson 2

Part V — The Modern Experience Layer · Chapter 31 · Lesson 2 of 2

React hooks, data grids and OpenAPI import

The frontend half of the SDK story — generate it, don't write it.

React hooks from routes

generate_react_hooks(spec, { "output": "src/hooks/" })

Each route with a known request/response shape becomes a hook: useOrders(), useCreateOrder(). The hooks carry loading/error/data states, are typed end to end and accept the same fetch wrapper options as a hand-written client — base URL, headers, error mapping.

Data grid and chart adapters

generate_data_grid_adapter(spec, "src/adapters/grid.ts")
generate_chart_adapter(spec, "src/adapters/charts.ts")

The grid adapter shapes records for TanStack Table / AG Grid-style components (column defs, sort, filter, pagination mapping); the chart adapter maps your analytics routes to chart component props. They are starting points, not frameworks — read the generated code; it is deliberately boring.

Streaming and middleware sources

Vector, RAG and ONNX export (v1.7.0)

let vec = create_vector(embed(text))
let score = cosine_similarity(vec, query_vec)
let hits = hybrid_search(store, "refund policy", 5)
export_model(model, "model.onnx")   # model_to_onnx / tree_to_onnx

VectorStore, chunk_text, bm25_score and hybrid_search are enough to ship a real retrieval feature without a vector database. model_to_onnx exports trained trees and pipelines for inference outside PeaLang.

Notebook to webapp (v1.8.0)

publish_as_webapp(notebook) and generate_notebook_html(notebook) turn an analysis notebook into a shareable page — charts, tables and the narrative included. Useful for the "here is what the data said" deliverable that used to be a PDF nobody read.

Guided practice

← Previous Next →