|
| 1 | +# UI Customization Guide |
| 2 | + |
| 3 | +This guide explains how to customize the RAG Template frontend applications, including bot branding, theming, and logo configuration. |
| 4 | + |
| 5 | +Note: In this document, “frontend” refers to the folder at services/frontend in this repository. All links below point to files in that folder or elsewhere in this repo. |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +The RAG Template frontend supports several customization options: |
| 10 | + |
| 11 | +- **Bot Name**: Customize the AI assistant's name in chat messages |
| 12 | +- **Logo/Branding**: Replace the default logo with your organization's branding |
| 13 | +- **Theme System**: Switch between light and dark modes with user preference persistence |
| 14 | + |
| 15 | +## Configuration Options |
| 16 | + |
| 17 | +### Environment Variables |
| 18 | + |
| 19 | +All customization is done through environment variables that can be set at build time or runtime: |
| 20 | + |
| 21 | +| Variable | Description | Default Value | Example | |
| 22 | +|----------|-------------|---------------|---------| |
| 23 | +| `VITE_BOT_NAME` | The AI assistant's display name | "Knowledge Agent" | "DocBot" | |
| 24 | +| `VITE_UI_LOGO_PATH` | Common path to the main navigation logo (fallback for both light/dark) | "/assets/navigation-logo.svg" | "/assets/my-logo.png" | |
| 25 | +| `VITE_UI_LOGO_PATH_LIGHT` | Path to logo used in light mode (falls back to `VITE_UI_LOGO_PATH`) | — | "/assets/logo-light.svg" | |
| 26 | +| `VITE_UI_LOGO_PATH_DARK` | Path to logo used in dark mode (falls back to `VITE_UI_LOGO_PATH`) | — | "/assets/logo-dark.svg" | |
| 27 | +| `VITE_UI_THEME_DEFAULT` | Default theme when user first visits | "light" | "dark" | |
| 28 | +| `VITE_UI_THEME_OPTIONS` | Available theme options (comma-separated) | "light,dark" | "light,dark,auto" | |
| 29 | + |
| 30 | +### Bot Name Customization |
| 31 | + |
| 32 | +The bot name appears in the initial welcome message in the chat interface. |
| 33 | + |
| 34 | +**Default Message:** |
| 35 | + |
| 36 | +```text |
| 37 | +Hi 👋, I'm your AI Assistant Knowledge Agent, here to support you with any questions regarding the provided documents! |
| 38 | +``` |
| 39 | + |
| 40 | +**Setting Custom Bot Name:** |
| 41 | + |
| 42 | +1. **Development Environment:** |
| 43 | + |
| 44 | + ```bash |
| 45 | + # In your .env file |
| 46 | + VITE_BOT_NAME=DocBot |
| 47 | + ``` |
| 48 | + |
| 49 | +2. **Docker/Production:** |
| 50 | + |
| 51 | + ```bash |
| 52 | + # Environment variable |
| 53 | + export VITE_BOT_NAME="Your Custom Bot Name" |
| 54 | + ``` |
| 55 | + |
| 56 | +3. **Kubernetes/Helm:** |
| 57 | + |
| 58 | + ```yaml |
| 59 | + # In your values.yaml or deployment |
| 60 | + env: |
| 61 | + - name: VITE_BOT_NAME |
| 62 | + value: "Corporate Knowledge Assistant" |
| 63 | + ``` |
| 64 | +
|
| 65 | +### Logo Customization |
| 66 | +
|
| 67 | +The logo appears in the navigation header of both chat and admin applications. You can configure separate logos for light and dark themes. |
| 68 | +
|
| 69 | +**Setting Custom Logos:** |
| 70 | +
|
| 71 | +1. Place your logo files in the app assets directory: |
| 72 | +
|
| 73 | +- Chat app: services/frontend/apps/chat-app/public/assets/ ([open folder](../services/frontend/apps/chat-app/public/assets)) |
| 74 | +- Admin app: services/frontend/apps/admin-app/public/assets/ ([open folder](../services/frontend/apps/admin-app/public/assets)) |
| 75 | +
|
| 76 | +1. Set the environment variables: |
| 77 | +
|
| 78 | + ```bash |
| 79 | + # Preferred: specify light and dark explicitly |
| 80 | + VITE_UI_LOGO_PATH_LIGHT=/assets/my-logo-light.svg |
| 81 | + VITE_UI_LOGO_PATH_DARK=/assets/my-logo-dark.svg |
| 82 | + |
| 83 | + # Optional: common fallback used when LIGHT/DARK are not set |
| 84 | + VITE_UI_LOGO_PATH=/assets/my-logo.svg |
| 85 | + ``` |
| 86 | + |
| 87 | +**Logo Requirements:** |
| 88 | + |
| 89 | +- **Format**: SVG, PNG, or JPG |
| 90 | +- **Size**: Optimized for 128px width (will be scaled to w-32 class) |
| 91 | +- **Background**: Transparent recommended for better theme compatibility |
| 92 | +- **Path**: Must be accessible from the public assets directory |
| 93 | + |
| 94 | +**Fallback order:** |
| 95 | + |
| 96 | +- Light: `VITE_UI_LOGO_PATH_LIGHT` → `VITE_UI_LOGO_PATH` → `/assets/navigation-logo.svg` (default asset exists in both apps: [chat](../services/frontend/apps/chat-app/public/assets/navigation-logo.svg), [admin](../services/frontend/apps/admin-app/public/assets/navigation-logo.svg)) |
| 97 | +- Dark: `VITE_UI_LOGO_PATH_DARK` → `VITE_UI_LOGO_PATH` → `/assets/navigation-logo.svg` (default asset exists in both apps: [chat](../services/frontend/apps/chat-app/public/assets/navigation-logo.svg), [admin](../services/frontend/apps/admin-app/public/assets/navigation-logo.svg)) |
| 98 | + |
| 99 | +**Examples:** |
| 100 | + |
| 101 | +```bash |
| 102 | +# Separate light/dark logos |
| 103 | +VITE_UI_LOGO_PATH_LIGHT=/assets/company-logo-light.svg |
| 104 | +VITE_UI_LOGO_PATH_DARK=/assets/company-logo-dark.svg |
| 105 | + |
| 106 | +# Only a common logo |
| 107 | +VITE_UI_LOGO_PATH=/assets/company-logo.svg |
| 108 | +``` |
| 109 | + |
| 110 | +### Theme System |
| 111 | + |
| 112 | +The application supports a flexible theme system with user preference persistence. |
| 113 | + |
| 114 | +**Available Themes:** |
| 115 | + |
| 116 | +- `light`: Light mode (default) |
| 117 | +- `dark`: Dark mode |
| 118 | + |
| 119 | +**Theme Configuration:** |
| 120 | + |
| 121 | +1. **Set Default Theme:** |
| 122 | + |
| 123 | + ```bash |
| 124 | + # Users will see dark mode by default |
| 125 | + VITE_UI_THEME_DEFAULT=dark |
| 126 | + ``` |
| 127 | + |
| 128 | +1. **Configure Available Options:** |
| 129 | + |
| 130 | + ```bash |
| 131 | + # Only allow light mode (remove theme toggle) |
| 132 | + VITE_UI_THEME_OPTIONS=light |
| 133 | + |
| 134 | + # Support both themes (default) |
| 135 | + VITE_UI_THEME_OPTIONS=light,dark |
| 136 | + ``` |
| 137 | + |
| 138 | +**Theme Behavior:** |
| 139 | + |
| 140 | +- Theme preference is saved in browser's localStorage |
| 141 | +- Theme persists across browser sessions |
| 142 | +- Theme toggle button appears only when multiple options are available |
| 143 | +- Manual theme switching overrides the default setting |
| 144 | + |
| 145 | +## Development Setup |
| 146 | + |
| 147 | +### Local Development |
| 148 | + |
| 149 | +1. **Create/modify `.env` file in frontend directory** (services/frontend/.env): |
| 150 | + |
| 151 | + ```bash |
| 152 | + # Bot customization |
| 153 | + VITE_BOT_NAME=Development Bot |
| 154 | + |
| 155 | + # Logo customization |
| 156 | + VITE_UI_LOGO_PATH_LIGHT=/assets/dev-logo-light.svg |
| 157 | + VITE_UI_LOGO_PATH_DARK=/assets/dev-logo-dark.svg |
| 158 | + # Optional common fallback |
| 159 | + # VITE_UI_LOGO_PATH=/assets/dev-logo.svg |
| 160 | + |
| 161 | + # Theme customization |
| 162 | + VITE_UI_THEME_DEFAULT=light |
| 163 | + VITE_UI_THEME_OPTIONS=light,dark |
| 164 | + ``` |
| 165 | + |
| 166 | +1. **Start development server** (scripts are defined in [services/frontend/package.json](../services/frontend/package.json)): |
| 167 | + |
| 168 | + ```bash |
| 169 | + npm run chat:serve |
| 170 | + # or |
| 171 | + npm run admin:serve |
| 172 | + ``` |
| 173 | + |
| 174 | +### Docker Deployment |
| 175 | + |
| 176 | +For Docker deployments, the frontend uses a special script (services/frontend/env.sh) to replace environment variables at runtime: |
| 177 | + |
| 178 | +1. **Set environment variables in your container:** |
| 179 | + |
| 180 | + ```dockerfile |
| 181 | + ENV VITE_BOT_NAME="Production Assistant" |
| 182 | + ENV VITE_UI_LOGO_PATH_LIGHT="/assets/prod-logo-light.svg" |
| 183 | + ENV VITE_UI_LOGO_PATH_DARK="/assets/prod-logo-dark.svg" |
| 184 | + ENV VITE_UI_THEME_DEFAULT="light" |
| 185 | + ``` |
| 186 | + |
| 187 | +1. **The env.sh script automatically replaces variables** in built JS/CSS files when the container starts. See [services/frontend/env.sh](../services/frontend/env.sh). |
| 188 | + |
| 189 | +### Kubernetes/Helm Deployment |
| 190 | + |
| 191 | +1. **Configure in your Helm values.yaml** (example chart values at [infrastructure/rag/values.yaml](../infrastructure/rag/values.yaml)): |
| 192 | + |
| 193 | + ```yaml |
| 194 | + frontend: |
| 195 | + env: |
| 196 | + VITE_BOT_NAME: "Enterprise Knowledge Bot" |
| 197 | + VITE_UI_LOGO_PATH_LIGHT: "/assets/enterprise-logo-light.svg" |
| 198 | + VITE_UI_LOGO_PATH_DARK: "/assets/enterprise-logo-dark.svg" |
| 199 | + VITE_UI_THEME_DEFAULT: "dark" |
| 200 | + VITE_UI_THEME_OPTIONS: "light,dark" |
| 201 | + ``` |
| 202 | +
|
| 203 | +2. **Or use ConfigMap:** |
| 204 | +
|
| 205 | + ```yaml |
| 206 | + apiVersion: v1 |
| 207 | + kind: ConfigMap |
| 208 | + metadata: |
| 209 | + name: frontend-config |
| 210 | + data: |
| 211 | + VITE_BOT_NAME: "K8s Assistant" |
| 212 | + VITE_UI_LOGO_PATH_LIGHT: "/assets/k8s-logo-light.svg" |
| 213 | + VITE_UI_LOGO_PATH_DARK: "/assets/k8s-logo-dark.svg" |
| 214 | + ``` |
| 215 | +
|
| 216 | +## Advanced Customization |
| 217 | +
|
| 218 | +### Adding Custom Themes |
| 219 | +
|
| 220 | +To add custom themes beyond light/dark: |
| 221 | +
|
| 222 | +1. **Update the settings configuration** in [services/frontend/libs/shared/settings.ts](../services/frontend/libs/shared/settings.ts): |
| 223 | +
|
| 224 | + ```typescript |
| 225 | + // frontend/libs/shared/settings.ts |
| 226 | + const defaultSettings: AppSettings = { |
| 227 | + ui: { |
| 228 | + theme: { |
| 229 | + default: "light", |
| 230 | + options: ["light", "dark", "custom"], // Add your theme |
| 231 | + }, |
| 232 | + }, |
| 233 | + }; |
| 234 | + ``` |
| 235 | + |
| 236 | +1. **Configure DaisyUI themes** in [services/frontend/tailwind.config.js](../services/frontend/tailwind.config.js): |
| 237 | + |
| 238 | + ```javascript |
| 239 | + module.exports = { |
| 240 | + daisyui: { |
| 241 | + themes: [ |
| 242 | + "light", |
| 243 | + "dark", |
| 244 | + { |
| 245 | + custom: { |
| 246 | + "primary": "#your-color", |
| 247 | + "secondary": "#your-color", |
| 248 | + // ... more theme colors |
| 249 | + } |
| 250 | + } |
| 251 | + ], |
| 252 | + }, |
| 253 | + }; |
| 254 | + ``` |
| 255 | + |
| 256 | +### Internationalization |
| 257 | + |
| 258 | +Bot names and messages support internationalization: |
| 259 | + |
| 260 | +1. **Modify translation files:** |
| 261 | + |
| 262 | + ```json |
| 263 | + // services/frontend/libs/i18n/chat/en.json |
| 264 | + { |
| 265 | + "chat": { |
| 266 | + "initialMessage": "Hi 👋, I'm your AI Assistant {bot_name}, here to help!" |
| 267 | + } |
| 268 | + } |
| 269 | + ``` |
| 270 | + |
| 271 | +1. **Add language-specific bot names:** |
| 272 | + |
| 273 | + ```json |
| 274 | + // services/frontend/libs/i18n/chat/de.json |
| 275 | + { |
| 276 | + "chat": { |
| 277 | + "initialMessage": "Hallo 👋, ich bin dein KI-Assistent {bot_name}, hier um zu helfen!" |
| 278 | + } |
| 279 | + } |
| 280 | + ``` |
| 281 | + Files: [en.json](../services/frontend/libs/i18n/chat/en.json), [de.json](../services/frontend/libs/i18n/chat/de.json) |
| 282 | + |
| 283 | +## Troubleshooting |
| 284 | + |
| 285 | +### Bot Name Not Updating |
| 286 | + |
| 287 | +- **Issue**: Bot name shows as `{bot_name}` instead of actual name |
| 288 | +- **Cause**: Vue computed property not accessed correctly |
| 289 | +- **Solution**: Use `initialMessage.value` instead of `initialMessage` in the store |
| 290 | + |
| 291 | +### Logo Not Loading / Wrong for Theme |
| 292 | + |
| 293 | +- **Issue**: Logo doesn't appear or shows broken image |
| 294 | +- **Cause**: Incorrect path or missing asset |
| 295 | +- **Solutions**: |
| 296 | + - Verify files exist in `public/assets/` directory |
| 297 | + - Check `VITE_UI_LOGO_PATH_LIGHT` / `VITE_UI_LOGO_PATH_DARK` (or `VITE_UI_LOGO_PATH` fallback) |
| 298 | + - Ensure path starts with `/assets/` |
| 299 | + - Check browser network tab for 404 errors |
| 300 | + |
| 301 | +### Theme Not Persisting |
| 302 | + |
| 303 | +- **Issue**: Theme resets to default on page refresh |
| 304 | +- **Cause**: localStorage not being saved/loaded correctly |
| 305 | +- **Solutions**: |
| 306 | + - Check browser localStorage for `app-theme` key |
| 307 | + - Verify theme value is in available options |
| 308 | + - Clear localStorage and try again |
| 309 | + |
| 310 | +### Environment Variables Not Working in Production |
| 311 | + |
| 312 | +- **Issue**: Customization works in development but not production |
| 313 | +- **Cause**: Vite environment variables are build-time only |
| 314 | +- **Solutions**: |
| 315 | + - For Docker: Ensure `env.sh` script runs after copying files |
| 316 | + - For Kubernetes: Use ConfigMap/Secret with proper mounting |
| 317 | + - Verify environment variables are set in container |
| 318 | + |
| 319 | +## Example Configurations |
| 320 | + |
| 321 | +### Corporate Deployment |
| 322 | + |
| 323 | +```bash |
| 324 | +VITE_BOT_NAME="Corporate Knowledge Assistant" |
| 325 | +VITE_UI_LOGO_PATH_LIGHT="/assets/corporate-logo-light.svg" |
| 326 | +VITE_UI_LOGO_PATH_DARK="/assets/corporate-logo-dark.svg" |
| 327 | +# Optional common fallback |
| 328 | +# VITE_UI_LOGO_PATH="/assets/corporate-logo.svg" |
| 329 | +VITE_UI_THEME_DEFAULT="light" |
| 330 | +VITE_UI_THEME_OPTIONS="light,dark" |
| 331 | +``` |
| 332 | + |
| 333 | +### Development Environment |
| 334 | + |
| 335 | +```bash |
| 336 | +VITE_BOT_NAME="Dev Bot" |
| 337 | +VITE_UI_LOGO_PATH_LIGHT="/assets/dev-logo-light.png" |
| 338 | +VITE_UI_LOGO_PATH_DARK="/assets/dev-logo-dark.png" |
| 339 | +VITE_UI_THEME_DEFAULT="dark" |
| 340 | +VITE_UI_THEME_OPTIONS="light,dark" |
| 341 | +``` |
| 342 | + |
| 343 | +### Minimal Configuration |
| 344 | + |
| 345 | +```bash |
| 346 | +VITE_BOT_NAME="Assistant" |
| 347 | +VITE_UI_THEME_DEFAULT="light" |
| 348 | +VITE_UI_THEME_OPTIONS="light" |
| 349 | +``` |
| 350 | + |
| 351 | +This customization system provides flexible branding options while maintaining a clean, maintainable codebase. |
0 commit comments