Skip to content
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
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typings/
.yarn-integrity

# dotenv environment variables file
*.env
.env
.env.test

Expand Down Expand Up @@ -102,3 +103,41 @@ dist

# TernJS port file
.tern-port


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
*.DS_Store
*.iws
*.iml
*.ipr

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

### VS Code ###
.vscode/

*.env
80 changes: 80 additions & 0 deletions README_DEV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Transaction Microservice - Development Guide

Este documento explica cómo levantar el proyecto en un entorno de desarrollo y cómo probar la API de transacciones y el servicio antifraude.

---

## Requisitos

- Docker & Docker Compose
- Postman o `curl` para probar la API
- Navegador para acceder a la interfaz web y PgAdmin

---

## Levantar el proyecto

1. Clonar el repositorio:
```bash
git https://github.com/lordjeferoon2/app-nodejs-codechallenge.git
cd app-nodejs-codechallenge
```

2. Levantar todos los servicios usando Docker Compose:
```bash
docker-compose up --build
```
Esto levantará:
- La API de transacciones (`localhost:8081`)
- Base de datos PostgreSQL
- PgAdmin (`localhost:5050`)
- Frontend web (`localhost:4300`)
- Otros servicios necesarios (antifraude, etc.)

---

## Probar la API de transacciones

### 1. Obtener los UUID de las cuentas

- Accede a PgAdmin en: [http://localhost:5050](http://localhost:5050)
- Credenciales:
```
Email: admin@admin.com
Password: admin
```
- Navega hasta la base de datos y la tabla `accounts`.
- Copia los UUID de las cuentas que se han creado (por ejemplo Juan Perez y Karla Rojas) y úsalos en el payload.

### 2. Hacer la petición `curl` de prueba

```bash
curl --location 'http://localhost:8081/api/transactions' --header 'Content-Type: application/json' --data '{
"accountExternalIdDebit": "UUID_DE_LA_CUENTA_DEBITO",
"accountExternalIdCredit": "UUID_DE_LA_CUENTA_CREDITO",
"transferTypeId": 1,
"value": 300.0
}'
```

> Reemplaza `UUID_DE_LA_CUENTA_DEBITO` y `UUID_DE_LA_CUENTA_CREDITO` por los UUID obtenidos desde PgAdmin.

---

## Probar usando la interfaz web

1. Accede a la web: [http://localhost:4300](http://localhost:4300)
2. Encontrarás los usuarios generados automáticamente:
- Juan Perez
- Karla Rojas
3. Desde la interfaz puedes realizar transferencias y probar el **servicio antifraude** directamente.

---

## Notas adicionales

- Todas las operaciones iniciales de la base de datos (borrado de registros y creación de cuentas) se realizan automáticamente al iniciar la aplicación.
- El servicio antifraude se ejecuta en paralelo y valida las transacciones en tiempo real.
- Si cambias los UUID en la base de datos, asegúrate de actualizar el payload de las pruebas.

---
2 changes: 2 additions & 0 deletions antifraud-microservice/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf
36 changes: 36 additions & 0 deletions antifraud-microservice/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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
*.DS_Store
*.iws
*.iml
*.ipr

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

### VS Code ###
.vscode/

*.env
19 changes: 19 additions & 0 deletions antifraud-microservice/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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
#
# http://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.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
19 changes: 19 additions & 0 deletions antifraud-microservice/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM maven:3.9.6-eclipse-temurin-21 AS builder

WORKDIR /app

COPY pom.xml .
RUN mvn dependency:go-offline -B

COPY src ./src
RUN mvn clean package -DskipTests

FROM eclipse-temurin:21-jdk

WORKDIR /app

COPY --from=builder /app/target/antifraud-microservice-0.0.1.jar app.jar

EXPOSE 8081

ENTRYPOINT ["java", "-jar", "app.jar"]
Loading