feat: Solución completa Yape Challenge Java - Event Sourcing + CQRS + Redis Cache#563
Open
FernandoCandela wants to merge 1 commit intoyaperos:mainfrom
Open
feat: Solución completa Yape Challenge Java - Event Sourcing + CQRS + Redis Cache#563FernandoCandela wants to merge 1 commit intoyaperos:mainfrom
FernandoCandela wants to merge 1 commit intoyaperos:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Yape Code Challenge
📌 Resumen
He completado el desafío de código de Yape implementando un sistema de microservicios robusto para gestión de transacciones financieras con validación anti-fraude en tiempo real.
✅ Requisitos Cumplidos
/transactionsy GET/transactions/{id}🚀 Extras Implementados (Opcional)
🏗️ Arquitectura Implementada
Microservicios
Flujo de Datos (Como Solicitado)
flowchart LR A[POST /transactions] --> B[Save Transaction<br/>Status: PENDING] B --> C[(PostgreSQL<br/>Database)] B --> D[Kafka Event<br/>transaction-created] D --> E[Anti-Fraud Service] E --> F{value > 1000?} F -->|No| G[Kafka Event<br/>Status: APPROVED] F -->|Yes| H[Kafka Event<br/>Status: REJECTED] G --> I[Update Transaction<br/>Status: APPROVED] H --> J[Update Transaction<br/>Status: REJECTED] I --> C J --> C📊 Tech Stack
Tecnologías Implementadas
Backend:
Base de Datos:
Mensajería:
Infraestructura:
🎯 API Endpoints Implementados
1️⃣ Crear Transacción (Requerido)
Respuesta (201 Created):
{ "transactionExternalId": "550e8400-e29b-41d4-a716-446655440000", "transactionStatus": "PENDING", "transactionType": 1, "value": 120.00, "createdAt": "2026-01-04T10:30:00Z" }2️⃣ Obtener Transacción (Requerido)
Respuesta (200 OK):
{ "transactionExternalId": "550e8400-e29b-41d4-a716-446655440000", "transactionType": { "name": "Transfer" }, "transactionStatus": { "name": "approved" }, "value": 120, "createdAt": "2026-01-04T10:30:00Z" }3️⃣ Event Store API (Extra - Para Auditoría)
🚀 Cómo Ejecutar
Opción 1: Docker Compose (Recomendado)
Opción 2: Ejecución Local (Desarrollo)
Verificar que está funcionando
🔄 Flujo de Transacciones Detallado
Creación de Transacción (Write Path - CQRS)
/api/v1/transactionscon datos de la transacciónCreateTransactionCommandTransactionCreatedEventdomain_events)transactions)transaction-createdtransaction-statusTransactionStatusUpdatedEventConsulta de Transacción (Read Path - CQRS)
Con Cache Hit (80-90% de los casos):
/api/v1/transactions/{id}GetTransactionQueryCon Cache Miss:
/api/v1/transactions/{id}GetTransactionQuery📈 Optimización para Alto Volumen (Opcional pero Implementado)
El desafío preguntaba: "¿Cómo manejarías escenarios de alto volumen con gran cantidad de escrituras y lecturas concurrentes?"
Mi Solución Implementada:
1. Redis Distributed Cache
2. Event Sourcing
3. CQRS (Command Query Responsibility Segregation)
4. Connection Pooling (HikariCP)
5. Procesamiento Asíncrono (Kafka)
Métricas de Performance
🧪 Testing
Tests Implementados:
📦 Estructura del Proyecto
🔍 Patrones y Principios Aplicados
Arquitectura
Patrones de Diseño
Principios SOLID
🎯 Decisiones Técnicas Importantes
1. ¿Por qué Event Sourcing?
/eventspara inspección2. ¿Por qué CQRS?
3. ¿Por qué Redis?
4. ¿Por qué Kafka?
📚 Documentación Adicional
Yape-Challenge.postman_collection.json)🐛 Troubleshooting
Problema: Los servicios no se levantan
Problema: Kafka no conecta
Problema: No se actualizan los estados
✅ Checklist del Desafío
Requisitos Obligatorios
Extras Implementados
🎓 Aprendizajes y Desafíos
Lo que fue desafiante:
Lo que mejoraría con más tiempo:
📞 Contacto
Si tienen alguna pregunta sobre la implementación o necesitan aclaraciones, estoy disponible para discutirlo.
¡Gracias por revisar mi solución! 🚀