Skip to content

Commit 1fe5acd

Browse files
authored
Merge pull request #128 from AET-DevOps25/feature/update-client-config
Feature/update client config
2 parents 3873460 + 1230d49 commit 1fe5acd

File tree

16 files changed

+204
-84
lines changed

16 files changed

+204
-84
lines changed

.env.template

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Cloud based LLM models
2+
# API_OPENAI="your openai key"
3+
# API_ANTHROPIC="your anthropic key"
4+
# API_MISTRAL="your mistral key"
5+
# API_HUGGINGFACEHUB="your huggingface api token"
6+
7+
# Local Models
8+
# API_OPENWEBUI="your openwebui key"
9+
10+
# You need one API key for both cloud or local LLM models.
11+
12+
# Base URL for calling local models
13+
# BASE_URL="https://gpu.aet.cit.tum.de"
14+
15+
# For docker-compose deployment, you can use the following environment variables:
16+
API_OPENWEBUI=""
17+
GITLAB_CLIENT_SECRET=""
18+
API_OPENAI=""

README.md

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RecipAI
2+
23
RecipAI is available at [`https://recipai.student.k8s.aet.cit.tum.de`](https://recipai.student.k8s.aet.cit.tum.de)
34

45
## Project Description
@@ -29,7 +30,8 @@ Generative AI is integrated meaningfully through a dedicated LLM microservice de
2930

3031
### 1. Frontend (React)
3132

32-
***Responsible Students:***
33+
**_Responsible Students:_**
34+
3335
- Mehmed Esad Akcam & Ege Dogu Kaya
3436

3537
**Responsibilities:**
@@ -47,10 +49,10 @@ Generative AI is integrated meaningfully through a dedicated LLM microservice de
4749
- Preference settings (gluten-free, diabetic, vegan, etc.)
4850
- Recipe history viewer
4951

50-
5152
### 2. Backend (Spring Boot REST API)
5253

53-
***Responsible Student:***
54+
**_Responsible Student:_**
55+
5456
- Mehmed Esad Akcam
5557

5658
**Responsibilities:**
@@ -61,10 +63,10 @@ Generative AI is integrated meaningfully through a dedicated LLM microservice de
6163
- Store and retrieve chat and recipe history from MongoDB.
6264
- Expose REST endpoints for client-side operations.
6365

64-
6566
### 3. GenAI Microservice (Python with FastAPI + LangChain + Qdrant)
6667

67-
***Responsible Student:***
68+
**_Responsible Student:_**
69+
6870
- Ege Dogu Kaya
6971

7072
**Responsibilities:**
@@ -80,7 +82,6 @@ Generative AI is integrated meaningfully through a dedicated LLM microservice de
8082
- Prompt templates that incorporate user reqeusts, preferences and dietary constraints
8183
- Qdrant vector database to store embedded documents for similarity search
8284

83-
8485
### 4. Database (MongoDB)
8586

8687
**Collections:**
@@ -92,26 +93,25 @@ Generative AI is integrated meaningfully through a dedicated LLM microservice de
9293

9394
- Preferences are indexed for fast lookup
9495

95-
9696
### 5. Vector Database (Qdrant)
9797

9898
**Collections:**
9999

100100
- `recipes` – Stores embedded recipe documents which are uploaded by the user
101101

102-
103102
### 6. DevOps
104103

105-
***Responsible Students:***
104+
**_Responsible Students:_**
105+
106106
- Mehmed Esad Akcam & Ege Dogu Kaya
107107

108-
***Responsibilites***
108+
**_Responsibilites_**
109+
109110
- Each service is dockerized and has its own image in github registry
110111
- CI/CD pipelines to deploy on student cluster in Rancher and AWS
111112
- Helm charts for k8s deployment
112113
- Docker compose for AWS deployment
113114

114-
115115
### 7. Authentication (GitLab LRZ SSO)
116116

117117
**Flow:**
@@ -122,7 +122,6 @@ Generative AI is integrated meaningfully through a dedicated LLM microservice de
122122
- Backend creates or updates the user profile in MongoDB
123123
- Tokens used for secure communication between frontend and backend
124124

125-
126125
### Communication Flow Example
127126

128127
1. User logs in via GitLab LRZ → token returned.
@@ -133,7 +132,6 @@ Generative AI is integrated meaningfully through a dedicated LLM microservice de
133132
6. API stores recipe + chat history in MongoDB.
134133
7. Response returned to frontend and rendered in chat UI.
135134

136-
137135
### Technologies
138136

139137
| Component | Technology |
@@ -145,7 +143,6 @@ Generative AI is integrated meaningfully through a dedicated LLM microservice de
145143
| Vector Database | Qdrant |
146144
| Auth | GitLab LRZ SSO |
147145

148-
149146
## Setup Instructions
150147

151148
### Prerequisites
@@ -214,28 +211,37 @@ docker compose -f docker-compose-dev.yml up -d
214211
cd client
215212
npm run dev
216213
```
214+
217215
The client will be available at [http://localhost:5173](http://localhost:5173).
218216

219217
### Start the Server Services
218+
220219
```bash
221220
cd server
222221
```
222+
223223
#### API-Gateway Service
224+
224225
```bash
225226
./gradlew :api-gw:bootRun
226227
```
228+
227229
The API-Gateway Service API will be available at [http://localhost:8080](http://localhost:8080).
228230

229231
#### User Service
232+
230233
```bash
231234
./gradlew :user:bootRun
232235
```
236+
233237
The User Service API will be available at [http://localhost:8081](http://localhost:8081).
234238

235239
#### Chat Service
240+
236241
```bash
237242
./gradlew :chat:bootRun
238243
```
244+
239245
The Chat Service API will be available at [http://localhost:8082](http://localhost:8082).
240246

241247
### Start the GenAI Service
@@ -244,6 +250,7 @@ The Chat Service API will be available at [http://localhost:8082](http://localho
244250
cd genai
245251
uvicorn main:app --reload --host 0.0.0.0 --port 8000
246252
```
253+
247254
The LLM service will be available at [http://localhost:8000](http://localhost:8000).
248255

249256
## Development Workflow
@@ -274,16 +281,20 @@ The LLM service will be available at [http://localhost:8000](http://localhost:80
274281
- Tests are in the `genai/tests` directory.
275282

276283
#### GenAI Usage
284+
277285
- The GenAI service is responsible for all interactions with the language model used to generate and modify recipes in RecipAI. It receives user inputs as free-text prompts and responds with structured outputs such as complete recipes, meal plans, or modified instructions. It is implemented using FastAPI, LangChain, and integrates with local and cloud large language models.
278286

279287
##### Retrieval-Augmented Generation
288+
280289
- The GenAI service uses Qdrant as a vector store to retrieve relevant documents before querying the LLM. It adds the retrieved context to the prompt to improve the relevance of answers.
281290

282291
##### Integration
292+
283293
- The client UI sends user requests to the server, which forwards them to the GenAI service along with the user’s query and chat history to support multi-turn conversations. GenAI service then makes a similarity search in the vector database with the given query, and generates a respective answer. GenAI service is able to provide a proper answer altough no similar context is found in the vector database. (Endpoint: POST - `genai/generate`)
284294
- If the user wants to upload a recipe file, client UI sends the file content directly to the GenAI service, where the content of the file is chunked, embedded, and stored in the vector database. (Endpoint: POST - `genai/upload`)
285295

286296
##### Vector Database - Qdrant
297+
287298
We use Qdrant as the vector database to enable semantic search and retrieval-augmented generation (RAG) in RecipAI. Embeddings are generated using OpenAI’s small embedding model `text-embedding-3-small`.
288299

289300
```bash
@@ -295,7 +306,9 @@ embeddings = OpenAIEmbeddings(
295306
```
296307

297308
##### Environment Variables
309+
298310
- If you want to use cloud and local based LLM models, you need to set the respective api key in your `.env` file. Required `.env` variables:
311+
299312
```bash
300313
# Cloud based LLM models
301314
API_OPENAI="your openai key"
@@ -309,6 +322,7 @@ BASE_URL="base url where openwebui is hosted"
309322
```
310323

311324
- Example for Cloud LLM Models (defined in `genai/routes/routes.py`):
325+
312326
```bash
313327
llm_cloud_anthropic = CloudLLM(
314328
model_name="claude-3-sonnet-20240229",
@@ -367,7 +381,7 @@ The project includes Docker configurations for containerized deployment.
367381
docker compose -f docker-compose.yml up -d
368382
```
369383
2. Access the application:
370-
- Client: [http://localhost:3000](http://localhost:3000)
384+
- Client: [http://localhost:5173](http://localhost:5173)
371385
- API Gateway Service: [http://localhost:8080](http://localhost:8080)
372386
- User Service: [http://localhost:8081](http://localhost:8081)
373387
- Chat Service: [http://localhost:8082](http://localhost:8082)
@@ -397,34 +411,41 @@ The project includes Helm charts for Kubernetes deployment in the `recipai-chart
397411
## CI/CD Pipeline
398412

399413
The project includes a GitHub Actions workflow `ci-cd.yml` for:
400-
- **Testing Server**: For each push, server tests on server microservices are run.
414+
415+
- **Testing Server**: For each push, server tests on server microservices are run.
401416
- **Building Docker Images**: Automatically builds and pushes Docker images to GitHub Container Registry.
402417
- **Deploying Docker Images**: Automatically deploys the application to a production environment by using deployment manifests in helm for K8s cluster.
403418

404419
The project includes a GitHub Actions workflow `helm-manual.yml` for:
420+
405421
- **Deploying Docker Images**: Manually deploys the application to a production environment by using deployment manifests in helm for K8s cluster.
406422

407423
The project includes a GitHub Actions workflow `ansible-manual.yml` for:
424+
408425
- **Running Ansible Playbook**: Manually runs any Ansible playbook defined in the `ansible/playbooks` directory against an EC2 instance securely using SSH and Ansible Vault.
409426

410427
The project includes a GitHub Actions workflow `genai-tests.yml` for:
428+
411429
- **Running GenAI Tests**: Automatically runs the tests defined in the `genai/tests` directory on every code push in genai module.
412430

413431
## API Documentation
414432

415433
### User Service
434+
416435
API documentation is available in the [`server/user/openapi.yml`](server/user/openapi.yml) file.
417436

418437
### Chat Service
438+
419439
API documentation is available in the [`server/chat/openapi.yml`](server/chat/openapi.yml) file.
420440

421441
### GenAI Service
422-
API documentation is available in the [`genai/openapi.yaml`](genai/openapi.yaml) file.
423442

443+
API documentation is available in the [`genai/openapi.yaml`](genai/openapi.yaml) file.
424444

425445
## Requirements
426446

427447
### Functional Requirements
448+
428449
- Recipe Generation: The system must allow users to input a description or ingredients and receive a complete recipe in response.
429450
- Meal Planning: The system must allow users to request a meal plan for a specified number of days and meals per day.
430451
- Chat-Based Interaction: The user must be able to interact with the application via a conversational interface and therefore the system must preserve context in multi-turn conversations.
@@ -433,6 +454,7 @@ API documentation is available in the [`genai/openapi.yaml`](genai/openapi.yaml)
433454
- Chat History: The user must be able to view and revisit previous recipe requests and conversations.
434455

435456
### Nonfunctional Requirements
457+
436458
- Performance: The system must generate a recipe in response to a user query within 15 seconds in 95% of cases.
437459
- Scalability: The architecture must allow horizontal scaling of microservices.
438460
- Availability: The system must maintain 99.5% uptime during working hours.
@@ -446,58 +468,66 @@ API documentation is available in the [`genai/openapi.yaml`](genai/openapi.yaml)
446468
- Usability: The chat interface must be responsive and intuitive.
447469
- Observability & Monitoring: The system must expose Prometheus metrics for all critical services. Dashboards must be created in Grafana to visualize response latency, error rates, and user request volume. Besides that, at least one alert must be defined.
448470

449-
450471
## Architecture Overview - TODO
451472

452-
453-
454473
## Monitoring and Observability
474+
455475
RecipAI is equipped with a monitoring stack powered by Prometheus and Grafana, deployed in a Kubernetes environment. This setup enables real-time observability across all microservices, including the GenAI service, user and chat services, and the API gateway.
456476

457477
### Prometheus Configuration
478+
458479
Prometheus is configured via a Kubernetes ConfigMap named prometheus-config at [`recipai-chart/templates/prometheus/prometheus-configmap.yml`](recipai-chart/templates/prometheus/prometheus-configmap.yml). The configuration defines scrape jobs for each service, enabling Prometheus to collect metrics every 15 seconds.
459480

460481
All services expose Prometheus-compatible metrics:
482+
461483
- GenAI service uses a standard `/metrics` endpoint.
462484
- Server (Spring Boot) services (e.g., chat, user, api-gw) expose metrics via `/actuator/prometheus`.
463485

464486
For dockerized setup, respective prometheus config is also defined at [`monitoring/prometheus/prometheus.yml`](monitoring/prometheus/prometheus.yml)
465487

466488
### Grafana Dashboards
489+
467490
Grafana is used to visualize metrics collected by Prometheus. It is deployed via Helm and configured with:
491+
468492
- Dashboards for GenAI and chat service latency, error rates, and request counts.
469493
- Dashboard for general system metrics of the cluster
470494
- Contact points for alerting (Discord Webhook)
471495

472496
##### Included Dashboards
497+
473498
- system-dasboard.json: Infrastructure-level metrics (CPU, memory, nodes)
474-
- For dockerized setup: [`monitoring/grafana/dashboards/system-dashboard.json`](monitoring/grafana/dashboards/system-dashboard.json)
475-
- For helm setup: [`recipai-chart/dashboards/system-dashboard.json`](recipai-chart/dashboards/system-dashboard.json)
499+
- For dockerized setup: [`monitoring/grafana/dashboards/system-dashboard.json`](monitoring/grafana/dashboards/system-dashboard.json)
500+
- For helm setup: [`recipai-chart/dashboards/system-dashboard.json`](recipai-chart/dashboards/system-dashboard.json)
476501
- genai-dashboard.json: latency, error rates, and request counts
477-
- For dockerized setup: [`monitoring/grafana/dashboards/genai-dashboard.json`](monitoring/grafana/dashboards/genai-dashboard.json)
478-
- For helm setup: [`recipai-chart/dashboards/genai-dashboard.json`](recipai-chart/dashboards/genai-dashboard.json)
502+
- For dockerized setup: [`monitoring/grafana/dashboards/genai-dashboard.json`](monitoring/grafana/dashboards/genai-dashboard.json)
503+
- For helm setup: [`recipai-chart/dashboards/genai-dashboard.json`](recipai-chart/dashboards/genai-dashboard.json)
479504
- chat-dashboard.json: latency, error rates, and request counts
480-
- For dockerized setup: [`monitoring/grafana/dashboards/chat-dashboard.json`](monitoring/grafana/dashboards/chat-dashboard.json)
481-
- For helm setup: [`recipai-chart/dashboards/chat-dashboard.json`](recipai-chart/dashboards/chat-dashboard.json)
505+
- For dockerized setup: [`monitoring/grafana/dashboards/chat-dashboard.json`](monitoring/grafana/dashboards/chat-dashboard.json)
506+
- For helm setup: [`recipai-chart/dashboards/chat-dashboard.json`](recipai-chart/dashboards/chat-dashboard.json)
482507

483508
#### Accessing Grafana
509+
484510
- To access Grafana locally from the cluster, we can do port-forwarding:
485-
```bash
486-
kubectl port-forward svc/grafana 3000:3000
487-
```
488-
Then, it should be available at [`http://localhost:3000`](http://localhost:3000)
511+
512+
```bash
513+
kubectl port-forward svc/grafana 3000:3000
514+
```
515+
516+
Then, it should be available at [`http://localhost:3000`](http://localhost:3000)
489517

490518
- Or you can access it directly via our ingress in the cluster: [`https://grafana-tcd.student.k8s.aet.cit.tum.de`](https://grafana-tcd.student.k8s.aet.cit.tum.de)
491519

492520
- Grafana Credentials:
493-
- Username: `admin`
494-
- Password: `admin`
521+
- Username: `admin`
522+
- Password: `admin`
495523

496524
### Alerting Setup
525+
497526
Alerts are configured using Grafana’s Unified Alerting system. It defines receivers (e.g., Discord webhook) for high response generation duration in the GenAI service (for >20 seconds).
527+
498528
- Contact points are defined:
499-
- For dockerized setup: [`monitoring/grafana/provisioning/alerting/contact-points.yaml`](monitoring/grafana/provisioning/alerting/contact-points.yaml)
500-
- For helm setup: [`recipai-chart/templates/grafana/grafana-alerting.yml`](recipai-chart/templates/grafana/grafana-alerting.yml)
529+
- For dockerized setup: [`monitoring/grafana/provisioning/alerting/contact-points.yaml`](monitoring/grafana/provisioning/alerting/contact-points.yaml)
530+
- For helm setup: [`recipai-chart/templates/grafana/grafana-alerting.yml`](recipai-chart/templates/grafana/grafana-alerting.yml)
501531

502532
## License
503533

client/.env.development

Lines changed: 0 additions & 2 deletions
This file was deleted.

client/.env.production

Lines changed: 0 additions & 2 deletions
This file was deleted.

client/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
ARG NODE_ENV=production
21
FROM node:22-alpine AS build
32

4-
ARG NODE_ENV
5-
ENV NODE_ENV=$NODE_ENV
6-
7-
RUN echo "Building in $NODE_ENV mode"
83
WORKDIR /app
94

105
COPY package*.json ./

client/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"redirectUri": "http://localhost:5173",
3+
"clientId": "60a9e442420a386f2ddff0f60ed0801dd7e826f0710507e982d5afe6aa054334"
4+
}

client/nginx.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ server {
88
try_files $uri /index.html;
99
}
1010

11+
location /config.json {
12+
try_files $uri =404;
13+
add_header Cache-Control "no-cache, no-store, must-revalidate";
14+
add_header Pragma "no-cache";
15+
add_header Expires "0";
16+
}
17+
1118
location /api/ {
1219
proxy_pass http://apigw-service/;
1320
proxy_set_header Host $host;

0 commit comments

Comments
 (0)