Skip to main content

System Architecture

Yugma is an AI-native 3D studio — a professional web-based scene editor where natural language is the primary interface. Users describe what they want, and an AI Director composes the scene using structured tool calls against a live Three.js scene graph.

High-Level Architecture

Browser (yugma-app) Firebase
+----------------------------+ +----------------------------+
| React 18 + TypeScript | | Cloud Functions v2 |
| +----------+ +---------+ | | +------------------------+|
| | AIPanel | | Scene | | | | aiCompose (agentic) ||
| | + spatial| | Renderer| | | | - composeCore loop ||
| | preproc| | (R3F) | | | | - 20 tools, <=5 iter ||
| +----------+ +---------+ | | | - style injection ||
| +----------+ +---------+ | | | - Firestore persist ||
| | 17 Zustand| | Physics | | | +------------------------+|
| | stores | | World | | | | saveProviderConfig ||
| +----------+ +---------+ | | | generateMaterial (AI) ||
| +----------+ +---------+ | | | sweepGenerationJobs ||
| | Catalog | | ROS/Robot| | | | stripeWebhook ||
| | Panel | | Panel | | | | createShareLink + OG ||
| +----------+ +---------+ | | | publicApi (read API) ||
+----------------------------+ +----------------------------+
| | | |
| | Firestore | | Realtime DB
| | - projects | | - collab/cursors
| | - aiSessions | | - rooms
| | - *Jobs | | - shareLinks
| | | |
| +---------------------+ |
| |
+-----------------------------+

Key Design Principles

  1. AI-first, not AI-bolted-on. The scene graph, serialization format (YSL), and every data structure are designed for LLM consumption at ~60 tokens/object (measured).

  2. Agentic loop, not one-shot. The AI Director calls tools, sees the results (including generated IDs), and chains dependent operations across up to 5 iterations (default 3). This produces coherent multi-object scenes, not random placements.

  3. Client-side spatial computation. LLMs are bad at trigonometry. The spatial preprocessor detects patterns ("arrange 6 in a circle") and injects exact coordinates. The AI just uses them.

  4. Firebase-native data layer. Firebase handles auth, real-time collab, document storage, and AI session persistence via Firestore.

  5. Phase scaffolding. Phases 12-16 are planned verticals. Their earlier prototype stores, service stubs, and panel UIs were removed in the 2026-07 cleanup; the ROS 2 / robotics and industrial-catalog integrations that overlap them remain as real, in-progress code.

Monorepo Structure

PackagePurposeStack
yugma-appMain 3D studio editorReact + R3F + Zustand + Vite
yugma-functionsCloud Functions backendNode 22 + Firebase Functions v2
yugma-landingMarketing siteStatic HTML/CSS
yugma-adminAdmin dashboardReact + Tailwind
yugma-docsThis documentationDocusaurus

Managed with pnpm workspaces + Turborepo. Exception: yugma-functions uses npm (Firebase Cloud Build constraint).

Tech Stack

LayerTechnology
FrontendReact 18, TypeScript, Vite
3D EngineThree.js via React Three Fiber + Drei
StateZustand (17 stores)
AIGoogle Gemini, managed server-side (gemini-3.7-flash, GEMINI_API_KEY, model overridable in Admin → Providers). The only inference provider; no user-facing model picker.
3D AssetsFirst-party only: Library v2 (procedural world library, bundled), yugma-lib v1 industrial catalog, Omniverse OpenUSD packs
AuthFirebase Auth (Google OAuth only)
Document DBFirestore
RealtimeFirebase Realtime Database
StorageFirebase Cloud Storage
AI MemoryFirestore (aiSessions collection)
HostingFirebase multi-site hosting