Last updated

Development Guide

Mirrored from iblai/os ยท docs/development.md. This page is generated โ€” edit it in the repository, not here.

Prerequisites

  • Node.js 25.3.0+ (we recommend using nvm)
  • pnpm 10+ โ€” npm install -g pnpm

Quick Start

1. Clone the repository

git clone https://github.com/iblai/os.git
cd os

2. Install dependencies

pnpm install

3. Configure environment

cp .env.example .env.local

Edit .env.local with your ibl.ai platform credentials:

# Required โ€” your ibl.ai platform URLs
NEXT_PUBLIC_AUTH_URL=https://login.iblai.app
NEXT_PUBLIC_API_BASE_URL=https://api.iblai.app
NEXT_PUBLIC_LEGACY_LMS_URL=https://learn.iblai.app

# Required โ€” your tenant key
NEXT_PUBLIC_MAIN_TENANT_KEY=main

# Required โ€” WebSocket and voice servers
NEXT_PUBLIC_BASE_WS_URL=wss://asgi.data.iblai.app
NEXT_PUBLIC_IBL_LIVE_KIT_SERVER_URL=wss://livekit.call.iblai.app

# App URLs
NEXT_PUBLIC_MENTOR_URL=http://localhost:3000
NEXT_PUBLIC_MENTOR_IFRAME_URL=http://localhost:3000

# Feature flags
NEXT_PUBLIC_IBL_PLATFORM=mentor
NEXT_PUBLIC_IBL_TEMPLATE_MENTOR=ai-mentor
NEXT_PUBLIC_IBL_ALLOW_FREE_TRIAL_BANNER=true
NEXT_PUBLIC_STRIPE_ENABLED=false
NEXT_PUBLIC_ENABLE_ADVERTISING=false

NEXT_PUBLIC_API_BASE_URL points at the consolidated ibl.ai API gateway โ€” the SDK derives /lms, /dm, and /axd path prefixes from it, so you don't need to set NEXT_PUBLIC_LMS_URL, NEXT_PUBLIC_DM_URL, or NEXT_PUBLIC_AXD_URL separately unless you're targeting a self-hosted stack with distinct subdomains.

4. Start the dev server

pnpm dev

Open http://localhost:3000 in your browser.

Node.js 25+ note: The dev script already includes --no-experimental-webstorage to prevent conflicts with the SDK's browser storage guards. If you customize your scripts, make sure to include NODE_OPTIONS='--no-experimental-webstorage'.


Scripts

ScriptDescription
pnpm devStart development server (port 3000)
pnpm buildProduction build (standalone output)
pnpm startStart production server via server-wrapper.js
pnpm lintRun ESLint with --fix, then typecheck
pnpm lint:checkLint without auto-fix (CI mode)
pnpm typecheckTypeScript type checking (tsc --noEmit)
pnpm formatFormat code with Prettier
pnpm format:checkPrettier check without writing (CI mode)
pnpm format-lintRun format then lint
pnpm testRun unit tests (Vitest)
pnpm test:watchRun tests in watch mode
pnpm test:coverageGenerate test coverage report
pnpm test:uiVitest UI runner
pnpm test:e2ePlaywright end-to-end (seeds empty .auth fixtures)
pnpm test:e2e:uiPlaywright UI runner
pnpm test:e2e:headedPlaywright in a visible browser
pnpm tauri:devStart Tauri desktop dev mode
pnpm tauri:buildBuild Tauri desktop app
pnpm tauri:build:debugTauri debug build (sourcemaps, faster)
pnpm releaseCut a release via release-it
pnpm prepareInstall husky hooks (runs on pnpm install)

Testing

pnpm test              # unit tests (Vitest)
pnpm test:watch        # watch mode
pnpm test:coverage     # coverage report
pnpm test:e2e          # Playwright end-to-end
pnpm test:e2e:ui       # Playwright UI runner
pnpm test:e2e:headed   # run in a visible browser

pnpm test:e2e auto-seeds empty Playwright auth fixtures under playwright/.auth/ before running โ€” no manual setup needed.


Architecture

