Skip to content

Latest commit

 

History

History
262 lines (168 loc) · 16.4 KB

environment.md

File metadata and controls

262 lines (168 loc) · 16.4 KB

Development Environment Setup

This guide covers the local tooling, IDE configuration, environment variables, and editor extensions needed to work on the apps/web Next.js frontend inside OpenFrame OSS Frontend. It assumes you have already cloned the repository:

git clone https://github.com/flamingo-stack/openframe-oss-frontend.git
cd openframe-oss-frontend

For the first commands to run after cloning, see Local Development. This page focuses on preparing the machine and editor before you run anything.


Repository Shape

This is a monorepo with three application surfaces, each with its own toolchain:

App Path Stack
Web (primary) apps/web Next.js 16, React 19, TypeScript, Relay, Tailwind CSS
Desktop shell apps/desktop Tauri 2 (Rust) wrapping the web export
Mobile shell apps/mobile Capacitor wrapping the web export

The web app consumes @flamingo-stack/openframe-frontend-core (published by the OpenFrame OSS Library repository) as its component, hook, and ESLint-config library, and the desktop shell links async_nats from the NATS Rust Client repository for its background notification plane. Most day-to-day frontend development happens in apps/web; the desktop and mobile shells mainly package its static export, so this document emphasizes the web app's requirements while noting the native shells where relevant.


Required Development Tools

Node.js

The repository pins its Node.js version in .nvmrc at the repository root:

26

If you use nvm, run nvm use from the repository root to pick up this version automatically.

npm

Every package.json in the monorepo (apps/web/package.json, apps/mobile/package.json, apps/desktop/package.json) declares a devEngines.packageManager constraint:

"devEngines": {
  "packageManager": { "name": "npm", "version": ">=11.11.0", "onFail": "error" }
}

Running with an older npm fails fast (onFail: "error") rather than producing a confusing installation error later. Check your version with:

npm --version

and upgrade npm itself if it is older than 11.11.0.

Git Hooks (Husky)

apps/web/package.json runs husky from its prepare script:

"prepare": "cd ../.. && husky || true"

This installs the repository's pre-commit hook at .husky/pre-commit, which runs automatically once you npm install inside apps/web. The hook:

  • Scopes itself to staged *.ts, *.tsx, *.js, *.jsx, *.mjs, *.cjs files only.
  • Refuses to run against a file that is staged and has further unstaged edits, to avoid checking content that would not actually be committed.
  • Runs ESLint with eslint.ci.mjs (the same configuration CI enforces) and Prettier's --check against the staged files.
  • Runs tsc --noEmit and filters its output down to diagnostics that belong to the staged files.

Because this hook enforces the same checks as CI, keeping it enabled saves round-trips through a failed pull request.

TypeScript, ESLint, and Prettier

These are installed as devDependencies of apps/web/package.json rather than global tools, so no separate install step is required beyond npm install:

  • typescript 5.9.3
  • eslint 9.39.5 (flat config)
  • prettier 3.9.6
  • vitest 5.0.5 for unit tests

The ESLint and Prettier rule sets themselves are largely supplied by @flamingo-stack/openframe-frontend-core/eslint-config, re-exported and locally extended from apps/web/eslint.config.mjs and apps/web/prettier.config.mjs. You do not need to install these configs separately — they arrive with the pinned @flamingo-stack/openframe-frontend-core dependency.

Native Shell Toolchains (Only If You Touch Them)

Desktop shell (Tauri / Rust)

apps/desktop/src-tauri/Cargo.toml requires Rust 1.90 or newer (rust-version = "1.90"), driven by tauri-plugin-updater 2.14. The desktop app is built with apps/desktop/package.json's dev (tauri dev --no-dev-server) and build (tauri build) scripts, both of which shell out to the @tauri-apps/cli devDependency. Before dev, predev calls node scripts/make-placeholder-web.mjs --if-missing so Tauri has a web bundle to point at even before you have run a real web build.

Mobile shell (Capacitor)

