A modern React-based frontend application with Fastify backend for interacting with data through natural language queries via Template Agent. The application features SSO authentication, real-time streaming responses, and a clean chat interface.
- Node.js >= 22.0.0
- npm >= 8.0.0
-
Clone the repository
git clone https://github.com/redhat-data-and-ai/template-ui.git cd template-ui -
Install dependencies
npm install
-
Set up environment variables
cp env.template .env
Edit
.envand configure the required variables (see Environment Configuration below). -
Start development server
npm run dev
The application will be available at http://localhost:5173
Template UI supports runtime configuration for branding (logo, colors, title), feature flags, agent endpoint, and compliance policies β without code changes or rebuilds.
Full documentation: docs/deployment-patterns.md
Copy one of the ready-made example configs to get started:
# Local development (auth off, debug panel open)
cp config/ui/examples/minimal.yaml config/ui/settings.yaml
# Blue color scheme
cp config/ui/examples/blue-theme.yaml config/ui/settings.yaml
# Red Hat branding
cp config/ui/examples/red-hat-branding.yaml config/ui/settings.yaml
# Production-hardened (OPA enabled, strict security)
cp config/ui/examples/production.yaml config/ui/settings.yamlconfig/ui/settings.yaml is optional β built-in defaults are used if it is absent. Key sections:
branding:
title: "My Custom Agent"
logo_url: "/custom-logo.svg" # Place file in public/ to serve it
favicon_url: "/custom-favicon.ico"
colors:
light:
primary: "#0066cc"
accent: "#a60000"
background: "#ffffff"
foreground: "#1a1a1a"
dark:
primary: "#4dabf7"
accent: "#f56e6e"
background: "#0a1628"
foreground: "#f0f4f8"
features:
debug_mode_default: false # Default state of the debug panel toggle
auth_enabled: true # Set to false for local dev (no SSO credentials needed)
mcp_apps_enabled: true # Render interactive MCP Apps (ui://) in chat
agent:
endpoint: "" # Agent URL β empty falls back to AGENT_HOST env var
timeout_ms: 30000
streaming: trueSee config/ui/README.md for the full schema and every environment variable override.
Env vars take precedence over the YAML file:
BRANDING_TITLE="Production Agent"
BRANDING_LOGO_URL="/prod-logo.svg"
FEATURE_AUTH_ENABLED=true
AGENT_ENDPOINT=https://prod-agent.example.comSee env.template for the complete list.
Branding and agent.endpoint / agent.timeout_ms changes are applied without a server restart. Security settings (rate_limit, session, helmet) require a restart. The config watcher logs which category each change falls into.
The config is validated at startup. Invalid values cause the server to exit with a clear error:
Config validation error: branding.colors.light.primary must be a valid hex color (got 'not-a-color')
Template UI can render interactive MCP Apps (ui:// HTML) inside chat when Template Agent is connected to a compliant MCP server.
- Enable with
features.mcp_apps_enabled(orFEATURE_MCP_APPS_ENABLED) - Point any SEP-1865-compliant server at the agent via
mcp.jsonβ no per-server UI widgets
| Command | Description |
|---|---|
npm run dev |
Development mode - Runs both client and server locally with hot reload |
npm run dev:client |
Runs only the frontend development server (Vite) |
npm run dev:server |
Runs only the backend development server (Fastify) |
npm run build |
Production build - Builds both client and server for deployment |
npm run build:client |
Builds only the frontend (TypeScript + Vite) |
npm run build:server |
Builds only the backend (TypeScript compilation) |
npm start |
Production start - Runs the built server application |
npm run lint |
Runs ESLint code analysis |
For convenience, a Makefile is provided with common development shortcuts:
| Command | Description |
|---|---|
make dev |
Quick development start - Installs dependencies and starts dev server |
make local |
Local production build - Installs dependencies, builds, and starts production server |
make clean |
Clean workspace - Removes node_modules and dist directories |
These commands are equivalent to:
make devβnpm ci && npm run devmake localβnpm ci && npm run build && npm startmake cleanβrm -rf node_modules dist
Copy env.template to .env and configure the following variables:
PORT=8080 # Server port (default: 8080)
ENVIRONMENT=development # Environment mode: development | production | test# Cookie signing secret (minimum 32 characters required)
COOKIE_SIGN=your-secret-with-minimum-length-of-32-characters
# Enable/disable authentication (set to "false" for development with dummy user)
AUTH_ENABLED=false# SSO Client credentials
SSO_CLIENT_ID=your-sso-client-id
SSO_CLIENT_SECRET=your-sso-client-secret
# SSO Provider settings
SSO_ISSUER_HOST=https://your-sso-provider.com
SSO_CALLBACK_URL=http://localhost:8080/auth/callback/oidcAGENT_HOST=http://localhost:5002template-ui/
βββ src/
β βββ frontend/ # React frontend application
β β βββ components/ # React components
β β βββ contexts/ # React context providers
β β βββ hooks/ # Custom React hooks
β β βββ pages/ # Route-level page components
β β βββ redux/ # Redux slices and store
β β βββ services/ # API client services
β β βββ types/ # TypeScript type definitions
β β βββ utils/ # Shared utilities
β β βββ App.tsx # Main application component
β βββ server/ # Fastify backend server
β βββ plugins/ # Fastify plugins (auth, OPA, tracing)
β βββ router/ # Route handlers (API, proxy, client)
β βββ utils/ # Settings loader, OPA engine, Redis, config watcher
β βββ server.ts # Server factory + config watcher setup
βββ config/
β βββ ui/
β β βββ settings.yaml # Runtime config (optional β defaults used if absent)
β β βββ README.md # Full schema + env-var reference
β β βββ examples/ # Ready-to-use example configs
β βββ compliance/
β βββ policy.rego # OPA deny rules (package compliance.ui)
β βββ data.json # Static external data for OPA policies
β βββ README.md # OPA policy authoring guide
βββ deployment/
β βββ openshift/ # OpenShift BuildConfig, ImageStream, Route, ConfigMap, Secret
β βββ overlays/
β βββ kind/ # Kind cluster overlay (NodePort, no TLS)
β βββ openshift/ # OpenShift overlay
βββ docs/
β βββ deployment-patterns.md # Branding, feature flags, runtime config, agent endpoint, OPA
βββ public/ # Static assets served directly
βββ e2e/ # Playwright end-to-end tests
βββ dist/ # Built files (generated)
βββ Containerfile # Podman/Docker build definition (UBI base)
βββ compose.yml # Local development compose (Redis)
βββ Makefile # Task shortcuts (dev, local, clean)
βββ package.json # Dependencies and scripts
βββ vite.config.ts # Vite configuration
βββ tsconfig.json # TypeScript configuration
βββ env.template # Environment variables template
| Document | What it covers |
|---|---|
docs/deployment-patterns.md |
Branding customization, feature flag reference, runtime config examples, agent endpoint switching, OPA policy examples |
config/ui/README.md |
Full YAML schema, every env-var override, hot-reload reference |
config/compliance/README.md |
OPA policy authoring, built-in rules, testing with opa eval |
- React 19 - UI framework
- TypeScript - Type safety
- Vite - Build tool and dev server
- Tailwind CSS - Styling
- Radix UI - Component primitives
- LangChain SDK - AI/ML integration
- React Router - Navigation
- Fastify - Web framework
- TypeScript - Type safety
- OAuth2 - Authentication
- Session Management - User sessions
The application supports two authentication modes:
- Uses a dummy user for development
- No actual authentication required
- User:
developer@redhat.com
- Full SSO/OAuth2 authentication
- Requires valid SSO configuration
- Session-based authentication with token refresh
npm run buildThis creates optimized builds in the dist/ directory:
dist/frontend/- Built React applicationdist/server/- Compiled server code
npm startThe server serves both the API and the built frontend application.
A Containerfile is provided for containerized deployment:
# Build container
podman build -t template-ui .
# Run container
podman run -p 8080:8080 --env-file .env template-ui-
Start development server
npm run dev
-
Make changes to frontend (
src/frontend/) or backend (src/server/) -
Changes auto-reload thanks to Vite (frontend) and nodemon (backend)
-
Run linting
npm run lint
-
Build and test
npm run build npm start
Port already in use
# Kill process on port 8080
lsof -ti:8080 | xargs kill -9Environment variables not loaded
- Ensure
.envfile exists in project root - Check that variables match
env.templateformat
Authentication issues
- Verify SSO configuration in
.env - Check that callback URL matches SSO provider settings
- For development, set
AUTH_ENABLED=false
Build failures
- Clear node_modules and reinstall:
rm -rf node_modules package-lock.json && npm install - Check TypeScript errors:
npx tsc --noEmit