The goal of this challenge is implement a simplified version of PicPay service. It should be possible to perform transfers between users. This project adheres to RESTful principles and incorporates clean code practices, observability, and SOLID.
PicPay Simplified is a payment service that allows users to transfer and deposit money. It supports two types of users:
- Customer: Can send and receive money.
- Merchants: Can only receive money.
Each user has a wallet for transactions. The system ensures security, validation, and reliability during all financial operations.
- Programming Language: TypeScript
- Framework: Fastify
- Database: PostgreSQL
- Caching: Redis (Proposed)
- Containerization: Docker & Docker Compose
- Documentation: Swagger/OpenAPI
- CI/CD: GitHub Actions
- Messaging: RabbitMQ (Proposed)
- Monitoring: Prometheus, Grafana (Proposed)
- Testing: Vitest, supertest and Bruno for API testing
- Email and CPF/CNPJ must be uniques
- Customers can receive and perform transfers
- Merchant only receive transfers
- Balance must be sufficient before transfers
- Every transfer operation is wrapped in a database transaction to ensure atomicity. In case of an error, the system reverts all operations to maintain consistency.
- Transfers must be authorized with an external authorization service (GET)
- Users should receive a notification when a transfer is completed with a external notification service (POST)
- User can create an account as customer or merchant
- User can authenticate with email & password
- Transaction history is available for all users
- Customers can transfer money to other users (customers or merchants)
- Transfers are restricted to customers with sufficient balance
- All transfers must be authorized by an external service
- Merchants are limited to receiving transfers only
- Users should receive notifications (e.g., email or SMS) upon receiving a transfer
- Transfers must be reversible in case of any failure
The following diagram represents the database structure used in this project:
- Secure transfers between users.
- Wallet balance validation before transactions.
- Integration with external authorization service for validating transfers.
- Notifications for payees using a mocked external service.
- Rollback mechanism for failed transactions.
- Clean code following SOLID principles.
- Observability with logging and monitoring.
- Scalable and decoupled architecture.
- RESTful API with Swagger documentation.
- Support for relational and non-relational databases.
- Dockerized environment for consistent deployment.
- Automated CI/CD pipelines.
- Docker & Docker Compose
- Node v20+ with
pnpm
as package manager
-
Clone the repository:
git clone https://github.com/patricks-js/picpay-simplified.git cd picpay-simplified
-
Installing dependencies:
pnpm install
-
Start the services:
pnpm services:up
-
Running database migrations:
pnpm db:migrate
-
Seed database with some data:
pnpm db:seed
-
Start the application running:
pnpm dev
-
The API will be accessible at http://localhost:3333
-
The API documentation (swagger) will be accessible at http://localhost:3333/api/docs
Run the following command
pnpm test
To see the code coverage
pnpm test:coverage
- Error Handling: Enhance error messages and use semantic status codes.
- Monitoring: Add detailed transaction metrics for observability.
- Rate Limiting: Implement API rate limiting and request throttling for security.
- Database Optimization: Improve query performance with indexes and partitioning.
- Caching: Introduce caching strategies for high-volume transactions.