Skip to content

Ayrton Neves - Java Challenge #6

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 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Binary file added .DS_Store
Binary file not shown.
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Logs ##
/logs/

### MacOs ###
.DS_Store
.DS_Store
111 changes: 110 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,113 @@ 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.

# Solucion del Challenge #

Ejecutar el comando
```bash
docker-compose up -d
```

Se ejecutara los contenedores necesarios para solucionar
el alcance basico que se solicito en el Challenge

> [!IMPORTANT]
> Al ser ejecutado el Docker-Compose, las APIs se exponen en el puerto "8092" y cuando se ejecuta de forma local se ejecuta en el puerto "8091".

API para generar una nueva transferencia.
```bash
curl --location 'http://localhost:8091/transactions' \
--header 'Content-Type: application/json' \
--data '{
"accountExternalIdDebit": "550e8400-e29b-41d4-a716-446655447700",
"accountExternalIdCredit": "550e8400-e29b-41d4-a716-446655447701",
"transferTypeId": 1,
"value": 9900.10
}'
```

La respuesta que nos devolvera es una similar a la siguiente
```bash
{
"transactionExternalId": "ff2a75b5-9ba0-40a8-9329-e67a2ec19037",
"transactionType": {
"name": "1"
},
"transactionStatus": {
"name": "pending"
},
"value": "9900.10",
"createdAt": "2024-06-08T23:47:37.328-05:00"
}
```

API para consultar por un Id especifico
```bash
curl --location 'http://localhost:8091/transactions/4b2a815f-090b-4e4d-ba20-760cbad4c43d'
```
La respuesta sera una similar a la siguientes
```bash
{
"id": "4b2a815f-090b-4e4d-ba20-760cbad4c43d",
"accountExternalIdDebit": "550e8400-e29b-41d4-a716-446655447700",
"accountExternalIdCredit": "550e8400-e29b-41d4-a716-446655447701",
"transferTypeId": 1,
"value": 99.10,
"transactionStatus": "approved",
"transactionType": "1",
"createdAt": "2024-06-08T23:33:22.081-05:00"
}
```

API para consultar todas transferencias almacenadas
```bash
curl --location 'http://localhost:8092/transactions'

```

La respuesta sera una similar a la siguientes
```bash
[
{
"id": "2a6d9387-238a-4f07-9017-fd7506a6fd68",
"accountExternalIdDebit": "550e8400-e29b-41d4-a716-446655447700",
"accountExternalIdCredit": "550e8400-e29b-41d4-a716-446655447701",
"transferTypeId": 1,
"value": 99.10,
"transactionStatus": "approved",
"transactionType": "1",
"createdAt": "2024-06-08T23:46:47.985-05:00"
},
{
"id": "ff2a75b5-9ba0-40a8-9329-e67a2ec19037",
"accountExternalIdDebit": "550e8400-e29b-41d4-a716-446655447700",
"accountExternalIdCredit": "550e8400-e29b-41d4-a716-446655447701",
"transferTypeId": 1,
"value": 9900.10,
"transactionStatus": "rejected",
"transactionType": "1",
"createdAt": "2024-06-08T23:47:37.328-05:00"
}
]
```

El Flujo consiste en:

1.- Se genera una nueva transferencia y se almacena como "pending"
para que pueda ser evaluada por el proceso de anti-fraude.
2.- El segundo paso se ejecuta una suscripcion
al evento publicado en la "generación de transferencia"
y se ejecuta el proceso de anti-fraude.
3.- Se cambia el estado en base al resultado del proceso
ejecutado por el proceso de anti-fraude, el cual nos
indicara si la transferencia fue aceptada o rechazada.


Como parte de la solucion se tienen las siguientes consideraciones:

1.- Se agrego pool de conexiones para la BD.
2.- Se agrego TTL para los mensaje publicados.
3.- Se agrego el manejo del logback.
4.- Se agrego el manejo de perfiles para la creacion de imagenes con docker.
Binary file added codechallenge/.DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions codechallenge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Logs ##
/logs/

### MacOs ###
.DS_Store
18 changes: 18 additions & 0 deletions codechallenge/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.1
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
21 changes: 21 additions & 0 deletions codechallenge/DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM alpine:3.18.3

RUN apk add --no-cache openjdk17 maven

WORKDIR /app

COPY ./codechallenge .

RUN mvn clean package -D skipTests -P docker

FROM alpine:3.18.3

RUN apk add --no-cache openjdk17

WORKDIR /app

COPY --from=0 /app/target/codechallenge-0.0.1-SNAPSHOT.jar .

ENV SPRING_PROFILES_ACTIVE=docker

CMD ["/usr/bin/java", "-jar", "codechallenge-0.0.1-SNAPSHOT.jar"]
Loading