apps/mobile wraps the openframe-frontend static export with no UI code of its own (see apps/mobile/package.json's description). Its Android project under apps/mobile/android is a standard Gradle project (apps/mobile/android/build.gradle, apps/mobile/android/app/build.gradle) that expects Android Studio's SDK/JDK toolchain; no additional repository-specific Android tooling is declared beyond the Gradle wrapper. An .editorconfig at apps/mobile/.editorconfig documents the expected indentation per language for this app (two-space TypeScript/JSON/YAML, four-space Java/Kotlin/Swift, LF line endings, trimmed trailing whitespace).


Installing Dependencies

From the web app directory:

cd apps/web
npm install

npm install triggers the prepare script, which installs the Husky git hook described above. The web app's package.json also pins a dependency override so next-runtime-env resolves next and react to the versions this repository uses, rather than its own peer range:

"overrides": {
  "next-runtime-env": { "next": "$next", "react": "$react" }
}

You do not need to do anything about this override — it is resolved automatically by npm install — but it explains why npm ls next-runtime-env may show a version that looks unusual compared to its own published peer dependencies.


IDE Recommendations And Setup

Recommended Editor: Visual Studio Code

The repository ships a committed VS Code workspace configuration under .vscode/, which is the strongest signal for the supported editor. Opening the repository root in VS Code picks these settings up automatically.

Workspace TypeScript Version

.vscode/settings.json pins the editor to the workspace's own TypeScript install rather than VS Code's bundled version:

"typescript.tsdk": "apps/web/node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true

This matters because apps/web/tsconfig.json sets strict TypeScript options (strict: true, isolatedModules: true, moduleResolution: bundler) and the Next.js TypeScript plugin, so using a mismatched bundled TypeScript version can produce diagnostics that do not match what npm run type-check reports. After opening the workspace, VS Code will usually prompt you to confirm using the workspace TypeScript version — accept it.

Format-on-Save and Lint-on-Save

.vscode/settings.json wires formatting and linting together deliberately:

"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" }

The settings file documents the reasoning inline: a formatter alone (formatOnSave) does not apply ESLint's autofixes, so both are wired as one combined save action. The source.fixAll.eslint action is written in the modern object form (not the deprecated array form VS Code has warned about since 1.85).

Import ordering is intentionally not handled by VS Code's built-in source.organizeImports action. It is an ESLint rule (perfectionist/sort-imports) applied by source.fixAll.eslint, and the comments in .vscode/settings.json explicitly warn against adding an organize-imports action, since the TypeScript server's own ordering would conflict with the rule and the two would fight on every save.

ESLint Scope And Working Directory

Because the web app's ESLint config and node_modules live under apps/web rather than at the workspace root, .vscode/settings.json scopes the ESLint extension accordingly:

"eslint.useFlatConfig": true,
"eslint.workingDirectories": [{ "directory": "apps/web", "changeProcessCWD": true }],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"]

The editor loads apps/web/eslint.config.mjs — the fast pass of rules. Type-aware rules (in eslint.types.mjs) are deliberately not run by the editor, because they require a full TypeScript program and a configured heap. Run npm run lint:types from apps/web before pushing to catch those.

Important: keep eslint.format.enable off. The settings file documents a real failure mode: with that setting on, the ESLint extension registers itself as a document formatter and "Format Document" silently runs eslint --fix instead of Prettier — producing no visible formatting change at all, because the shared config spreads eslint-config-prettier last, turning off every stylistic rule by design. This looks exactly like a broken format-on-save. .vscode/settings.json sets eslint.format.enable: false to prevent it.

Biome Is Retired

.vscode/settings.json explicitly disables Biome ("biome.enabled": false) and .vscode/extensions.json lists biomejs.biome under unwantedRecommendations. The project migrated off Biome on 2026-09-01; if you have a globally installed Biome VS Code extension, it is explicitly turned off for this workspace so it cannot format files against a configuration file that no longer exists.

Per-Language Formatter Bindings

.vscode/settings.json additionally binds Prettier as the default formatter for TypeScript, TSX, JavaScript, JSX, JSON, JSONC, and CSS individually ("[typescript]", "[typescriptreact]", etc.), so a global default formatter set elsewhere on your machine cannot override it for these languages inside this workspace.

Search Exclusions

.vscode/settings.json excludes **/dist and **/.next from workspace search, keeping build output out of your search results.


Editor Extensions / Plugins

The repository's .vscode/extensions.json declares the recommended and unwanted extensions for this workspace:

{
  "recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"],
  "unwantedRecommendations": ["biomejs.biome"]
}
Extension ID Purpose Status
esbenp.prettier-vscode Prettier formatting, wired as the default formatter for TS/TSX/JS/JSX/JSON/CSS Recommended
dbaeumer.vscode-eslint ESLint diagnostics and the source.fixAll.eslint save action Recommended
biomejs.biome Former formatter/linter, retired 2026-09-01 Explicitly unwanted

When you open the repository in VS Code, it will prompt you to install the two recommended extensions if they are missing. Install both before you start editing — without dbaeumer.vscode-eslint, source.fixAll.eslint has nothing to run, and without esbenp.prettier-vscode, format-on-save has no effect.

