Skip to content

Commit a1d3dc6

Browse files
committed
chore: merge main
2 parents 922b80d + 2dd2dce commit a1d3dc6

File tree

75 files changed

+2846
-470
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2846
-470
lines changed

docs/UI_Customization.md

Lines changed: 165 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,68 @@ The RAG Template frontend supports several customization options:
1212
- **Logos** for light and dark mode
1313
- **Brand colors and themes** (Tailwind v4 + daisyUI v5)
1414

15+
## Quick Start (Most Common Rebranding)
16+
17+
If you just want to rename/rebrand the UI, these are the usual knobs:
18+
19+
1. **Bot display name**: set `VITE_BOT_NAME`
20+
2. **Welcome message text**: edit `services/frontend/libs/i18n/chat/en.json``chat.initialMessage` (keep `{bot_name}`)
21+
3. **Navigation logo**: set `VITE_UI_LOGO_PATH_LIGHT` / `VITE_UI_LOGO_PATH_DARK` and add the files under each app’s `public/assets/`
22+
4. **Brand colors**: edit `services/frontend/libs/ui-styles/src/tailwind.css` (daisyUI theme tokens)
23+
5. **App titles + favicons**: edit `services/frontend/apps/*/index.html` and `services/frontend/apps/*/public/favicon.ico`
24+
25+
## How Configuration Works (Build-Time vs Runtime)
26+
27+
Vite apps are **static builds**. By default, all `VITE_*` variables are read at **build time** and baked into the built JS/CSS.
28+
29+
This repository also supports **runtime overrides** in container deployments:
30+
31+
- `services/frontend/.env.production` contains placeholder values like `VITE_BOT_NAME=VITE_BOT_NAME`
32+
- `services/frontend/env.sh` replaces those placeholder strings inside built `*.js`/`*.css` files at startup
33+
34+
That replacement only happens if you **run `env.sh` against the directory that nginx serves** (default: `/usr/share/nginx/html`).
35+
36+
| Scenario | Where to set `VITE_BOT_NAME` | When it takes effect |
37+
|---|---|---|
38+
| Local dev (`npm run chat:serve`) | `services/frontend/.env.development` (or `.env.development.local`) | on server restart |
39+
| Static hosting (S3, nginx without `env.sh`) | build environment or `services/frontend/.env.production` with real values | at build time |
40+
| Docker/Kubernetes (with `env.sh`) | container env vars + `env.sh` run at startup (in `infrastructure/rag/values.yaml` set `frontend.envs.vite.VITE_BOT_NAME`) | at container startup |
41+
1542
## Configuration Options
1643

1744
### Environment Variables
1845

19-
All customization is done through environment variables that can be set at build time or runtime:
46+
UI rebranding uses `VITE_*` environment variables (see “Build-Time vs Runtime” above):
2047

