Skip to content

Interactive Full-Stack Walkthrough: One .vox File to SQL, Rust & React

Interactive Full-Stack Walkthrough: One .vox File to SQL, Rust & React

This interactive tutorial walks through building a complete full-stack module in a single .vox file and inspecting the four compiler outputs it generates in lockstep: Turso/SQLite schema definitions, typed Rust Axum route handlers with Result[T] error propagation, reactive TypeScript/React components, and JSON-Schema Model Context Protocol (MCP) agent tools.

Step-by-Step Build Path

  1. Declare the Typed Schema (table)

    Every table block automatically provisions a primary key (Id[Ticket]) and maps fields to both SQLite/Turso column affinities and Rust/TypeScript types:

    table Ticket {
    title: str
    priority: int
    resolved: bool
    }
  2. Add Read Queries and Write Mutations (query / mutation / server)

    Queries are read-only; mutations and server functions return Result[T] so database or validation errors must be handled explicitly with ? or match:

    table Ticket {
    title: str
    priority: int
    resolved: bool
    }
    query open_ticket_count() to int {
    return len(db.Ticket.all())
    }
    server create_ticket(title: str, priority: int) to Result[str] {
    if priority < 1 {
    return Error("Priority must be at least 1")
    }
    let _id = db.Ticket.insert({ title: title, priority: priority, resolved: false })?
    return Ok("Created ticket: " + title)
    }
  3. Expose an AI Agent Tool (tool) and Reactive UI (component)

    The tool keyword generates an MCP tool schema with HMAC receipt verification, while component emits a reactive .tsx view:

    table Ticket {
    title: str
    priority: int
    resolved: bool
    }
    tool "Resolve a support ticket by ID" resolve_ticket(id: Id[Ticket]) to Result[str] {
    db.Ticket.delete(id)?
    return Ok("resolved")
    }
    component TicketHeader() {
    view: column(raw_class="ticket-header") {
    heading(level=2) { "Support Queue" }
    text() { "Typed across SQL, Axum, React, and MCP" }
    }
    }

Side-by-Side Compiler Output (vox build)

Switch tabs below to compare the single .vox source module against the generated SQLite/Turso DDL, Rust Axum handler, and React TSX component:

table Ticket {
title: str
priority: int
resolved: bool
}
query open_ticket_count() to int {
return len(db.Ticket.all())
}
server create_ticket(title: str, priority: int) to Result[str] {
let _id = db.Ticket.insert({ title: title, priority: priority, resolved: false })?
return Ok("Created: " + title)
}
component TicketHeader() {
view: column(raw_class="ticket-header") {
heading(level=2) { "Support Queue" }
text() { "Synchronized schema and UI" }
}
}

Live Interactive Sandbox

Edit and run the .vox program below to test schema changes and inspect generated targets in real time:

.voxCompiler Playground
1 .vox File -> 4 Targets1.vox.voxCompilerRuntimeSQLRustTargets
example.vox ×
import voxlang.vox;
// Sandbox: Tasks queued: 1 | Tasks remaining: 0 -> Ok("done")
────────────────────────────────────────────────────────
export SQL (Turso) {
  CREATE TABLE task (id PRIMARY KEY, title TEXT, done INT);
}

Where to Go Next

Durable Workflows

Learn how activity and workflow blocks journal every step ordinal in Durable Workflows.

Language Syntax Reference

Look up ADTs, pattern matching, and decorators in the Syntax Reference.