os/
โ”œโ”€โ”€ app/                        # Next.js App Router
โ”‚   โ”œโ”€โ”€ platform/               # Main authenticated routes
โ”‚   โ”‚   โ””โ”€โ”€ [tenantKey]/        # Multi-tenant routing (mentor pages nest below)
โ”‚   โ”œโ”€โ”€ create-mentor/          # Mentor creation wizard
โ”‚   โ”œโ”€โ”€ share/                  # Public shared chats
โ”‚   โ”œโ”€โ”€ reports/                # Analytics report export
โ”‚   โ”œโ”€โ”€ provider-association/   # Stripe / OAuth provider linking
โ”‚   โ”œโ”€โ”€ google-oauth-callback/  # Google OAuth return
โ”‚   โ”œโ”€โ”€ sso-login/              # SSO entry
โ”‚   โ”œโ”€โ”€ sso-login-complete/     # SSO callback
โ”‚   โ”œโ”€โ”€ mobile-sso-login/       # Mobile-specific SSO entry
โ”‚   โ”œโ”€โ”€ mobile/                 # Touch-optimized mobile routes
โ”‚   โ”œโ”€โ”€ uploads/                # File upload preview
โ”‚   โ”œโ”€โ”€ error/                  # Branded error pages (404, 500, โ€ฆ)
โ”‚   โ”œโ”€โ”€ version/                # Build info endpoint
โ”‚   โ””โ”€โ”€ api/                    # API routes (auth-redirect, health)
โ”‚
โ”œโ”€โ”€ components/                 # React components
โ”‚   โ”œโ”€โ”€ ui/                     # 54 shadcn/ui primitives
โ”‚   โ”œโ”€โ”€ chat/                   # Chat message rendering
โ”‚   โ”œโ”€โ”€ advanced-chat/          # Advanced chat builder + tabs
โ”‚   โ”œโ”€โ”€ chat-input-form/        # Input controls (voice, search, upload)
โ”‚   โ”œโ”€โ”€ canvas/                 # Document canvas (artifacts)
โ”‚   โ”œโ”€โ”€ header/                 # Top app bar
โ”‚   โ”œโ”€โ”€ sidebar/                # Nav + project switcher
โ”‚   โ”œโ”€โ”€ mentors/                # Mentor cards, lists, picker
โ”‚   โ”œโ”€โ”€ modals/                 # All modal dialogs
โ”‚   โ”‚   โ””โ”€โ”€ edit-mentor-modal/  # Mentor settings (LLM, datasets, access, โ€ฆ)
โ”‚   โ”œโ”€โ”€ projects/               # Project management
โ”‚   โ”œโ”€โ”€ welcome-chat/           # Landing / welcome screen
โ”‚   โ”œโ”€โ”€ workflows/              # Workflow builder UI
โ”‚   โ”œโ”€โ”€ markdown/               # Markdown + code renderers
โ”‚   โ”œโ”€โ”€ model-download/         # Local LLM download UI (Tauri)
โ”‚   โ”œโ”€โ”€ top-trial-banner/       # Free-trial / billing banners
โ”‚   โ”œโ”€โ”€ icons/                  # Custom icons
โ”‚   โ””โ”€โ”€ accessibility/          # A11y helpers
โ”‚
โ”œโ”€โ”€ features/                   # Feature modules (state + logic) โ€” 13 modules
โ”‚   โ”œโ”€โ”€ analytics/              # Analytics logic
โ”‚   โ”œโ”€โ”€ auth/                   # Auth slice
โ”‚   โ”œโ”€โ”€ chat/                   # Chat state machine
โ”‚   โ”œโ”€โ”€ chat-input/             # Input model
โ”‚   โ”œโ”€โ”€ mentors/                # Mentor CRUD
โ”‚   โ”œโ”€โ”€ messages/               # Message normalization
โ”‚   โ”œโ”€โ”€ navigation/             # Sidebar + route state
โ”‚   โ”œโ”€โ”€ provider-association/   # Stripe / OAuth flow
โ”‚   โ”œโ”€โ”€ rbac/                   # Role-based access control
โ”‚   โ”œโ”€โ”€ subscription/           # Billing & subscription
โ”‚   โ”œโ”€โ”€ tenants/                # Multi-tenant routing helpers
โ”‚   โ”œโ”€โ”€ top-banner/             # Banner copy + visibility rules
โ”‚   โ””โ”€โ”€ users/                  # User CRUD + invites
โ”‚
โ”œโ”€โ”€ hooks/                      # 151 custom React hooks
โ”‚   โ”œโ”€โ”€ use-voice-chat.ts       # LiveKit voice integration
โ”‚   โ”œโ”€โ”€ use-mentors.ts          # Mentor CRUD operations
โ”‚   โ”œโ”€โ”€ use-history.ts          # Chat history management
โ”‚   โ”œโ”€โ”€ use-datasets.ts         # Training data management
โ”‚   โ”œโ”€โ”€ subscription/           # Subscription hooks
โ”‚   โ””โ”€โ”€ ...
โ”‚
โ”œโ”€โ”€ lib/                        # Utilities and configuration
โ”œโ”€โ”€ providers/                  # React context providers
โ”œโ”€โ”€ store/                      # Redux store setup
โ”œโ”€โ”€ styles/                     # Global CSS
โ”œโ”€โ”€ public/                     # Static assets (LLM provider logos, fonts, env.js)
โ”œโ”€โ”€ src-tauri/                  # Tauri desktop app (Rust)
โ”œโ”€โ”€ url-routes/                 # Centralized route constants used by app + tauri shell
โ”œโ”€โ”€ scripts/                    # Build / release helpers (post-build, etc.)
โ””โ”€โ”€ docs/                       # Internal documentation