2148
| Variable | Description | Default Value | Example |
2249
|----------|-------------|---------------|---------|
2350
| `VITE_BOT_NAME` | The AI assistant's display name | "Knowledge Agent" | "DocBot" |
2451
| `VITE_UI_LOGO_PATH` | Common path to the main navigation logo (fallback for both light/dark) | "/assets/navigation-logo.svg" | "/assets/my-logo.png" |
2552
| `VITE_UI_LOGO_PATH_LIGHT` | Path to logo used in light mode (falls back to `VITE_UI_LOGO_PATH`) || "/assets/logo-light.svg" |
2653
| `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:**
54+
| `VITE_UI_THEME_DEFAULT` | Default theme when user first visits | "dark" | "light" |
55+
| `VITE_UI_THEME_OPTIONS` | Available theme options (comma-separated) | "light,dark" | "light" |
3556

36-
```text
37-
Hi 👋, I'm your AI Assistant Knowledge Agent, here to support you with any questions regarding the provided documents!
38-
```
57+
### Bot Name & Welcome Message
3958

40-
**Setting Custom Bot Name:**
59+
The bot name is read from `VITE_BOT_NAME` (see `services/frontend/libs/shared/settings.ts`) and is used in:
4160

42-
1. **Development Environment:**
61+
- the sender name for assistant chat bubbles (`services/frontend/libs/chat-app/ui/ChatMessages.vue`)
62+
- the first “welcome” message when a chat session starts (`services/frontend/libs/chat-app/data-access/+state/chat.store.ts`)
4363

44-
```bash
45-
# In your .env file
46-
VITE_BOT_NAME=DocBot
47-
```
64+
#### Change the bot name
4865

49-
2. **Docker/Production:**
66+
- **Local development**: set `VITE_BOT_NAME` in `services/frontend/.env.development` (or create `services/frontend/.env.development.local`) and restart `npm run chat:serve`.
67+
- **Build-time (no runtime injection)**: set `VITE_BOT_NAME` in your environment before building (for example `VITE_BOT_NAME="Acme Assistant" npm -C services/frontend run chat:build`).
68+
- **Runtime (Docker/Kubernetes)**: set `VITE_BOT_NAME` in the container environment and ensure `services/frontend/env.sh` runs (see “Docker Deployment” / “Kubernetes/Helm Deployment” below).
5069

51-
```bash
52-
# Environment variable
53-
export VITE_BOT_NAME="Your Custom Bot Name"
54-
```
70+
#### Change the welcome message text
5571

56-
3. **Kubernetes/Helm:**
72+
Edit the translation string and keep `{bot_name}` for interpolation:
5773

58-
```yaml
59-
# In your values.yaml or deployment
60-
env:
61-
- name: VITE_BOT_NAME
62-
value: "Corporate Knowledge Assistant"
63-
```
74+
Files:
75+
- `services/frontend/libs/i18n/chat/en.json`
76+
- `services/frontend/libs/i18n/chat/de.json`
6477

6578
### Logo Customization
6679

@@ -93,8 +106,8 @@ The logo appears in the navigation header of both chat and admin applications. Y
93106

94107
**Fallback order:**
95108

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))
109+
- Light: `VITE_UI_LOGO_PATH_LIGHT``VITE_UI_LOGO_PATH``/assets/navigation-logo-light.svg` (default asset exists in both apps: [chat](../services/frontend/apps/chat-app/public/assets/navigation-logo-light.svg), [admin](../services/frontend/apps/admin-app/public/assets/navigation-logo-light.svg))
110+
- Dark: `VITE_UI_LOGO_PATH_DARK``VITE_UI_LOGO_PATH``/assets/navigation-logo-dark.svg` (default asset exists in both apps: [chat](../services/frontend/apps/chat-app/public/assets/navigation-logo-dark.svg), [admin](../services/frontend/apps/admin-app/public/assets/navigation-logo-dark.svg))
98111

99112
**Examples:**
100113

@@ -107,13 +120,37 @@ VITE_UI_LOGO_PATH_DARK=/assets/company-logo-dark.svg
107120
VITE_UI_LOGO_PATH=/assets/company-logo.svg
108121
```
109122

123+
### Other Rebranding Assets
124+
125+
#### Chat avatars (user + assistant)
126+
127+
The chat bubbles use static avatar files by default:
128+
129+
- `services/frontend/apps/chat-app/public/assets/ai-avatar.svg`
130+
- `services/frontend/apps/chat-app/public/assets/user.svg`
131+
132+
Replace those files (keep the same filenames), or update the constants in `services/frontend/libs/chat-app/ui/ChatMessages.vue`.
133+
134+
#### Favicons
135+
136+
- `services/frontend/apps/chat-app/public/favicon.ico`
137+
- `services/frontend/apps/admin-app/public/favicon.ico`
138+
139+
#### Browser tab titles
140+
141+
- `services/frontend/apps/chat-app/index.html` (`<title>`)
142+
- `services/frontend/apps/admin-app/index.html` (`<title>`)
143+
110144
### Theme System (Tailwind v4 + daisyUI v5)
111145

112146
The frontend uses Tailwind v4 with daisyUI v5. In the following, we describe how to customize the theme using central CSS (recommended for brand colors shared by both apps):
113147

