Skip to content

Commit c9b145f

Browse files
EddeCCCareydependabot[bot]bryanwong69420TayJieHao386
authored
synchronize petclinic (#10)
* Bump to Chaos Monkey 3.1.0 (spring-petclinic#264) * Bump org.webjars:bootstrap from 3.3.7-1 to 3.4.0 in /spring-petclinic-api-gateway (spring-petclinic#269) * Bump org.webjars:bootstrap in /spring-petclinic-api-gateway Bumps [org.webjars:bootstrap](https://github.com/webjars/bootstrap) from 3.3.7-1 to 3.4.0. - [Commits](webjars/bootstrap@bootstrap-3.3.7-1...bootstrap-3.4.0) --- updated-dependencies: - dependency-name: org.webjars:bootstrap dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * Report bootstrap version to wro4j.xml --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Antoine Rey <[email protected]> * Add Dev Container configuration (spring-petclinic#271) * Add Dev Container configuration * Remove the postCreateCommand * Add configuration tips for VS Code in Dev Container * Add GitHub Codespaces badge * Bump to Spring Cloud 2023.0.3 and Spring Boot 3.2.7 (spring-petclinic#272) * Bootstrap 5 with SCSS migration (spring-petclinic#273) * Bootstrap 5 with SCSS migration * Bump Angular version * Remove class="container" * Upgrade to Maven 3.9.8 and Maven Wrapper 3.3.2 (spring-petclinic#274) * Disable Github linguist support for CSS * Add Microservices Overview to readme (spring-petclinic#276) * Added text file * Delete Text File * Update microservices overview in README file --------- Co-authored-by: TayJieHao386 <[email protected]> * Add user friendly error when Java < 17 is used (Issue spring-petclinic#280) (spring-petclinic#286) * Add user friendly error when Java < 17 is used (Issue spring-petclinic#280) * pom.xml updated * java version property updated * Removed Bracket [Issue spring-petclinic#280] fixed build * Generative AI support for Spring Petclinic Microservices (spring-petclinic#281) * updated git ignore * New microservice for generative ai chatbot based on Spring AI. Supports listing vets, listing owners, adding owners and adding pets to owners * Update README.md * Use webjar as webjar * Externalise JavaScript for handling chatbox interaction * Use @PostMapping for the /fallback endpoint * Configure the /fallback uri for the POST verb only * Move the spring-ai.png to the docs directory * Switch by default to the openai demo account * Use lambda expression * Remove Lombok from the genai-service * Remove creds.yaml * Fix SonarQube issues * Fix SonarQube issues (second attempt) * Add the genai-service * Use lambda expression * Fix Docker warnings * Setting the GenAI environment variables --------- Co-authored-by: Antoine Rey <[email protected]> * Add "Open with Codeanywhere" badge to README.md (spring-petclinic#292) * Get rid of Lombok spring-petclinic#251 (spring-petclinic#300) * Bump to Spring Cloud 2024 and Spring Boot 3.4.1 (spring-petclinic#302) * Externalise the genai-service configuration (spring-petclinic#301) * JetBrains support for Open-Source Projects (spring-petclinic#304) * small fixes --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Antoine Rey <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Wong Jia Cin <[email protected]> Co-authored-by: TayJieHao386 <[email protected]> Co-authored-by: Ankush Thakur <[email protected]> Co-authored-by: odedia <[email protected]> Co-authored-by: Nikola Balic <[email protected]>
1 parent 2bc49d4 commit c9b145f

File tree

84 files changed

+12086
-780
lines changed

Some content is hidden

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

84 files changed

+12086
-780
lines changed

.devcontainer/devcontainer.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "Spring Petclinic Microservices",
3+
// Java Development Container Images https://mcr.microsoft.com/en-us/product/devcontainers/java/tags
4+
"image": "mcr.microsoft.com/devcontainers/java:17-bullseye",
5+
// Features list https://containers.dev/features
6+
"features": {
7+
"ghcr.io/devcontainers/features/java:1": {
8+
"installMaven": "true",
9+
"installGradle": "false"
10+
},
11+
"ghcr.io/devcontainers/features/azure-cli:1":{}, // Install Azure CLI
12+
"ghcr.io/devcontainers/features/docker-in-docker:2":{}, // install docker
13+
},
14+
"customizations": {
15+
// Configure properties specific to VScode
16+
"vscode": {
17+
"settings": {
18+
// VSCode settings https://github.com/redhat-developer/vscode-java/blob/master/README.md
19+
"java.server.launchMode": "Standard"
20+
},
21+
"extensions":[
22+
"vscjava.vscode-java-pack",
23+
"vscjava.vscode-maven",
24+
"github.vscode-github-actions",
25+
"github.vscode-pull-request-github",
26+
"redhat.vscode-xml",
27+
"vmware.vscode-boot-dev-pack",
28+
"mhutchie.git-graph"
29+
]
30+
},
31+
},
32+
"forwardPorts": [8080, 8888, 8761]
33+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.css linguist-generated=true

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ target/
1919

2020
# Branch switching
2121
generated/
22+
23+
**/.DS_Store

.mvn/wrapper/maven-wrapper.jar

481 Bytes
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
18-
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
19+
distributionSha256Sum=8351955a9acf2f83c136c4eee0f6db894ab6265fdbe0a94b32a380307dbaa3e1

README.md

+74-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Distributed version of the Spring PetClinic Sample Application built with Spring Cloud
1+
# Distributed version of the Spring PetClinic Sample Application built with Spring Cloud and Spring AI
22

33
[![Build Status](https://github.com/spring-petclinic/spring-petclinic-microservices/actions/workflows/maven-build.yml/badge.svg)](https://github.com/spring-petclinic/spring-petclinic-microservices/actions/workflows/maven-build.yml)
44
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
@@ -7,15 +7,20 @@ This microservices branch was initially derived from [AngularJS version](https:/
77
To achieve that goal, we use Spring Cloud Gateway, Spring Cloud Circuit Breaker, Spring Cloud Config, Micrometer Tracing, Resilience4j, Open Telemetry
88
and the Eureka Service Discovery from the [Spring Cloud Netflix](https://github.com/spring-cloud/spring-cloud-netflix) technology stack.
99

10+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/spring-petclinic/spring-petclinic-microservices)
11+
12+
[![Open in Codeanywhere](https://codeanywhere.com/img/open-in-codeanywhere-btn.svg)](https://app.codeanywhere.com/#https://github.com/spring-petclinic/spring-petclinic-microservices)
13+
1014
## Starting services locally without Docker
1115

12-
Every microservice is a Spring Boot application and can be started locally using IDE ([Lombok](https://projectlombok.org/) plugin has to be set up) or `../mvnw spring-boot:run` command. Please note that supporting services (Config and Discovery Server) must be started before any other application (Customers, Vets, Visits and API).
16+
Every microservice is a Spring Boot application and can be started locally using IDE or `../mvnw spring-boot:run` command.
17+
Please note that supporting services (Config and Discovery Server) must be started before any other application (Customers, Vets, Visits and API).
1318
Startup of Tracing server, Admin server, Grafana and Prometheus is optional.
1419
If everything goes well, you can access the following services at given location:
1520
* Discovery Server - http://localhost:8761
1621
* Config Server - http://localhost:8888
1722
* AngularJS frontend (API Gateway) - http://localhost:8080
18-
* Customers, Vets and Visits Services - random port, check Eureka Dashboard
23+
* Customers, Vets, Visits and GenAI Services - random port, check Eureka Dashboard
1924
* Tracing Server (Zipkin) - http://localhost:9411/zipkin/ (we use [openzipkin](https://github.com/openzipkin/zipkin/tree/main/zipkin-server))
2025
* Admin Server (Spring Boot Admin) - http://localhost:9090
2126
* Grafana Dashboards - http://localhost:3000
@@ -52,7 +57,7 @@ For instance, if you target container images for an Apple M2, you could use the
5257
```
5358

5459
Once images are ready, you can start them with a single command
55-
`docker-compose up` or `podman-compose up`.
60+
`docker compose up` or `podman-compose up`.
5661

5762
Containers startup order is coordinated with the `service_healthy` condition of the Docker Compose [depends-on](https://github.com/compose-spec/compose-spec/blob/main/spec.md#depends_on) expression
5863
and the [healthcheck](https://github.com/compose-spec/compose-spec/blob/main/spec.md#healthcheck) of the service containers.
@@ -79,13 +84,62 @@ Each of the java based applications is started with the `chaos-monkey` profile i
7984

8085
You can then access petclinic here: http://localhost:8080/
8186

87+
## Microservices Overview
88+
89+
This project consists of several microservices:
90+
- **Customers Service**: Manages customer data.
91+
- **Vets Service**: Handles information about veterinarians.
92+
- **Visits Service**: Manages pet visit records.
93+
- **GenAI Service**: Provides a chatbot interface to the application.
94+
- **API Gateway**: Routes client requests to the appropriate services.
95+
- **Config Server**: Centralized configuration management for all services.
96+
- **Discovery Server**: Eureka-based service registry.
97+
98+
Each service has its own specific role and communicates via REST APIs.
99+
100+
82101
![Spring Petclinic Microservices screenshot](docs/application-screenshot.png)
83102

84103

85104
**Architecture diagram of the Spring Petclinic Microservices**
86105

87106
![Spring Petclinic Microservices architecture](docs/microservices-architecture-diagram.jpg)
88107

108+
## Integrating the Spring AI Chatbot
109+
110+
Spring Petclinic integrates a Chatbot that allows you to interact with the application in a natural language. Here are some examples of what you could ask:
111+
112+
1. Please list the owners that come to the clinic.
113+
2. Are there any vets that specialize in surgery?
114+
3. Is there an owner named Betty?
115+
4. Which owners have dogs?
116+
5. Add a dog for Betty. Its name is Moopsie.
117+
6. Create a new owner.
118+
119+
![Screenshot of the chat dialog](docs/spring-ai.png)
120+
121+
This `spring-petlinic-genai-service` microservice currently supports **OpenAI** (default) or **Azure's OpenAI** as the LLM provider.
122+
In order to start the microservice, perform the following steps:
123+
124+
1. Decide which provider you want to use. By default, the `spring-ai-openai-spring-boot-starter` dependency is enabled.
125+
You can change it to `spring-ai-azure-openai-spring-boot-starter`in the `pom.xml`.
126+
2. Create an OpenAI API key or a Azure OpenAI resource in your Azure Portal.
127+
Refer to the [OpenAI's quickstart](https://platform.openai.com/docs/quickstart) or [Azure's documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/) for further information on how to obtain these.
128+
You only need to populate the provider you're using - either openai, or azure-openai.
129+
If you don't have your own OpenAI API key, don't worry!
130+
You can temporarily use the `demo` key, which OpenAI provides free of charge for demonstration purposes.
131+
This `demo` key has a quota, is limited to the `gpt-4o-mini` model, and is intended solely for demonstration use.
132+
With your own OpenAI account, you can test the `gpt-4o` model by modifying the `deployment-name` property of the `application.yml` file.
133+
3. Export your API keys and endpoint as environment variables:
134+
* either OpenAI:
135+
```bash
136+
export OPENAI_API_KEY="your_api_key_here"
137+
```
138+
* or Azure OpenAI:
139+
```bash
140+
export AZURE_OPENAI_ENDPOINT="https://your_resource.openai.azure.com"
141+
export AZURE_OPENAI_KEY="your_api_key_here"
142+
```
89143

90144
## In case you find a bug/suggested improvement for Spring Petclinic Microservices
91145

@@ -207,6 +261,17 @@ Be sure to turn on "Use containerd for pulling and storing images" in the Docker
207261
The `scripts/pushImages.sh` and `scripts/tagImages.sh` shell scripts could also be used once you build your image with the `buildDocker` maven profile.
208262
The `scripts/tagImages.sh` requires to declare the `VERSION` env variable.
209263
264+
## Compiling the CSS
265+
266+
There is a `petclinic.css` in `spring-petclinic-api-gateway/src/main/resources/static/css`.
267+
It was generated from the `petclinic.scss` source, combined with the [Bootstrap](https://getbootstrap.com/) library.
268+
If you make changes to the `scss`, or upgrade Bootstrap, you will need to re-compile the CSS resources
269+
using the Maven profile `css` of the `spring-petclinic-api-gateway`module.
270+
```bash
271+
cd spring-petclinic-api-gateway
272+
mvn generate-resources -P css
273+
```
274+
210275
## Interesting Spring Petclinic forks
211276
212277
The Spring Petclinic `main` branch in the main [spring-projects](https://github.com/spring-projects/spring-petclinic)
@@ -228,7 +293,11 @@ For pull requests, editor preferences are available in the [editor config](.edit
228293
[Configuration repository]: https://github.com/spring-petclinic/spring-petclinic-microservices-config
229294
[Spring Boot Actuator Production Ready Metrics]: https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html
230295
231-
# InspectIT related Stuff
296+
## Supported by
297+
298+
[![JetBrains logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg)](https://jb.gg/OpenSourceSupport)
299+
300+
# InspectIT related stuff
232301
233302
## Soap Service Testing
234303
For more information about testing the custom soap service and client, please refer to the [README](spring-petclinic-soap-service/README.md) in the soap folder.

docker-compose.yml

+23-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3'
2-
31
services:
42
config-server:
53
image: inspectit/spring-petclinic-config-server:${INSPECTIT_PETCLINIC_VERSION}
@@ -79,6 +77,25 @@ services:
7977
ports:
8078
- 8083:8083
8179

80+
genai-service:
81+
image: springcommunity/spring-petclinic-genai-service
82+
container_name: genai-service
83+
environment:
84+
- OPENAI_API_KEY=${OPENAI_API_KEY}
85+
- AZURE_OPENAI_KEY=${AZURE_OPENAI_KEY}
86+
- AZURE_OPENAI_ENDPOINT=${AZURE_OPENAI_ENDPOINT}
87+
deploy:
88+
resources:
89+
limits:
90+
memory: 512M
91+
depends_on:
92+
config-server:
93+
condition: service_healthy
94+
discovery-server:
95+
condition: service_healthy
96+
ports:
97+
- 8084:8084
98+
8299
soap-service:
83100
image: inspectit/spring-petclinic-soap-service:${INSPECTIT_PETCLINIC_VERSION}
84101
container_name: soap-service
@@ -92,7 +109,7 @@ services:
92109
discovery-server:
93110
condition: service_healthy
94111
ports:
95-
- 8877:8877
112+
- 8877:8877
96113

97114
soap-client:
98115
image: inspectit/spring-petclinic-soap-client:${INSPECTIT_PETCLINIC_VERSION}
@@ -132,7 +149,8 @@ services:
132149
limits:
133150
memory: 512M
134151
environment:
135-
- JAVA_OPTS=-XX:+UnlockExperimentalVMOptions -Djava.security.egd=file:/dev/./urandom
152+
# Waiting for https://github.com/openzipkin/zipkin/issues/3786
153+
- JAVA_OPTS=-XX:UseSVE=0
136154
ports:
137155
- 9411:9411
138156

@@ -161,7 +179,7 @@ services:
161179
limits:
162180
memory: 256M
163181
ports:
164-
- 3000:3000
182+
- 3030:3030
165183

166184
prometheus-server:
167185
build: ./docker/prometheus

docker/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM eclipse-temurin:17 as builder
1+
FROM eclipse-temurin:17 AS builder
22
WORKDIR application
33
ARG ARTIFACT_NAME
44
COPY ${ARTIFACT_NAME}.jar application.jar
@@ -11,7 +11,7 @@ WORKDIR application
1111
ARG EXPOSED_PORT
1212
EXPOSE ${EXPOSED_PORT}
1313

14-
ENV SPRING_PROFILES_ACTIVE docker
14+
ENV SPRING_PROFILES_ACTIVE=docker
1515

1616
COPY --from=builder application/dependencies/ ./
1717

46.3 KB
Loading

docs/spring-ai.png

107 KB
Loading

0 commit comments

Comments
 (0)