This document explains how to set up and run the AI Reskilling Platform locally and in production, and provides a complete reference for every environment variable the platform reads.
| Requirement | Version |
|---|---|
| Node.js | 20 or later |
| npm | 10 or later (bundled with Node 20) |
No other runtime or containerisation tool is required. The website runs with npm run dev. Background jobs need a second terminal: npm run sidequest.
git clone <repository-url>
cd <repository-folder>
npm install
Copy or create a .env file at the project root (see the environment variable reference below) and then start the development server:
npm run dev
In a second terminal, start the Sidequest job worker (required for index refresh / on-save validation after content edits):
npm run sidequest
Worker liveness: data/sidequest.pid (written by npm run sidequest). Check with systemctl status website-sidequest in prod.
Site YAML content is not in this repository. Each domain in sites.yml maps to a gitignored folder under the project root.
Local development: copy the template to create your registry:
cp sites.yml.example sites.yml
Edit sites.yml with your domain(s) and content folder names. The file is gitignored — it is local runtime config, not platform source code.
Production: the canonical sites.yml is stored in GCS at multisite-global/sites.yml (requires GCS_BUCKET_NAME). Site Manager updates are persisted there automatically. On first deploy with GCS enabled, the server seeds GCS from a local/git copy if the bucket object does not exist yet.
Before the dev server starts, npm run dev runs check:sites, which:
- Verifies each configured folder exists and has the required scaffold (
settings.yml,content-types.yml,image-registry.json,custom-redirects.yml, plusimages/,menus/, andpages/). - If a folder is missing or incomplete and the site has a
github_repo_urlinsites.yml, automatically downloads content from GitHub whenGITHUB_TOKENis set in.env(does not requireGITHUB_SYNC_ENABLED). - If the remote repo has no content for that site folder, prompts interactively to create a simple local scaffold (syncs via GitHub sync when enabled).
- Exits with an error if folders are still invalid — for example when
GITHUB_TOKENis absent and content has not been populated manually.
You can run the check alone with npm run check:sites.
Tracked shared/schema.ts re-exports Zod schemas from gitignored site_*/component-registry/**/schema.ts. If the app repo moves ahead of your local content (missing named export), boot and build fail before the Sync UI or startup auto-pull can run.
npm run check:registry— verify those imports; prints recovery steps on failure.npm run content:pull— hash-diff pull all sites from GitHub without starting the server (--forcefor a full re-download). NeedsGITHUB_TOKENandgithub_repo_urlinsites.yml(does not requireGITHUB_SYNC_ENABLED).npm run ensure:registry— check first; on failure, pull content then re-check. Wired intopredevandprebuild.npm run ensure:schema-yml— checkschema.ts↔schema.ymlvariant drift and shared/site type collisions; on failure, runschema:syncthen re-check. Wired intopredevandprebuild. Does not push to the content GitHub.
Once the server is up, GitHub Sync in the Debug bubble still works for day-to-day content sync.
The command starts two processes in parallel:
- Express backend — handles API routes, content serving, and GitHub/GCS integrations.
- Vite frontend — serves the React client with hot module replacement.
Both are reachable on the same port (default 5000). Open http://localhost:5000 in a browser.
Set NODE_ENV=production before starting. The Vite frontend is compiled to static files and served by the Express backend — no separate Vite process runs.
NODE_ENV=production npm run build
NODE_ENV=production npm start
Key variables you must configure for a production deployment:
SITE_URL— the canonical base URL (e.g.https://www.example.com). Used for sitemaps, hreflang tags, canonical URLs, and GitHub webhook registration.PORT— the port the server listens on (default5000).GITHUB_SYNC_ENABLED=trueand the full GitHub variable group if you want content edits committed back to the repository.GCS_BUCKET_NAMEand the full GCS variable group if media should be stored in Google Cloud Storage instead of the local filesystem.OPENROUTER_API_KEYif AI-powered features such as field mapping or the chat assistant should be available.
Variables are listed by category. "Required" means the feature that depends on the variable will be unavailable or will exit fatally if the variable is missing.
| Variable | Required | Default | Description | Features enabled | Extra config needed |
|---|---|---|---|---|---|
PORT |
No | 5000 |
TCP port the Express server listens on. | Core server | None |
NODE_ENV |
No | development |
Set to production to serve compiled static assets, enable secure cookies, and suppress development-only behaviour. |
All production hardening | None |
SITE_URL |
No | http://localhost:5000 (dev) |
Canonical base URL with no trailing slash (e.g. https://www.example.com). Falls back to http://localhost:5000 when unset. Used for sitemaps, hreflang, canonical meta tags, and GitHub webhook registration. |
Sitemap, SEO canonical URLs, GitHub webhook auto-registration | None |
When you run npx caxton-cms (or a globally linked caxton-cms), the engine and the site folder can live in different directories. Leave these unset in a normal monorepo checkout (npm run dev / npm run caxton from the repo root).
| Variable | Required | Default | Description | Features enabled | Extra config needed |
|---|---|---|---|---|---|
WEBLIFY_PROJECT_ROOT |
No | process.cwd() |
Absolute path to the site project (sites.yml, site_*, .env, data/, .cache/, .local/). Set in the shell when the site is not your current directory, e.g. WEBLIFY_PROJECT_ROOT=/path/to/my-site npx caxton-cms. The CLI loads .env from this directory, so putting the var only inside that .env cannot retarget create/resume from elsewhere. |
npx caxton-cms / linked CLI against a non-cwd site |
Site folder with sites.yml (or empty folder to create) |
WEBLIFY_PACKAGE_ROOT |
No | Directory of the installed Caxton package | Absolute path to the engine (server, client, shared, dist/). Rare override for unusual installs. |
Force engine path when package resolution is wrong | Built/installable Caxton tree |
WEBLIFY_ALLOW_CONNECTION_TOKEN_STAFF |
No | unset (off) | Dev only. When GitHub staff login is available, set to 1 to allow connection-token staff paste again on a non-production machine. Ignored in production; if set while NODE_ENV/WEBLIFY_MODE/--production is production, the process refuses to start. See docs/local-connection-token.md. |
Local connection-token staff login | npx caxton-cms token --user <name> |
WEBLIFY_CONNECTION_OWNER |
No | .local/connection-owner |
Local bootstrap username for the connection token (same as the file written by caxton-cms token). |
Connection-token staff/MCP identity | docs/local-connection-token.md |
| Variable | Required | Default | Description | Features enabled | Extra config needed |
|---|---|---|---|---|---|
VITE_BREATHECODE_HOST |
No | https://breathecode.herokuapp.com |
Base URL for the 4Geeks Breathecode REST API. Available on both server and client because of the VITE_ prefix. Used for consumer login/signup and program data — not for staff CMS login. |
Breathecode data fetching (programs, consumer auth) | None |
BREATHECODE_HOST |
No | https://breathecode.herokuapp.com |
Same host for server-side consumer auth proxies. | Consumer auth API | None |
IPAPI_PRO_KEY |
No | — | API key for ipapi.pro, used to geo-locate visitors and redirect them to a locale-appropriate page. Only used on the live server; dev and preview builds use the free endpoint. | IP-based locale detection | Register at ipapi.pro |
TURNSTILE_SITE_KEY |
No | — | Cloudflare Turnstile public site key, embedded in the lead-capture form. | Bot-protection on lead forms | Must also set TURNSTILE_SECRET_KEY |
TURNSTILE_SECRET_KEY |
No | — | Cloudflare Turnstile secret key, validated server-side. | Bot-protection on lead forms | Must also set TURNSTILE_SITE_KEY |
CLOUDFLARE_ACCOUNT_ID |
No* | — | Cloudflare account id for Browser Run /screenshot (entry-preview OG images). Env only — never stored in settings.yml. SEO/GEO → OG Image shows configured status. |
Server-side OG / entry-preview capture | CLOUDFLARE_API_TOKEN, public SITE_URL |
CLOUDFLARE_API_TOKEN |
No* | — | API token with Browser Rendering - Edit. Env only — never stored in settings.yml. |
Server-side OG / entry-preview capture | CLOUDFLARE_ACCOUNT_ID, public SITE_URL |
ENTRY_PREVIEW_CAPTURE_SECRET |
No | SESSION_SECRET |
HMAC secret for signed capture frame URLs opened by Cloudflare. Env only (then SESSION_SECRET). Prefer a dedicated secret in production. |
Entry-preview capture auth | Public SITE_URL; staff status UI at SEO/GEO → OG Image |
IPN_SECRET |
No* | — | Shared secret for the IP Normalization proxy (X-IPN-Token). Env only — never stored in settings.yml. Tracking → IP Normalization shows configured status and can Generate & copy (does not save). |
/ipn/{id}/* egress proxy |
Enable + destinations in settings; same value as GTM server Constant |
GOOGLE_PSI_API_KEY |
No | — | Deprecated for in-app diagnostics (Lighthouse/PSI UI removed). Use external Lighthouse/PageSpeed tools. | — | — |
The platform uses an OpenAI-compatible API client pointed at OpenRouter. Which API key and base URL it reads is controlled by site_*/llm.yml via the provider.api_key_env and provider.base_url_env fields. Set OPENROUTER_API_KEY (and optionally OPENROUTER_BASE_URL) in the environment.
# site_*/llm.yml (current defaults)
provider:
api_key_env: OPENROUTER_API_KEY
base_url_env: OPENROUTER_BASE_URL
model:
default: openai/gpt-4o-mini
chat: openai/gpt-4o
vision: openai/gpt-4oChoose the completion model in Debug Bubble → AI & Agents → AI Settings (/private/settings/ai/llms); saving writes model.default in llm.yml. Chat and vision models are configured separately (model.chat / model.vision, or the Knowledge Editor for chat).
If you change api_key_env or base_url_env in llm.yml, the server reads the named environment variables instead. The table below covers all variable names the code can read.
| Variable | Required | Default | Description | Features enabled | Extra config needed |
|---|---|---|---|---|---|
OPENROUTER_API_KEY |
No* | — | API key for OpenRouter. This is the variable currently named in llm.yml under provider.api_key_env. |
Field mapping, chat assistant, vision tagging | OpenRouter account at openrouter.ai |
OPENROUTER_BASE_URL |
No | https://openrouter.ai/api/v1 |
Base URL for the OpenRouter API. Soft-defaulted in code when unset and llm.yml names this env var. |
Routing LLM calls to OpenRouter | None |
LLM_MODEL |
No | Value from llm.yml (model.default), currently openai/gpt-4o-mini |
Overrides the default LLM model for all non-chat completions. Env var takes precedence over llm.yml. Prefer AI Settings over this env var. |
Model selection for field mapping and meta generation | None |
LLM_CHAT_MODEL |
No | Falls back to LLM_MODEL |
Overrides the LLM model used specifically for the chat assistant. Env var takes precedence over llm.yml (model.chat). |
Model selection for the chat assistant | None |
*A valid API key must be set for the LLM provider named in llm.yml. With the default configuration that means OPENROUTER_API_KEY.
Environment variables always take precedence over llm.yml for model overrides. Changing the provider, model, temperature, or token limit in llm.yml does not require a server restart — the file is reloaded on the next request when its modification time changes.
GitHub sync lets content editors commit YAML edits back to the repository automatically and pull remote changes into the running server. All five variables must be set together for the feature to work.
| Variable | Required | Default | Description | Features enabled | Extra config needed |
|---|---|---|---|---|---|
GITHUB_SYNC_ENABLED |
No | false |
Set to true to activate the GitHub sync subsystem. Acts as a master switch — other GitHub variables are ignored when this is false. |
GitHub content sync (commit & pull) | All other GITHUB_* variables |
GITHUB_TOKEN |
No* | — | Service token for pulls, webhooks, bootstrap, and local/dev commits. Prefer a fine-grained PAT with Contents read/write on the content repo. In production, staff commits use GitHub Connect (below), not this token. | Pulls / system / local commits | GITHUB_SYNC_ENABLED=true, GITHUB_REPO_URL |
GITHUB_REPO_URL |
No* | — | Full URL of the GitHub repository (e.g. https://github.com/owner/repo). .git suffix is optional. |
Repository targeting for all sync operations | GITHUB_SYNC_ENABLED=true, GITHUB_TOKEN |
GITHUB_BRANCH |
No | main |
Branch to read from and commit to. | Branch targeting for sync operations | GITHUB_SYNC_ENABLED=true |
GITHUB_AUTO_COMMIT_ENABLED |
No | false |
Set to true to automatically commit local content changes to GitHub when files are saved. Requires GITHUB_SYNC_ENABLED=true. |
Automatic commit on save | GITHUB_SYNC_ENABLED=true |
GITHUB_AUTO_PULL_ENABLED |
No | false |
Set to true to automatically pull remote changes from GitHub into the running server (triggered by a GitHub webhook). Requires GITHUB_SYNC_ENABLED=true and a registered webhook (auto-registered when SITE_URL is set). |
Webhook-driven content pull | GITHUB_SYNC_ENABLED=true, SITE_URL |
GITHUB_APP_CLIENT_ID |
No* | — | GitHub App client ID for staff login OAuth and content Connect. Required for staff sign-in and for production content commits. | Staff auth + per-user content commits | App Email permission Read; production |
GITHUB_APP_CLIENT_SECRET |
No* | — | GitHub App client secret. | OAuth code exchange | GITHUB_APP_CLIENT_ID |
GITHUB_APP_SLUG |
No* | — | GitHub App slug (for install/docs URLs). | Connect setup | GITHUB_APP_CLIENT_ID |
GITHUB_CONNECT_REQUIRED |
No | false |
Set to true to force Connect for user commits even outside production (local testing). Still requires GITHUB_SYNC_ENABLED=true. |
Dev Connect UI / commit gate | GITHUB_SYNC_ENABLED=true, App env |
MCP_PUBLIC_URL |
No | http://127.0.0.1:$MCP_PORT |
Public base URL of the MCP process (for OAuth return after GitHub staff login). | MCP GitHub login return | MCP_PORT |
Staff auth connectors vs GitHub content Connect: Staff sign in through pluggable OAuth connectors (v1: GitHub only) and receive an owned staff session (7-day opaque token). Only pre-registered emails (Security → Pre-register) or the first admin bootstrap can get a session; verified GitHub email is required. Staff may paste an existing staff session token. Separately, GitHub Connect on the sync chip stores a commit token for content repo push — login can succeed without repo write. Create a GitHub App with Account permissions → Email addresses: Read and Repository Contents: Read and write, callback ${SITE_URL}/api/github/oauth/callback, and set GITHUB_APP_*. Sessions: data/staff-sessions.json; commit tokens: data/github-user-tokens.json (+ GCS when encryption is enabled).
GitHub Connect (content): After staff login, Connect binds the GitHub user token for production commits. Local/dev may still use GITHUB_TOKEN unless GITHUB_CONNECT_REQUIRED=true.
When GCS is configured, uploaded media is stored in a GCS bucket instead of the local 4geeks-com/images/ directory. GCS_BUCKET_NAME is the only variable that activates GCS; the rest refine how the client authenticates.
| Variable | Required | Default | Description | Features enabled | Extra config needed |
|---|---|---|---|---|---|
GCS_BUCKET_NAME |
No* | — | Name of the GCS bucket (e.g. my-project-media). Setting this variable activates GCS for all media operations. |
GCS media storage | Service-account credentials via GCS_KEY_FILENAME or GCS_CREDENTIALS_JSON |
GCS_PROJECT_ID |
No | Auto-detected by the GCS SDK | Google Cloud project ID. Required only when the SDK cannot determine the project from the service-account credentials. | GCS authentication | GCS_BUCKET_NAME |
GCS_KEY_FILENAME |
No | — | Filesystem path to a service-account JSON key file. Use this or GCS_CREDENTIALS_JSON, not both. |
GCS authentication via key file | GCS_BUCKET_NAME |
GCS_CREDENTIALS_JSON |
No | — | Inline JSON string of the service-account credentials object. Use this or GCS_KEY_FILENAME, not both. Useful in environments where writing key files to disk is not practical. |
GCS authentication via inline credentials | GCS_BUCKET_NAME |
GCS_BASE_PATH |
No | media |
Key prefix (folder path) inside the bucket where media files are stored. | GCS path organisation | GCS_BUCKET_NAME |
MEDIA_DEFAULT_PROVIDER |
No | local |
Set to gcs to route all new media uploads to GCS by default. Set to local to keep files on the local filesystem even when GCS is available. |
Media provider routing | GCS_BUCKET_NAME when set to gcs |
The MCP (Model Context Protocol) server is a separate process that exposes content tools to AI coding assistants. It runs on its own port and is proxied through the main Express server so that it is reachable without opening an additional firewall port. The MCP server is optional — the main application works without it.
| Variable | Required | Default | Description | Features enabled | Extra config needed |
|---|---|---|---|---|---|
MCP_PORT |
No | 3001 |
Port the MCP server listens on internally. Requests are proxied from the main server's port, so this port does not need to be public. | MCP server internal port | None |
MCP_API_KEY |
Yes (for MCP) | — | Secret key that MCP clients must supply as a Bearer token to access the MCP endpoints. The MCP server exits immediately at startup if this is not set. | MCP tool access control | None |
OAUTH_CLIENT_ID |
No | — | Static OAuth client ID used for pre-registered MCP clients. When set, MCP clients can use this known ID without registering dynamically. | Static OAuth client support | Must also set OAUTH_CLIENT_SECRET |
OAUTH_CLIENT_SECRET |
No | — | Static OAuth client secret corresponding to OAUTH_CLIENT_ID. |
Static OAuth client support | Must also set OAUTH_CLIENT_ID |
| Variable | Required | Default | Description | Features enabled | Extra config needed |
|---|---|---|---|---|---|
DEBUG_CROP_RESIZE |
No | — | Set to any non-empty value to enable verbose logging for image crop and resize operations in the image processing pipeline. | Debug output for image processing | None |
These variables are embedded into the frontend bundle at build time by Vite. They must be prefixed with VITE_ to be accessible in browser code via import.meta.env.
| Variable | Required | Default | Description | Features enabled | Extra config needed |
|---|---|---|---|---|---|
VITE_BREATHECODE_HOST |
No | https://breathecode.herokuapp.com |
Base URL for the Breathecode API as seen by the browser (consumer forms). | Client-side Breathecode API calls | None |
Staff CMS login no longer uses VITE_BREATHECODE_TOKEN. Use Log in with GitHub in DebugBubble (or paste a staff session).
The MCP server exposes the platform's content management tools to AI coding assistants (such as Cursor or Claude) via the Model Context Protocol. It must be started separately from the main application:
npm run mcp
The server starts on MCP_PORT (default 3001) and is accessible through the main server at /mcp/* — the main Express process proxies those paths automatically, so clients only need to reach the main port.
Authentication: MCP OAuth uses the same staff auth as the CMS (GitHub login or paste staff session). Direct Bearer tokens must be owned staff sessions (or MCP access tokens issued after OAuth), not Breathecode tokens.
OAuth: Authorisation-code flow for AI assistants. Humans verify with GitHub (via the CMS) or by pasting a staff session. Pre-registered static clients: OAUTH_CLIENT_ID / OAUTH_CLIENT_SECRET; dynamic registration at /oauth/register.
Public URL: Set SITE_URL for the CMS (GitHub App callback). For MCP return after GitHub login, set MCP_PUBLIC_URL when the MCP origin is not http://127.0.0.1:$MCP_PORT.