114148
- File: `services/frontend/libs/ui-styles/src/tailwind.css`
115149
- This file loads Tailwind v4 and defines daisyUI themes via CSS `@plugin` blocks.
116-
- Update semantic tokens under the `@plugin "daisyui/theme"` blocks:
150+
- Themes are defined in two blocks:
151+
- `light`: Light mode
152+
- `dark`: Dark mode (default via `VITE_UI_THEME_DEFAULT`)
153+
- Update semantic tokens under the `@plugin "daisyui/theme"` blocks, for example:
117154

118155
```css
119156
--color-primary: #a90303; /* CTA/buttons */
@@ -122,17 +159,63 @@ The frontend uses Tailwind v4 with daisyUI v5. In the following, we describe how
122159
--color-base-200: #EDEDED; /* cards */
123160
```
124161

162+
Common class ↔ token mapping:
163+
164+
- `btn btn-primary`, `bg-primary`, `text-primary``--color-primary` / `--color-primary-content`
165+
- `bg-secondary`, `text-secondary-content``--color-secondary` / `--color-secondary-content`
166+
- `bg-base-100/200/300`, `border-base-300`, `text-base-content``--color-base-*` / `--color-base-content`
167+
168+
Custom CSS variables used by this repo are also defined per theme in `tailwind.css`:
169+
170+
- `--scrollbar-track` / `--scrollbar-thumb` (scrollbar styling)
171+
- `--base-200-highlight` (highlight “jump to source” anchors)
172+
125173
Theme behavior:
126174

127-
- Default theme and options are set by env vars: `VITE_UI_THEME_DEFAULT`, `VITE_UI_THEME_OPTIONS`
128-
- The selected theme is stored in `localStorage` under `app-theme`
129-
- Theme switching updates `html[data-theme]` so daisyUI variables apply
175+
1. **Set Default Theme:**
176+
177+
```bash
178+
# Users will see dark mode by default
179+
VITE_UI_THEME_DEFAULT=dark
180+
```
181+
182+
1. **Configure Available Options:**
183+
184+
```bash
185+
# Only allow light mode (remove theme toggle)
186+
VITE_UI_THEME_OPTIONS=light
187+
188+
# Support both themes (default)
189+
VITE_UI_THEME_OPTIONS=light,dark
190+
```
191+
192+
**Theme Behavior:**
193+
194+
- Theme preference is saved in browser's localStorage
195+
- Theme persists across browser sessions
196+
- The built-in theme toggle is shown only when both `light` and `dark` are available
197+
- Manual theme switching overrides the default setting
198+
- Theme selection is stored under `localStorage["app-theme"]` and applied via `html[data-theme]`
199+
200+
### Markdown / Chat Content Styling
201+
202+
Chat answers, user prompts, and citations are rendered from Markdown via `marked` (see `services/frontend/libs/shared/utils/src/lib/marked.utils.ts`) and styled via global CSS in `services/frontend/libs/shared/global.css`.
203+
204+
Rebrandable bits:
205+
206+
- Code blocks: `--chat-code-*` variables and `.chat-code-block*` styles
207+
- Typography: `.prose` overrides keep headings/links readable across themes
130208

131209
## Development Setup
132210

133211
### Local Development
134212

135-
1. **Create/modify `.env` file in frontend directory** (services/frontend/.env):
213+
Vite reads env files from `services/frontend/`. Common ones:
214+
215+
- `services/frontend/.env.development` / `services/frontend/.env.development.local` (local dev)
216+
- `services/frontend/.env.production` / `services/frontend/.env.production.local` (production build)
217+
218+
1. **Create/modify an env file** (recommended: `services/frontend/.env.development.local`):
136219

