Back to .md Directory

UI.md — OmoiOS Frontend Architecture

Documents the frontend architecture, route structure, component organization, state management, and design system for a Next.js application.

May 2, 2026
0 downloads
3 views
ai agent workflow
View source

What this file does

Documents the frontend architecture, route structure, component organization, state management, and design system for a Next.js application.

When to use it

  • Onboarding new frontend developers to the codebase
  • Planning a new page or feature to understand existing patterns
  • Auditing state management or component usage across the app
  • Setting up a similar Next.js project with ShadCN and React Query

Assumes this stack

Next.js 15ShadCN UIReact QueryZustandTailwind CSS v4React Flow v12

UI.md — OmoiOS Frontend Architecture

This document helps contributors understand the frontend codebase quickly. For detailed page-by-page flows, see the deep-dive documentation linked throughout.

Tech Stack

LayerTechnology
FrameworkNext.js 15 (App Router)
UI ComponentsShadCN UI (Radix primitives + Tailwind CSS v4)
Server StateReact Query (TanStack Query) — 60s stale time, 1 retry
Client StateZustand with persist middleware
GraphsReact Flow v12 (@xyflow/react)
Terminalxterm.js
AnalyticsPostHog
Error TrackingSentry
FontsInter (sans), JetBrains Mono (mono)

Route Structure

The frontend uses Next.js route groups to separate concerns:

frontend/app/
├── (app)/              # Authenticated application — main product
│   ├── command/        # Command Center (primary landing after login)
│   ├── projects/       # Project management
│   │   └── [id]/
│   │       ├── specs/[specId]/  # Spec workflow viewer (most complex page)
│   │       ├── settings/        # Project config (board, GitHub, phases)
│   │       ├── explore/         # Project exploration
│   │       └── stats/           # Project statistics
│   ├── board/[projectId]/       # Kanban ticket board
│   ├── graph/[projectId]/       # Dependency graph visualization
│   ├── sandboxes/               # Sandbox list
│   │   └── sandbox/[sandboxId]/ # Sandbox execution detail (events, preview, chat)
│   ├── agents/                  # Agent management and monitoring
│   │   └── [agentId]/workspace/ # Agent terminal
│   ├── organizations/           # Org management, members, billing, settings
│   ├── settings/                # User settings (profile, security, API keys, appearance)
│   ├── health/                  # Agent health, trajectories, interventions
│   ├── activity/                # Real-time activity feed
│   ├── phases/                  # Workflow phase management
│   ├── prototype/               # Live prototype workspace
│   ├── diagnostic/[entityType]/[entityId]/  # Diagnostic reasoning
│   └── commits/[commitSha]/     # Commit detail
│
├── (auth)/             # Authentication — centered layout, no sidebar
│   ├── login/
│   ├── register/
│   ├── forgot-password/
│   ├── reset-password/
│   ├── verify-email/
│   └── callback/       # OAuth callback
│
├── (dashboard)/        # Root dashboard — redirects to /command
├── onboarding/         # Onboarding wizard (6-step flow)
├── try/                # (Planned) Public prototype workspace
├── blog/               # Blog listing and posts
├── docs/               # Documentation (Fumadocs)
├── pricing/            # Pricing page
└── showcase/[token]/   # Public showcase/demo page

Application Shell

The authenticated app uses a three-column layout:

┌──────────────────────────────────────────────────────┐
│ MinimalHeader (breadcrumbs, context, user menu)       │
├─────────┬──────────────────┬─────────────────────────┤
│ IconRail│ ContextualPanel  │ Main Content             │
│  (14w)  │   (16rem)        │   (flex-1)               │
│         │                  │                           │
│ Terminal│ Changes based on │ Route page content        │
│ Folder  │ active section:  │                           │
│ Box     │ - ProjectsPanel  │                           │
│ Building│ - TasksPanel     │                           │
│         │ - SettingsPanel  │                           │
│ ─────── │ - HealthPanel    │                           │
│ Settings│ - GraphFilters   │                           │
│         │ - etc.           │                           │
└─────────┴──────────────────┴─────────────────────────┘

Key files:

  • components/layout/MainLayout.tsx — Three-column shell
  • components/layout/IconRail.tsx — Left icon navigation (4 main + settings)
  • components/layout/ContextualPanel.tsx — Route-aware sidebar that swaps panels
  • components/layout/MinimalHeader.tsx — Top bar with breadcrumbs

Keyboard shortcuts: Cmd+1-4 navigate sections, Cmd+B collapses the panel.

Component Organization