No other editor-specific configuration (e.g. for JetBrains IDEs or Vim/Neovim) is published in this repository; VS Code with the two extensions above is the supported baseline.


Environment Variables For Development

The web app documents its runtime environment variables in apps/web/.env.example. Copy it to a local .env (or .env.local) inside apps/web and adjust as needed:

cd apps/web
cp .env.example .env.local

All variables are read via next-runtime-env, so they are safe to change without rebuilding in most cases, but they are still public (NEXT_PUBLIC_*) and must never carry secrets.

Variable Purpose Local Dev Default / Notes
NEXT_PUBLIC_ENABLE_DEV_TICKET_OBSERVER Enables automatic devTicket detection and exchange for SSO authentication false; enable only when testing that SSO flow
NEXT_PUBLIC_AUTH_CHECK_INTERVAL How often (in milliseconds) authentication status is polled 60000 (1 minute)
NEXT_PUBLIC_APP_MODE Selects oss-tenant, saas-tenant, or saas-shared behavior oss-tenant for this repository
NEXT_PUBLIC_GTM_CONTAINER_ID Google Tag Manager container ID Unset for local dev
NEXT_PUBLIC_RECAPTCHA_SITE_KEY reCAPTCHA Enterprise public site key used by the edge firewall to score password signup/reset Unset is fine for OSS and local dev; a SaaS edge that enforces the check will refuse requests with no token
NEXT_PUBLIC_BREW_CASK Homebrew cask name used by the Add Device "Brew" install command (flamingo-stack/openframe tap) Unset defaults to openframe-client (production); use openframe-client@stage or openframe-client@dev on those environments
NEXT_PUBLIC_SUPABASE_HOST The hub's Supabase project host, used so its images load directly rather than through the image proxy Unset uses the build-time default in apps/web/next.config.mjs; set it only when pointing at a different Supabase project
NEXT_PUBLIC_FEATURE_SCRIPT_SCHEDULE Enables the script scheduling feature false
NEXT_PUBLIC_PR_NUMBER_ENABLED Shows a PR-number field on the signup form, linking registrations to a PR for testing false; enable only on dev environments, keep disabled on stage/prod

Two additional variables appear in apps/web/next.config.mjs and are relevant to local development, even though they are not listed in .env.example:

  • NEXT_PUBLIC_TENANT_HOST_URL — when set, next.config.mjs's rewrites() proxies /content/:path* calls to this tenant gateway at build time, so embedded chat works without a cross-origin workaround during next dev/next build. It is intentionally absent from the deployed Docker image build (its .env* is dockerignored), where the platform's reverse proxy answers /content/* directly instead.
  • OPENFRAME_BUILD_TARGET=export — not a runtime variable but a build-time selector; setting it (as npm run build:export does) switches the Next.js output mode from standalone to export for the native shells.

resolve_code_imports and the import-resolution review rule (IMPORT-001) both treat apps/web/.env.example as part of the dependency surface this repository is checked against — keep any new NEXT_PUBLIC_* variable you add there in sync with where it is actually read in code, and do not duplicate a variable's default in more than one place (per the repository's single-source-of-truth convention).

Mobile And Desktop Shell Variables

If you also build the native shells locally:

  • apps/mobile/scripts/inject-env.mjs requires NEXT_PUBLIC_SHARED_HOST_URL to be set — the script aborts the build if it is missing, because without it every auth/discovery call would resolve against capacitor://localhost instead of the shared auth host. Optional companions are NEXT_PUBLIC_TENANT_HOST_URL (pins a single tenant), NEXT_PUBLIC_MOBILE_APP_SCHEME (must match the native OAuth callback scheme compiled into the build you are testing against), and NEXT_PUBLIC_MOBILE_AUTH_UI (login-only or legacy).
  • apps/desktop/src-tauri/Cargo.toml's async-nats dependency is used by the desktop shell's background notification plane; no separate environment variable is required for local development beyond what the web export itself needs.

Verifying Your Setup

Once dependencies are installed and your editor is configured, confirm everything is wired correctly from apps/web:

npm run type-check
npm run lint
npm run test
  • type-check runs tsc --noEmit against the strict tsconfig.json.
  • lint runs the fast ESLint pass with --max-warnings 0.
  • test runs vitest run plus the Node-based tests under src/lib/*.test.mjs (test:node).

If any of these fail immediately after a clean clone, revisit the Node.js and npm versions above before assuming the code itself is broken — version mismatches are the most common cause of environment-only failures in this repository.

For the commands used to actually run the app day to day (npm run dev, the GraphQL schema fetch, Relay compilation, and so on), continue to Local Development.