137220
```bash
138221
# Bot customization
@@ -159,31 +242,42 @@ Theme behavior:
159242

160243
### Docker Deployment
161244

162-
For Docker deployments, the frontend uses a special script (services/frontend/env.sh) to replace environment variables at runtime:
245+
The app Docker images are built from:
163246

164-
1. **Set environment variables in your container:**
247+
- `services/frontend/apps/chat-app/Dockerfile`
248+
- `services/frontend/apps/admin-app/Dockerfile`
165249

166-
```dockerfile
167-
ENV VITE_BOT_NAME="Production Assistant"
168-
ENV VITE_UI_LOGO_PATH_LIGHT="/assets/prod-logo-light.svg"
169-
ENV VITE_UI_LOGO_PATH_DARK="/assets/prod-logo-dark.svg"
170-
ENV VITE_UI_THEME_DEFAULT="light"
171-
```
250+
These images contain:
251+
252+
- built files under `/app/frontend` (read-only)
253+
- `env.sh` at `/app/env.sh`
254+
- nginx serving `/usr/share/nginx/html`
255+
256+
To use runtime variables in Docker, you must ensure the container runs:
172257

173-
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).
258+
```sh
259+
cp -r /app/frontend/. /usr/share/nginx/html && /bin/sh /app/env.sh
260+
```
261+
262+
before nginx serves the files (otherwise placeholders like `VITE_BOT_NAME` will remain).
263+
264+
See `services/frontend/env.sh` for details, including `TARGET_DIR` override.
174265

175266
### Kubernetes/Helm Deployment
176267

177-
1. **Configure in your Helm values.yaml** (example chart values at [infrastructure/rag/values.yaml](../infrastructure/rag/values.yaml)):
268+
The Helm chart wires env vars via `frontend.envs.vite` into a ConfigMap and mounts a writable `/usr/share/nginx/html`. It also runs the copy + `env.sh` step (see `infrastructure/rag/templates/frontend/deployment.yaml`).
269+
270+
1. **Configure in your Helm `values.yaml`** (example values at [infrastructure/rag/values.yaml](../infrastructure/rag/values.yaml)):
178271

179272
```yaml
180273
frontend:
181-
env:
182-
VITE_BOT_NAME: "Enterprise Knowledge Bot"
183-
VITE_UI_LOGO_PATH_LIGHT: "/assets/enterprise-logo-light.svg"
184-
VITE_UI_LOGO_PATH_DARK: "/assets/enterprise-logo-dark.svg"
185-
VITE_UI_THEME_DEFAULT: "dark"
186-
VITE_UI_THEME_OPTIONS: "light,dark"
274+
envs:
275+
vite:
276+
VITE_BOT_NAME: "Enterprise Knowledge Bot"
277+
VITE_UI_LOGO_PATH_LIGHT: "/assets/enterprise-logo-light.svg"
278+
VITE_UI_LOGO_PATH_DARK: "/assets/enterprise-logo-dark.svg"
279+
VITE_UI_THEME_DEFAULT: "dark"
280+
VITE_UI_THEME_OPTIONS: "light,dark"
187281
```
188282
189283
2. **Or use ConfigMap:**
@@ -203,23 +297,12 @@ For Docker deployments, the frontend uses a special script (services/frontend/en
203297
204298
### Adding Custom Themes
205299
206-
To add themes beyond light/dark, update both the settings and the theme source:
300+
This repo is optimized for `light`/`dark` theming. You can still add a custom theme, but note:
207301

208-
1. **Update the settings configuration** in [services/frontend/libs/shared/settings.ts](../services/frontend/libs/shared/settings.ts):
302+
- The built-in UI toggle only switches between `light` and `dark` (`services/frontend/libs/shared/ui/ThemeToggle.vue`).
303+
- If you want a custom theme without adding a theme picker, set `VITE_UI_THEME_OPTIONS` to a single theme and the toggle will disappear.
209304

210-
```typescript
211-
// frontend/libs/shared/settings.ts
212-
const defaultSettings: AppSettings = {
213-
ui: {
214-
theme: {
215-
default: "light",
216-
options: ["light", "dark", "brand-red"], // Add your theme
217-
},
218-
},
219-
};
220-
```
221-
222-
2. Define the theme either e.g. in CSS (recommended for shared branding):
305+
To add a custom theme, define it in `services/frontend/libs/ui-styles/src/tailwind.css`:
223306

224307
CSS (Tailwind v4):
225308

@@ -232,6 +315,13 @@ CSS (Tailwind v4):
232315
}
233316
```
234317

