Skip to content

Marcos Huaranga - SOLUTION CHALLENGE #488

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 18 commits into
base: main
Choose a base branch
from
Open

Conversation

dimacros
Copy link

@dimacros dimacros commented Apr 25, 2025

Todos los detalles se encuentran aqui:

https://github.com/dimacros/app-nodejs-codechallenge/blob/main/CHALLENGE.md

Yape Code Challenge 🚀

Welcome to the Yape Code Challenge! This project is designed to showcase your skills in building scalable, maintainable, and efficient backend systems. The challenge involves implementing a robust microservices architecture using modern tools and frameworks, with a focus on clean code, modular design, and seamless communication between services.

Key Features

  • Microservices Architecture: Leverage NestJS to build modular and scalable services.
  • Event-Driven Communication: Use Kafka for asynchronous messaging between services.
  • Database Integration: Design and implement a relational database schema using Prisma.
  • Clean Code Practices: Follow industry standards for maintainable and testable code.
  • Task Automation: Utilize TurboRepo for efficient task management and dependency handling.

Objectives

  1. Implement a Gateway service to handle API requests and route commands/queries to the appropriate processors.
  2. Build a Processor service to handle business logic, process commands, and respond to queries.
  3. Ensure seamless communication between services using Kafka as the messaging backbone.
  4. Design a relational database schema to store and manage transactional data.
  5. Write unit and integration tests to ensure the reliability of the system.

Technologies Used

  • NestJS: A progressive Node.js framework for building efficient and scalable server-side applications.
  • Kafka: A distributed event streaming platform for asynchronous communication.
  • Prisma: A modern ORM for database management and schema design.
  • TurboRepo: A high-performance build system for managing monorepos.
  • TypeScript: A strongly typed programming language for building robust applications.

Getting Started

Getting started is simple and hassle-free! Follow these steps to spin up the entire system with a single command:

  1. Clone the Repository:
    git clone https://github.com/your-repo/yape-code-challenge.git
    cd yape-code-challenge
    

This challenge is an excellent opportunity to demonstrate your expertise in backend development, microservices, and event-driven architectures. Good luck, and happy coding! 🚀

  1. Run the Services with Docker Compose: Ensure you have Docker and Docker Compose installed, then run:
    docker-compose up --build
    
     AND
    
 docker compose up -d
 pnpm install & pnpm dev

That's it! With a single command, your environment is ready to go. Dive into the code, explore the architecture, and start building something amazing.

## Try the endpoints

### 1. Create a Transaction

Endpoint: `POST /v1/transactions`

Description: Creates a new transaction.

Request Body:
```json
  {
    "transactionExternalId": "string",
    "accountExternalIdDebit": "string",
    "accountExternalIdCredit": "string",
    "transactionType": {
      "id": "string"
    },
    "value": 100.50
  }'

cURL Command:

  curl -X POST http://localhost:3000/v1/transactions \
  -H "Content-Type: application/json" \
  -d '{
    "transactionExternalId": "12345",
    "accountExternalIdDebit": "debit-account-id",
    "accountExternalIdCredit": "credit-account-id",
    "transactionType": {
      "id": "1"
    },
    "value": 100.50
  }'

2. Get All Transactions

Description: Retrieves all transactions based on query parameters.

  curl -X GET "http://localhost:3000/v1/transactions?page=1&limit=10"

3. Get Transaction by ID

Endpoint: GET /v1/transactions/:transactionExternalI

Description Retrieves a transaction by its external ID.

cURL Command:

  curl -X GET http://localhost:3000/v1/transactions/12345

dimacros added 18 commits April 21, 2025 20:53
- Updated transaction.module-definition.ts to include PrismaService as a provider, allowing for better integration with Prisma options.
- Refactored transaction.module.ts to streamline provider registration and ensure PrismaService is correctly injected.
- Renamed apps/api to apps/gateway in pnpm-lock.yaml for clarity and consistency.
- Updated dependencies in pnpm-lock.yaml to align with the latest versions of NestJS packages and added new apps/processor with necessary dependencies.
…rate PrismaService directly into TransactionModule

feat(transaction): update TransactionService to include updateTransactionStatus command and utilize defer for command execution

test(transaction): update e2e tests to reference the correct AppModule after transaction.module-definition removal

chore(db): add initial migration for Wallet, Transaction, TransactionType, and FraudFlag tables with appropriate constraints and enums

fix(prisma): rename TransactionStatus enum to TransactionStatusEnum and update references in Transaction model
feat: add TRANSACTION_SERVICE constant for dependency injection

feat: create TransactionProxyModule to encapsulate transaction-related services

chore: update tsconfig.json to remove baseUrl

chore: modify build script in core package.json to include prisma generate

refactor: remove deprecated database, fraud, and transaction Kafka config files

feat: implement dynamic database module for Prisma client configuration

refactor: clean up fraud-proxy module by removing unused adapters

refactor: update fraud module to remove CQRS module imports and dependencies

feat: enhance transaction commands and handlers for better structure and clarity

fix: ensure transaction value is converted to number in PrismaTransactionRepo

chore: streamline transaction module by removing unnecessary imports

chore: update package.json scripts for better development workflow

chore: clean up pnpm workspace configuration

chore: add format task to turbo.json for consistent code formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant