Skip to main content

๐Ÿ–ฅ๏ธ Frontend Guide

This document describes the primary pages, services, and components of the React Frontend within the orchable module.


1. src/ Directory Structureโ€‹

src/
โ”œโ”€โ”€ App.tsx # Main Router (React Router v6)
โ”œโ”€โ”€ pages/ # Application Pages
โ”‚ โ”œโ”€โ”€ Home.tsx # Landing page
โ”‚ โ”œโ”€โ”€ Designer.tsx # Orchestrator Designer (wrapper)
โ”‚ โ”œโ”€โ”€ Launcher.tsx # Batch Launching
โ”‚ โ”œโ”€โ”€ Monitor.tsx # Progress Monitoring
โ”‚ โ”œโ”€โ”€ BatchProgress.tsx# Detailed Batch View
โ”‚ โ”œโ”€โ”€ AssetLibrary.tsx # Prompt Template + Custom Component Management
โ”‚ โ”œโ”€โ”€ Calculator.tsx # Token Cost Estimation
โ”‚ โ”œโ”€โ”€ Settings.tsx # System Settings
โ”‚ โ”œโ”€โ”€ Login.tsx # Email/Google Login
โ”‚ โ””โ”€โ”€ NotFound.tsx # 404 Page
โ”œโ”€โ”€ components/
โ”‚ โ”œโ”€โ”€ designer/ # Orchestrator Designer (ReactFlow)
โ”‚ โ”‚ โ”œโ”€โ”€ StageConfigPanel.tsx # Stage Configuration Panel
โ”‚ โ”‚ โ”œโ”€โ”€ ContractSection.tsx # IO Schema editor
โ”‚ โ”‚ โ”œโ”€โ”€ PromptEditorDialog.tsx # Rich prompt editor (reused in AssetLibrary)
โ”‚ โ”‚ โ”œโ”€โ”€ OutputSchemaEditor.tsx # JSON Schema visual editor
โ”‚ โ”‚ โ”œโ”€โ”€ IconPicker.tsx # Lucide Icon Picker for stages
โ”‚ โ”‚ โ””โ”€โ”€ PrePostProcessSection.tsx # Hooks configuration
โ”‚ โ”œโ”€โ”€ batch/ # Monitor/Batch Components
โ”‚ โ”‚ โ”œโ”€โ”€ TaskHierarchyTree.tsx # Task tree with result viewing + component editing
โ”‚ โ”‚ โ”œโ”€โ”€ ComponentEditor.tsx # TSX Component editor (sandbox)
โ”‚ โ”‚ โ”œโ”€โ”€ CustomComponentRenderer.tsx # Renders TSX within the sandbox
โ”‚ โ”‚ โ”œโ”€โ”€ SchemaRenderer.tsx # Renders JSON schema (hide/show columns)
โ”‚ โ”‚ โ””โ”€โ”€ MergeResultsPanel.tsx # Merges results from multiple tasks
โ”‚ โ””โ”€โ”€ common/
โ”‚ โ”œโ”€โ”€ AppSidebar.tsx # Navigation sidebar
โ”‚ โ””โ”€โ”€ IconPicker.tsx # (shared)
โ”œโ”€โ”€ services/
โ”‚ โ”œโ”€โ”€ stageService.ts # CRUD for prompt_templates + custom_components
โ”‚ โ”œโ”€โ”€ pricingService.ts # Fetches Gemini pricing table
โ”‚ โ”œโ”€โ”€ taskActionService.ts # Retry, Delete task/batch
โ”‚ โ”œโ”€โ”€ executionTrackingService.ts # Real-time execution tracking
โ”‚ โ”œโ”€โ”€ executionService.ts # Execution initialization
โ”‚ โ”œโ”€โ”€ configService.ts # Orchestrator configuration reader
โ”‚ โ”œโ”€โ”€ compilerService.ts # Compiles TSX using Sucrase
โ”‚ โ””โ”€โ”€ n8nService.ts # n8n API integration
โ”œโ”€โ”€ stores/
โ”‚ โ””โ”€โ”€ designerStore.ts # Zustand store for Designer state
โ”œโ”€โ”€ lib/
โ”‚ โ”œโ”€โ”€ types.ts # Global TypeScript types
โ”‚ โ”œโ”€โ”€ supabase.ts # Supabase client
โ”‚ โ”œโ”€โ”€ utils.ts # cn() and utilities
โ”‚ โ”œโ”€โ”€ icons.ts # ICONS Registry (Lucide)
โ”‚ โ”œโ”€โ”€ schemaUtils.ts # JSON Schema processing utilities
โ”‚ โ”œโ”€โ”€ componentSandbox.ts # Sandbox validation + execution
โ”‚ โ””โ”€โ”€ constants/ # Constants (default configs, etc.)
โ””โ”€โ”€ contexts/
โ””โ”€โ”€ AuthContext.tsx # Auth state (currentUser, signIn, signOut)

