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
| 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
β β βββ hooks/ # Custom React hooks
β β βββ lib/ # Utility libraries
β β βββ App.tsx # Main application component
β βββ server/ # Fastify backend server
β βββ plugins/ # Fastify plugins (auth, etc.)
β βββ router/ # API routes
β βββ server.ts # Server configuration
βββ public/ # Static assets
βββ dist/ # Built files (generated)
βββ package.json # Dependencies and scripts
βββ vite.config.ts # Vite configuration
βββ tsconfig.json # TypeScript configuration
βββ env.template # Environment variables template
- 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:
[email protected]
- 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