Data Flow

User โ†’ React Components โ†’ Custom Hooks โ†’ Redux (RTK Query) โ†’ ibl.ai API
                                              โ†“
                                        @iblai/iblai-js SDK
                                        โ”œโ”€โ”€ /data-layer  (API slices, reducers)
                                        โ”œโ”€โ”€ /web-utils   (auth, providers, chat hooks)
                                        โ””โ”€โ”€ /web-containers (shared UI components)

The app uses @iblai/iblai-js as its unified SDK, which bundles the data layer, authentication utilities, and shared components under a single package.


Configuration

Environment Variables

VariableRequiredDescription
NEXT_PUBLIC_AUTH_URLYesAuthentication service URL (e.g. https://login.iblai.app)
NEXT_PUBLIC_API_BASE_URLYesConsolidated API gateway base (e.g. https://api.iblai.app) โ€” the SDK appends /lms, /dm, /axd
NEXT_PUBLIC_LEGACY_LMS_URLNoDirect LMS host for asset URLs that can't be proxied (e.g. https://learn.iblai.app)
NEXT_PUBLIC_LMS_URLNoOverride LMS path; defaults to ${API_BASE}/lms
NEXT_PUBLIC_DM_URLNoOverride DM path; defaults to ${API_BASE}/dm
NEXT_PUBLIC_AXD_URLNoOverride AXD path; defaults to ${API_BASE}/axd
NEXT_PUBLIC_MAIN_TENANT_KEYYesPrimary tenant identifier
NEXT_PUBLIC_BASE_WS_URLYesWebSocket server URL
NEXT_PUBLIC_IBL_LIVE_KIT_SERVER_URLYesLiveKit voice server URL
NEXT_PUBLIC_MENTOR_URLYesThis app's public URL
NEXT_PUBLIC_IBL_PLATFORMYesPlatform type (mentor)
NEXT_PUBLIC_IBL_TEMPLATE_MENTORYesDefault mentor template slug
NEXT_PUBLIC_STRIPE_ENABLEDNoEnable Stripe billing (true/false)
NEXT_PUBLIC_IBL_ALLOW_FREE_TRIAL_BANNERNoShow free trial banner
NEXT_PUBLIC_ENABLE_ADVERTISINGNoEnable advertising features
NEXT_PUBLIC_ENABLE_RBACNoEnable RBAC permission checks
NEXT_PUBLIC_EXTERNAL_PRICING_PAGE_URLNoExternal pricing page URL
NEXT_PUBLIC_HIDE_ANALYTICSNoHide the analytics surface entirely
NEXT_PUBLIC_DISABLED_DATASETSNoPipe-separated dataset types to hide (e.g. zip|courses)
NEXT_PUBLIC_DISABLED_ANALYTICS_REPORTSNoPipe-separated analytics reports to hide
NEXT_PUBLIC_MENTOR_TRAINING_MAXIMUM_FILE_SIZENoMax dataset upload size in MB
NEXT_PUBLIC_MAXIMUM_CHARACTER_SIZE_TO_COPYNoMax pasted characters before text becomes a .txt upload
NEXT_PUBLIC_SHOW_BASE_MENTORNoShow the base/template mentor in the picker
NEXT_PUBLIC_MENTOR_SETTINGS_DISCLAIMERNoDisclaimer line shown under mentor settings
NEXT_PUBLIC_ENABLE_GRAVATAR_ON_PROFILE_PICNoFall back to Gravatar when no profile pic
NEXT_PUBLIC_DEFAULT_EMBED_CSS_URLNoCSS injected into iframe embeds
NEXT_PUBLIC_IBL_ENABLE_SPECIAL_LOGO_WHEN_IFRAMEDNoSwap the logo when running inside an iframe
NEXT_PUBLIC_IFRAME_FROM_OLD_MENTORNoLegacy mentor URL allowed to iframe this app
NEXT_PUBLIC_HELP_CENTER_URLNoHelp center link in the UI
NEXT_PUBLIC_SUPPORT_EMAILNoSupport email shown in dialogs
NEXT_PUBLIC_APP_BANNER_TEXTNoTop app banner copy
NEXT_PUBLIC_APP_BANNER_LINKNoBanner click-through URL
NEXT_PUBLIC_APP_BANNER_LINK_TEXTNoBanner CTA text
NEXT_PUBLIC_APP_BANNER_BADGENoSmall badge label next to the banner
NEXT_PUBLIC_SHOW_APP_BANNERNoToggle the top banner
NEXT_PUBLIC_PLATFORM_BASE_DOMAINNoBrand domain (defaults to iblai.app)
NEXT_PUBLIC_BASE_PATHNoURL base path for subdirectory deployments
NEXT_IMAGE_PATTERNSNoComma-separated allowed image hosts
NEXT_PUBLIC_IBL_SENTRY_DSNNoSentry DSN for client-side error reporting
SENTRY_AUTH_TOKENNoSentry auth token (build-time only)

Feature Flags

Feature flags are set via environment variables prefixed with NEXT_PUBLIC_. They control which features are visible and active in the application:

  • Stripe billing โ€” NEXT_PUBLIC_STRIPE_ENABLED=true
  • Free trial banner โ€” NEXT_PUBLIC_IBL_ALLOW_FREE_TRIAL_BANNER=true
  • Advertising โ€” NEXT_PUBLIC_ENABLE_ADVERTISING=true
  • RBAC โ€” NEXT_PUBLIC_ENABLE_RBAC=true
  • Iframe logo โ€” NEXT_PUBLIC_IBL_ENABLE_SPECIAL_LOGO_WHEN_IFRAMED=true

Sentry

OS wires Sentry via sentry.client.config.ts, sentry.server.config.ts, and sentry.edge.config.ts at the repo root. Two env vars control it:

  • NEXT_PUBLIC_IBL_SENTRY_DSN โ€” runtime DSN for client/server error reporting. Leave empty to disable.
  • SENTRY_AUTH_TOKEN โ€” build-time only; lets next build upload source maps so stack traces stay readable in production. Without it the build still succeeds, just with minified frames in Sentry.

SDK version pin

The exact @iblai/iblai-js version this app is tested against lives in .iblai-js-version. The pre-push hook checks package.json against it; bump both when you intentionally move SDK versions, otherwise leave it alone.


Tech Stack

LayerTechnology
FrameworkNext.js 15, React 19, TypeScript
StylingTailwind CSS 4, Radix UI, shadcn/ui
StateRedux Toolkit, React-Redux
FormsReact Hook Form, Zod
EditorTiptap (rich text), Markdown (react-markdown, remark, rehype)
Voice/VideoLiveKit (WebRTC)
ChartsRecharts
DesktopTauri 2 (Rust + WebView)
TestingVitest, Testing Library, Playwright
MonitoringSentry
SDK@iblai/iblai-js (version pinned in .iblai-js-version)

AGENTS.md

AGENTS.md at the repo root documents the formatting, lint, and push-protocol rules that automated agents (Claude Code, OpenCode, etc.) follow when editing this codebase. Read it before you start contributing โ€” it's also what the husky hooks enforce. CLAUDE.md is a symlink to it for tools that still look for that filename.

The skills it references live under .claude/skills/:


Built With

  • Next.js โ€” App Router
  • @iblai/iblai-js โ€” SDK for auth, UI components, and data
  • @iblai/data-layer โ€” RTK Query data layer
  • @iblai/web-containers โ€” framework-agnostic SDK components
  • LiveKit โ€” WebRTC transport for real-time voice and video sessions
  • Tailwind CSS โ€” utility-first styling with ibl.ai design tokens
  • shadcn/ui โ€” accessible UI primitives
  • Tauri 2 โ€” desktop and mobile shell (Rust + WebView)
  • Sentry โ€” error monitoring and source maps
  • iblai.app โ€” production backend for auth, AI agents, billing, and analytics

Copyright ยฉ ibl.ai | support@iblai.zendesk.com