2. Primary Pagesโ€‹

๐ŸŽจ Designer (/designer)โ€‹

The node-graph-based Orchestrator design interface (ReactFlow).

Features:

  • Drag-and-drop addition of new Stages.
  • Connect Stages by dragging edges.
  • StageConfigPanel (right sidebar): Detailed configuration for each stage across 6 tabs (Basic, Prompt, IO, AI, Hooks, Visual).
  • Load configurations from the library (Recent Configs).
  • Export/Import stage configurations (JSON).
  • Save Config: Synchronizes all stages to Supabase prompt_templates via syncStagesToPromptTemplates().

๐Ÿš€ Launcher (/launcher)โ€‹

Select pre-configured Orchestrators and upload data to run batches.

Features:

  • List of Orchestrator configs with graph previews.
  • Excel/CSV Upload โ†’ Data preview.
  • Batch configuration (name, launch parameters).
  • Create batch and redirect to Monitor.

๐Ÿ“Š Monitor (/batch/:id and /monitor)โ€‹

Tracks execution progress in real-time.

Features:

  • Real-time task status updates (Supabase Realtime).
  • Filtering by stage and status.
  • TaskHierarchyTree: In-depth task details in a tree structure.
    • Formatted results viewing (Custom Component) or Raw JSON.
    • View Component editing (TSX sandbox).
    • CSV Export.
    • Results Merging.
  • Retry individual failed tasks / Retry All Failed.
  • Delete batches.

๐Ÿ“š Asset Library (/assets)โ€‹

Centralized management for Prompt Templates and Custom Components (TSX).

Tabs:

  1. View Components: List of custom_components with card previews. Opens the ComponentEditor for code sandbox editing.
  2. Prompt Templates: List of prompt_templates. Edit prompts using PromptEditorDialog (syntax highlighting, variable scanning, delimiter configuration).

๐Ÿงฎ Calculator (/calculator)โ€‹

Estimates Gemini API token costs before running large batches.

Features:

  • Select Orchestrator configuration.
  • Upload sample data.
  • Precise input token calculation (from actual prompt + data).
  • Output token estimation (from output schema).
  • Cost breakdown by stage and cardinality.
  • Live pricing table fetched from the Gemini pricing page.

3. Key Servicesโ€‹

stageService.tsโ€‹

  • syncStagesToPromptTemplates(): Syncs Orchestrator stages โ†’ Supabase prompt_templates.
  • getCustomComponents(): Fetches custom components.
  • createCustomComponent() / updateCustomComponent(): Component CRUD.
  • linkTemplateToComponent(): Links a template to a component.
  • updateTemplateCustomComponent(): Saves local TSX overrides to view_config.

taskActionService.tsโ€‹

  • retryTask(id): Resets a task status to plan.
  • retryAllFailedInBatch(batchId): Retries all failed tasks within a batch.
  • deleteBatch(batchId): Deletes a batch with cascading task deletion.

pricingService.tsโ€‹

  • Fetches Gemini pricing from the Google AI pricing page.
  • Caches results to minimize requests.

executionTrackingService.tsโ€‹

  • Subscribes to Supabase Realtime for task status updates.
  • Calculates batch progress (total / completed / failed).

compilerService.tsโ€‹

  • Compiles TSX source code using Sucrase within the browser.
  • Injects global scope (React, shadcn/ui components, Lucide icons, cn utility).
  • Performs security validation prior to execution.

4. Custom Component Sandboxโ€‹

Users can write TSX Components to render task output in specialized ways:

// Basic structure
const Component = ({ data, schema }) => {
return <div>{data.some_field}</div>;
};

Available Globals in Sandbox:

  • React, useState, useEffect, useMemo, useCallback.
  • cn (classNames utility).
  • All shadcn/ui components: Badge, Card, Table, Button, etc.
  • All Lucide icons.
  • Forbidden: window, fetch, eval, document.createElement.

Execution Flow:

  1. Validation (checking for dangerous patterns).
  2. Sucrase compilation (TSX โ†’ JS).
  3. Execution within a function scope with injected globals.
  4. Component extraction and rendering with data = task.output_data.

5. Authentication Flowโ€‹

graph LR
User -->|"Visit App"| AuthGuard
AuthGuard -->|"No session"| Login
Login -->|"Email OTP"| Supabase
Login -->|"Google OAuth"| Supabase
Supabase -->|"Session"| AuthContext
AuthContext -->|"currentUser"| App
  • AuthContext (contexts/AuthContext.tsx): Provides currentUser, signIn(), signOut(), and loading state.
  • Route protection: All routes require currentUser !== null.
  • Supabase RLS: auth.uid() is used to filter data by user.

Last Updated: 2026-02-24