318+
Then select it via env vars:
319+
320+
```bash
321+
VITE_UI_THEME_DEFAULT=brand-red
322+
VITE_UI_THEME_OPTIONS=brand-red
323+
```
324+
235325
### Internationalization
236326

237327
Bot names and messages support internationalization:
@@ -263,9 +353,12 @@ Bot names and messages support internationalization:
263353

264354
### Bot Name Not Updating
265355

266-
- **Issue**: Bot name shows as `{bot_name}` instead of actual name
267-
- **Cause**: Vue computed property not accessed correctly
268-
- **Solution**: Use `initialMessage.value` instead of `initialMessage` in the store
356+
- **Issue**: Bot name stays at the default or shows a placeholder value (e.g. `VITE_BOT_NAME`)
357+
- **Cause**: Runtime env replacement did not run (Vite env vars are build-time by default)
358+
- **Solutions**:
359+
- Ensure `services/frontend/.env.production` contains placeholders for the variables you want to replace (this repo includes `VITE_BOT_NAME`, `VITE_UI_*`, etc.)
360+
- Ensure the container runs `env.sh` after copying the built files into `/usr/share/nginx/html`
361+
- Verify the variable is set in the container environment (Kubernetes `ConfigMap`/`Secret`, Docker `-e`, etc.)
269362

270363
### Logo Not Loading / Wrong for Theme
271364

@@ -291,6 +384,7 @@ Bot names and messages support internationalization:
291384
- **Issue**: Customization works in development but not production
292385
- **Cause**: Vite environment variables are build-time only
293386
- **Solutions**:
387+
- Ensure the variables exist as placeholders at build time (see `services/frontend/.env.production`)
294388
- For Docker: Ensure `env.sh` script runs after copying files
295389
- For Kubernetes: Use ConfigMap/Secret with proper mounting
296390
- Verify environment variables are set in container

infrastructure/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ frontend:
257257

258258
The following values should be adjusted for the deployment:
259259

260+
> ⓘ INFO: If the backend pod gets `OOMKilled` (exit code `137`) on local k3d/Tilt setups, reduce `backend.workers` (each uvicorn worker is a separate Python process), disable reranking `RERANKER_ENABLED: false` or pin a smaller Flashrank model (e.g. `RERANKER_MODEL: ms-marco-TinyBERT-L-2-v2`), and/or increase the memory available to Docker/k3d.
261+
260262
```yaml
261263
backend:
262264
secrets:

infrastructure/rag/templates/_admin_backend_and_extractor_helpers.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
{{- printf "%s-source-uploader-configmap" .Release.Name | trunc 63 | trimSuffix "-" -}}
6969
{{- end -}}
7070

71+
{{- define "configmap.extractorSitemapName" -}}
72+
{{- printf "%s-extractor-sitemap-configmap" .Release.Name | trunc 63 | trimSuffix "-" -}}
73+
{{- end -}}
74+
7175
# image
7276
{{- define "adminBackend.fullImageName" -}}
7377
{{- $tag := default .Chart.AppVersion .Values.adminBackend.image.tag -}}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ template "configmap.extractorSitemapName" . }}
5+
data:
6+
{{- range $key, $value := .Values.extractor.envs.sitemap }}
7+
{{ $key }}: {{ $value | quote }}
8+
{{- end }}

infrastructure/rag/templates/extractor/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ spec:
110110
envFrom:
111111
- configMapRef:
112112
name: {{ template "configmap.s3Name" . }}
113+
- configMapRef:
114+
name: {{ template "configmap.extractorSitemapName" . }}
113115
- secretRef:
114116
name: {{ template "secret.s3Name" . }}
115117
{{- $hfCacheDir := include "extractor.huggingfaceCacheDir" . }}

0 commit comments

Comments
 (0)