frontend/components/
├── ui/                  # ShadCN primitives (40+ components)
│                        # Button, Card, Dialog, Tabs, Badge, Skeleton, Toast, etc.
│                        # DO NOT modify these unless updating ShadCN itself.
│
├── layout/              # Application shell (MainLayout, IconRail, ContextualPanel)
├── panels/              # Sidebar panels (ProjectsPanel, TasksPanel, HealthPanel, etc.)
│
├── command/             # Command Center — PromptInput, ModelSelector, WorkflowModeSelector
├── spec/                # Spec workflow — EventTimeline, PhaseProgress, ShareButtons
├── sandbox/             # Sandbox execution — EventRenderer, FileEditCard, ToolUseCard
├── board/               # Kanban board — AgentPanel
├── billing/             # Billing — PricingTable, SubscriptionCard, UpgradeDialog
├── onboarding/          # Onboarding wizard — OnboardingWizard + step components
├── github/              # GitHub integration — RepositoryBrowser, FileBrowser
├── preview/             # Live preview — PreviewPanel (iframe to dev server)
├── prototype/           # Prototype workspace — PrototypeWorkspace (split-view)
├── custom/              # App-specific — AgentCard, TaskCard, FileChangeCard
│
├── landing/             # Marketing landing page components
│   └── TicketJourney, CLIDemo, AgentTerminal, etc.
├── marketing/           # Marketing sections
│   ├── FloatingNavbar
│   └── sections/ (HeroSection, ProductShowcaseSection, NightShiftSection, etc.)
│
├── settings/            # Settings — ConnectedAccounts
├── docs/                # Documentation — mermaid diagram support
└── error-boundary.tsx   # Global error boundary

State Management

React Query (server state)

All data fetching uses React Query hooks in frontend/hooks/. Each hook file covers one domain:

Hook fileKey hooksDomain
useProjects.tsuseProjects(), useProject(id), useCreateProject()Project CRUD
useSpecs.tsuseProjectSpecs(), useSpec(), useApproveRequirements(), useExecuteSpecTasks()Spec workflow (largest hook file)
useAgents.tsuseAgents(), useAgentStatistics()Agent management
useSandbox.tsuseSandboxMonitor(), useSandboxTask()Sandbox execution
useTickets.tsuseTickets(), useCreateTicket()Ticket CRUD
useBoard.tsuseBoard()Kanban board state
useGitHub.tsuseGitHub(), useConnectedRepositories()GitHub integration
useOrganizations.tsuseOrganizations()Org management
useBilling.tsBilling/subscriptions
useOnboarding.tsuseOnboarding()Onboarding wizard state (Zustand + server sync)
usePrototype.tsPrototype workspace sessions
useEvents.tsuseEvents()Real-time system events
useMonitor.tsHealth monitoring

Zustand (client state)

  • useOnboarding.ts — Onboarding wizard state with persist middleware and server sync
  • Infrastructure exists for useKanbanStore, useAgentStore, useUIStore but React Query is the primary source

API Client

frontend/lib/api/client.ts — Centralized HTTP client with:

  • JWT token management (localStorage, auto-refresh 2 min before expiry)
  • Auth cookie for middleware (omoios_auth_state)
  • ApiError class with status, message, details
  • Sentry breadcrumbs on errors

Domain-specific files in lib/api/ (one per domain: projects.ts, specs.ts, agents.ts, etc.)

Providers (Context)

Wrapped in app/layout.tsx:

RootProvider (Fumadocs)
  └── QueryProvider (React Query + devtools)
       └── StoreProvider (Zustand)
            └── ThemeProvider (dark/light mode)
                 └── AuthProvider (JWT tokens)
                      └── PostHogProvider (analytics)
                           └── ErrorBoundary
                                └── Toaster (Sonner)

Design System

Colors (CSS variables)

Semantic tokens defined in CSS with light/dark variants:

  • --color-primary, --color-secondary, --color-destructive — Actions
  • --color-muted, --color-accent — UI accents
  • --color-background, --color-foreground, --color-border — Layout
  • --color-success, --color-warning, --color-info — Status
  • --color-sidebar, --color-sidebar-* — Sidebar theming
  • --color-landing-* — Marketing page colors
  • --color-chart-1 through --color-chart-5 — Data visualization

Spacing and radius

  • --radius-lg: 0.5rem (cards, large buttons)
  • --radius-md: 6px (medium elements)
  • --radius-sm: 4px (small elements)

ShadCN components (40+)

Before creating new UI primitives, check components/ui/. Available: Button, Card, Dialog, Tabs, Badge, Skeleton, Toast (Sonner), Progress, Dropdown, Select, Input, Textarea, Form (react-hook-form), Popover, Tooltip, Sheet, Accordion, Collapsible, ScrollArea, Resizable, Calendar, Breadcrumb, Pagination, Alert, and more.

Key Pages

Command Center (/command)

The primary landing page after login. Three-step workflow: select project/repo, select mode (quick/full/sandbox), enter prompt. Includes model selector, branch selection, and recent agents sidebar.

Components: command/PromptInput, command/ModelSelector, command/WorkflowModeSelector, command/RecentAgentsSidebar

Spec Viewer (/projects/[id]/specs/[specId])

The most complex page — multi-phase workflow viewer with tabs per phase (EXPLORE → REQUIREMENTS → DESIGN → TASKS → SYNC). Includes real-time event streaming, approval buttons, task cards, and sharing.

Components: spec/EventTimeline, spec/PhaseProgress, spec/ShareButtons, spec/SpecCompletionModal

Sandbox Detail (/sandbox/[sandboxId])

