diff --git a/persistence-modules/fauna/pom.xml b/persistence-modules/fauna/pom.xml
index 8c985e0b7c..cd66bf247b 100644
--- a/persistence-modules/fauna/pom.xml
+++ b/persistence-modules/fauna/pom.xml
@@ -41,6 +41,18 @@
spring-security-test
test
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
+
+ org.projectlombok
+ lombok
+ provided
+
diff --git a/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/FaunaClients.java b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/FaunaClients.java
new file mode 100644
index 0000000000..c4e1d52b5b
--- /dev/null
+++ b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/FaunaClients.java
@@ -0,0 +1,42 @@
+package com.baeldung.healthapp;
+
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import com.faunadb.client.FaunaClient;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@ConfigurationProperties
+@Component
+public class FaunaClients {
+
+ private final Map faunaConnections = new HashMap<>();
+ private final Map faunaSecrets = new HashMap<>();
+
+ public FaunaClient getFaunaClient(String region) throws MalformedURLException {
+
+ String faunaUrl = faunaConnections.get(region);
+ String faunaSecret = faunaSecrets.get(region);
+
+ log.info("Creating Fauna Client for Region:{} with URL:{}", region, faunaUrl);
+
+ return FaunaClient.builder()
+ .withEndpoint(faunaUrl)
+ .withSecret(faunaSecret)
+ .build();
+ }
+
+ public Map getFaunaConnections() {
+ return faunaConnections;
+ }
+
+ public Map getFaunaSecrets() {
+ return faunaSecrets;
+ }
+}
diff --git a/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/FaunaHealthApplication.java b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/FaunaHealthApplication.java
new file mode 100644
index 0000000000..ac09e4cd36
--- /dev/null
+++ b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/FaunaHealthApplication.java
@@ -0,0 +1,13 @@
+package com.baeldung.healthapp;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class FaunaHealthApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(FaunaHealthApplication.class, args);
+ }
+
+}
diff --git a/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/domain/HealthData.java b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/domain/HealthData.java
new file mode 100644
index 0000000000..9ee320c3d5
--- /dev/null
+++ b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/domain/HealthData.java
@@ -0,0 +1,17 @@
+package com.baeldung.healthapp.domain;
+
+import java.time.ZonedDateTime;
+
+public record HealthData(
+
+ String userId,
+
+ float temperature,
+ float pulseRate,
+ int bpSystolic,
+ int bpDiastolic,
+
+ double latitude,
+ double longitude,
+ ZonedDateTime timestamp) {
+}
diff --git a/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/DefaultGeoLocationService.java b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/DefaultGeoLocationService.java
new file mode 100644
index 0000000000..b643714972
--- /dev/null
+++ b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/DefaultGeoLocationService.java
@@ -0,0 +1,12 @@
+package com.baeldung.healthapp.service;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class DefaultGeoLocationService implements GeoLocationService {
+
+ @Override
+ public String getRegion(double latitude, double longitude) {
+ return "EU";
+ }
+}
diff --git a/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/DefaultHealthService.java b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/DefaultHealthService.java
new file mode 100644
index 0000000000..8e44b4b243
--- /dev/null
+++ b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/DefaultHealthService.java
@@ -0,0 +1,58 @@
+package com.baeldung.healthapp.service;
+
+import static com.faunadb.client.query.Language.Collection;
+import static com.faunadb.client.query.Language.Create;
+import static com.faunadb.client.query.Language.Now;
+import static com.faunadb.client.query.Language.Obj;
+import static com.faunadb.client.query.Language.Value;
+
+import java.net.MalformedURLException;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.baeldung.healthapp.FaunaClients;
+import com.baeldung.healthapp.domain.HealthData;
+import com.faunadb.client.FaunaClient;
+import com.faunadb.client.types.Value;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Component
+@Slf4j
+public class DefaultHealthService implements HealthService {
+
+ @Autowired
+ private GeoLocationService geoLocationService;
+
+ @Autowired
+ private FaunaClients faunaClients;
+
+ @Override
+ public void process(HealthData healthData) throws MalformedURLException, InterruptedException, ExecutionException {
+
+ String region = geoLocationService.getRegion( //
+ healthData.latitude(), //
+ healthData.longitude());
+
+ FaunaClient faunaClient = faunaClients.getFaunaClient(region);
+
+ Value queryResponse = faunaClient.query(
+ Create(Collection("healthdata"),
+ Obj("data",
+ Obj(Map.of(
+ "userId", Value(healthData.userId()),
+ "temperature", Value(healthData.temperature()),
+ "pulseRate", Value(healthData.pulseRate()),
+ "bpSystolic", Value(healthData.bpSystolic()),
+ "bpDiastolic", Value(healthData.bpDiastolic()),
+ "latitude", Value(healthData.latitude()),
+ "longitude", Value(healthData.longitude()),
+ "timestamp", Now()))))
+ ).get();
+
+ log.info("Query response received from Fauna: {}", queryResponse);
+ }
+}
diff --git a/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/GeoLocationService.java b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/GeoLocationService.java
new file mode 100644
index 0000000000..43a3204610
--- /dev/null
+++ b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/GeoLocationService.java
@@ -0,0 +1,6 @@
+package com.baeldung.healthapp.service;
+
+public interface GeoLocationService {
+
+ String getRegion(double latitude, double longitude);
+}
diff --git a/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/HealthService.java b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/HealthService.java
new file mode 100644
index 0000000000..eadf12cc08
--- /dev/null
+++ b/persistence-modules/fauna/src/main/java/com/baeldung/healthapp/service/HealthService.java
@@ -0,0 +1,10 @@
+package com.baeldung.healthapp.service;
+
+import java.net.MalformedURLException;
+import java.util.concurrent.ExecutionException;
+
+import com.baeldung.healthapp.domain.HealthData;
+
+public interface HealthService {
+ void process(HealthData healthData) throws MalformedURLException, InterruptedException, ExecutionException;
+}
diff --git a/persistence-modules/fauna/src/main/resources/application.properties b/persistence-modules/fauna/src/main/resources/application.properties
index e69de29bb2..d17d80c13b 100644
--- a/persistence-modules/fauna/src/main/resources/application.properties
+++ b/persistence-modules/fauna/src/main/resources/application.properties
@@ -0,0 +1,10 @@
+# Fauna Blog Service
+fauna.region=EU
+fauna.secret=
+
+# Fauna Health App
+fauna-connections.EU=https://db.eu.fauna.com/
+fauna-secrets.EU=fnAEsvJPtDAA0MyJZzrPNfjYGN49aiJe-7QfPdSo
+
+fauna-connections.US=https://db.us.fauna.com/
+fauna-secrets.US=fnAEsvKMCyAAQnx8-T_lWbhH91HOH_9374GpD4en
\ No newline at end of file
diff --git a/persistence-modules/fauna/src/test/java/com/baeldung/healthapp/service/DefaultHealthServiceManualTest.java b/persistence-modules/fauna/src/test/java/com/baeldung/healthapp/service/DefaultHealthServiceManualTest.java
new file mode 100644
index 0000000000..f77eb623b6
--- /dev/null
+++ b/persistence-modules/fauna/src/test/java/com/baeldung/healthapp/service/DefaultHealthServiceManualTest.java
@@ -0,0 +1,55 @@
+package com.baeldung.healthapp.service;
+
+import static org.mockito.Mockito.when;
+
+import java.net.MalformedURLException;
+import java.time.ZonedDateTime;
+import java.util.concurrent.ExecutionException;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+
+import com.baeldung.healthapp.FaunaHealthApplication;
+import com.baeldung.healthapp.domain.HealthData;
+
+@SpringBootTest(classes = FaunaHealthApplication.class)
+class DefaultHealthServiceManualTest {
+
+ @Autowired
+ private DefaultHealthService defaultHealthService;
+
+ @MockBean
+ private GeoLocationService geoLocationService;
+
+ @Test
+ void givenEURegion_whenProcess_thenRequestSentToEURegion() throws MalformedURLException, InterruptedException, ExecutionException {
+
+ HealthData healthData = new HealthData("user-1-eu", //
+ 37.5f, //
+ 99f, //
+ 120, 80, //
+ 51.50, -0.07, //
+ ZonedDateTime.now());
+
+ when(geoLocationService.getRegion(51.50, -0.07)).thenReturn("EU");
+
+ defaultHealthService.process(healthData);
+ }
+
+ @Test
+ void givenUSRegion_whenProcess_thenRequestSentToUSRegion() throws MalformedURLException, InterruptedException, ExecutionException {
+
+ HealthData healthData = new HealthData("user-1-us", //
+ 38.0f, //
+ 100f, //
+ 115, 85, //
+ 40.75, -74.30, //
+ ZonedDateTime.now());
+
+ when(geoLocationService.getRegion(40.75, -74.30)).thenReturn("US");
+
+ defaultHealthService.process(healthData);
+ }
+}