Skip to content

feature: resolved challenge #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: configure docker compose mwith microservices
  • Loading branch information
wpalomino20 committed Aug 22, 2024
commit 5affadeadae1abf3e1bf17463b01988032a4cd7b
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Solution

To solve the technical challenge, apply everything requested, first create a microservice that subscribes to Kafka topics and with this can create transactions in the DB and in the respective Topic and the second microservice is responsible for subscribing to the Kafka topic. creation to obtain the amount and be able to validate whether it is fraudulent or not according to the condition provided, in case the fraud microservice is restarted it will resume all the requests that were pending to analyze whether or not it was a fraud, the technological stack en Reactive programming with Java 17 (webflux), as well as GraphQL, H2 database with JPA, were used for the requests.


# Yape Code Challenge :rocket:

Our code challenge will let you marvel us with your Jedi coding skills :smile:.
Expand All @@ -9,6 +14,7 @@ Don't forget that the proper way to submit your work is to fork the repo and cre
- [Tech Stack](#tech-stack)
- [Optional](#optional)
- [Send us your challenge](#send-us-your-challenge)
- [Solution](#solution)

# Problem

Expand Down Expand Up @@ -81,4 +87,6 @@ You can use Graphql;

When you finish your challenge, after forking a repository, you **must** open a pull request to our repository. There are no limitations to the implementation, you can follow the programming paradigm, modularization, and style that you feel is the most appropriate solution.

If you have any questions, please let us know.
If you have any questions, please let us know.


13 changes: 13 additions & 0 deletions app-antifraud-microservice-kafka/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Etapa 1: Compilación de la aplicación
FROM maven:3.8.8-eclipse-temurin-17 AS build
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean package -DskipTests

# Etapa 2: Construcción de la imagen
FROM openjdk:17-jdk-slim
WORKDIR /app
COPY --from=build /app/target/app-antifraud-microservice-kafka-1.0-SNAPSHOT.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
16 changes: 16 additions & 0 deletions app-antifraud-microservice-kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,20 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AntifraudService {
public AntifraudService() {
objectMapper.registerModule(new JavaTimeModule());
Map<String, Object> props = new HashMap<>();
props.put("bootstrap.servers", "localhost:9092");
props.put("bootstrap.servers", "kafka:29092");
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("auto.offset.reset", "earliest");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
server:
port: 8090
port: 8090

spring:
kafka:
bootstrap-servers: kafka:9092
13 changes: 13 additions & 0 deletions app-microservice-kafka/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Etapa 1: Compilación de la aplicación
FROM maven:3.8.8-eclipse-temurin-17 AS build
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean package -DskipTests

# Etapa 2: Construcción de la imagen
FROM openjdk:17-jdk-slim
WORKDIR /app
COPY --from=build /app/target/app-microservice-kafka-1.0-SNAPSHOT.jar app.jar
EXPOSE 8081
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
17 changes: 16 additions & 1 deletion app-microservice-kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@
<version>17.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public TransactionService(TransactionRepository transactionRepository, Transacti
objectMapper.registerModule(new JavaTimeModule());

Map<String, Object> props = new HashMap<>();
props.put("bootstrap.servers", "localhost:9092");
props.put("bootstrap.servers", "kafka:29092");
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
SenderOptions<String, String> senderOptions = SenderOptions.create(props);
Expand Down
2 changes: 2 additions & 0 deletions app-microservice-kafka/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ spring:
init:
mode: always
data-locations: classpath:query.sql
kafka:
bootstrap-servers: kafka:9092

server:
port: 8080
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,22 @@ services:
ZK_HOSTS: zookeeper:2181
depends_on:
- zookeeper
- kafka
app-microservice:
build:
context: ./app-microservice-kafka
dockerfile: Dockerfile
ports:
- "8080:8080"
depends_on:
- postgres
- kafka

app-antifraud:
build:
context: ./app-antifraud-microservice-kafka
dockerfile: Dockerfile
ports:
- "8081:8081"
depends_on:
- kafka