Real-time execution viewer showing agent events (file edits, bash commands, test runs), live preview iframe, and agent chat. Uses EventRenderer to display events with syntax highlighting.

Components: sandbox/EventRenderer, sandbox/FileEditCard, sandbox/ToolUseCard, preview/PreviewPanel

Onboarding (/onboarding)

6-step wizard: Welcome → GitHub → Repo → First Spec → Plan → Complete. State managed by useOnboarding.ts (Zustand + server sync). Step components in components/onboarding/steps/.

Detailed Documentation

For comprehensive page-by-page flows and user journeys, see:

Page Flows (docs/page_flows/)

Detailed page-by-page navigation documentation covering 67 flows across the entire application. Each document describes the exact UI elements, API calls, state transitions, and error handling for a set of related pages.

DocumentCoverage
README.mdIndex of all 67 flows with quick navigation
01_authentication.mdRegistration, login, OAuth, email verification
02_projects_specs.mdProject creation, spec-driven workflow
03_agents_workspaces.mdAgent management, spawning, workspace isolation
04_kanban_tickets.mdKanban board, ticket operations, search
05_organizations_api.mdOrg management, API key management
06_visualizations.mdDependency graph, statistics, activity timeline
07_phases.mdPhase management, gates, custom phases
08a_comments_collaboration.mdComments and collaboration
08b_ticket_operations.mdTicket search, creation, status transitions
08c_github_integration.mdGitHub OAuth, repository connection
09a_diagnostic_reasoning.mdDiagnostic reasoning view
10_command_center.mdCommand center, project selection, recent agents
10a_monitoring_system.mdHealth dashboard, trajectories, interventions
11_cost_management.mdCost dashboard, budgets, forecasting
12_agent_memory.mdMemory search, learned patterns, ACE workflow
13_sandbox_system.mdSandbox list and detail (real-time events, preview)
14_billing.mdBilling dashboard, Stripe checkout, subscriptions
15_settings_expanded.mdAppearance, integrations, notifications, security
16_public_pages.mdLanding page, pricing, blog, docs, showcase
17_activity_timeline.mdReal-time activity feed

User Journeys (docs/user_journey/)

End-to-end user flows from onboarding through feature completion, organized by journey phase rather than individual pages.

DocumentCoverage
README.mdIndex with quick navigation by topic
00_overview.md60-second story, core promise, dashboard layout
00a_demo_flow.md90-second video demo script
01_onboarding.mdOnboarding and first project setup
01a_onboarding_conversion.mdOnboarding conversion funnel analysis
02_feature_planning.mdFeature request and planning flow
03_execution_monitoring.mdAutonomous execution and monitoring
04_approvals_completion.mdApproval gates and phase transitions
05_optimization.mdOngoing monitoring and optimization
06_key_interactions.mdCommand palette, real-time updates, interventions
06a_monitoring_system.mdGuardian and monitoring system
07_phase_system.mdPhase system, custom phases, discovery branching
08_user_personas.mdPersonas: engineering manager, senior IC, CTO
09_design_principles.mdVisual design principles and success metrics
10_additional_flows.mdError handling, notifications, collaboration, mobile
11_cost_memory_management.mdCost dashboard, budgets, memory insights
12_billing_subscription.mdSubscription tiers, credits, invoices
13_public_marketing_pages.mdLanding page, pricing, blog, docs, showcase
14_settings_personalization.mdAppearance, notifications, security, integrations
15_prototype_diagnostic.mdPrototype workspace and diagnostic reasoning

How these relate

  • Page flows = "What does each page do?" — API calls, state, UI elements, error handling
  • User journeys = "How does a user accomplish a goal?" — Cross-page flows, decision points, personas
  • This document (UI.md) = "How is the frontend built?" — Architecture, components, patterns, conventions

Adding New Pages

  1. Determine the route group: (app) for authenticated, (auth) for auth flows, root for public
  2. Create page.tsx in the appropriate app/ subdirectory
  3. If the page needs a sidebar panel, add it to components/panels/ and register in ContextualPanel.tsx
  4. Create domain hooks in hooks/ and API functions in lib/api/
  5. Use existing ShadCN components from components/ui/ — don't create new primitives
  6. Document the page flow in docs/page_flows/ if it's a significant new feature

What's inside

14 sections covering tech stack, routes, shell layout, components, state management, providers, design system, key pages, and documentation links

Change this for your project

  • Replace kivo360/OmoiOS with your own repository name
  • Replace route paths like /command, /projects/[id]/specs/[specId] with your own routes
  • Replace component names like PromptInput, ModelSelector, WorkflowModeSelector with your own components
  • Replace documentation references like docs/page_flows/ and docs/user_journey/ with your own doc paths

Where it goes

Save in docs/ or the repository root. Gives agents and new contributors a map of the codebase.

Worth borrowing

  • Route groups in Next.js App Router to separate authenticated, auth, and public pages
  • Three-column layout shell with a route-aware contextual sidebar panel
  • Domain-specific React Query hooks organized by feature in a single hooks directory

Related Documents