Solution for the PicPay challenge aimed at backend. The requirements for the challenge can be found here
- Javascript/Typescript: Main programming language.
- NodeJS: Platform to run Javascript
- PostgreSQL: Relational database to store persistent data.
- NestJS: Web framework for building APIs in NodeJS.
- Prisma ORM: ORM (Object-Relational Mapping) for communication with the database.
- Docker: Development environment for PostgreSQL and Redis.
- RabbitMQ: Message broker to handle asynchronous communication through queues
The application follows the following design patterns:
-
Clean Architecture: The project structure is organized in layers (entities, use cases, interfaces) to separate concerns and facilitate maintenance.
-
Domain Driven Design (DDD): The software design is domain-oriented, focusing on business rules and main entities.
-
Dependency Injection: Inversion of control and dependency injection are used to ensure code flexibility and testability.
-
Automated Testing: Unit, integration and end-2-end tests are written to ensure code quality.
-
Asynchronous Communication: Asynchronous communication within a system brings the possibility of making parts communicate through messages, without waiting for an immediate response.
One of the highlights of this solution is the use of Domain Events. This concept ensures data consistency when a user performs a transfer and a notification must be sent to the end user. By taking advantage of domain events, the business logic related to sending notifications is decoupled from the core of the application, which is making money transfers. In the future it is even possible to abstract this part of the application to another service running on any other technology.
- Perform money transfer operations between users
To run this application, you need to have NodeJS and Docker installed on your machine.
- Run the command
touch .env .env.test && cp .env.example .env .env.test
to create environment variable files. - Start the docker services using:
docker-compose up -d
- Run the command
pnpm i
to download the dependencies. You can use the package manager you prefer - Run the command
pnpm prisma migrate deploy
to apply the migrations to the database. - Run the command
pnpm prisma db seed
to populate the database with some initial data - Run the command
pnpm dev
to start the application. - Open the
client.http
file at the root of the project to call the http route that performs the operation. It is important to have the Rest Client extension installed in VsCode
- Run the command
pnpm test
to run the unit tests - Run the command
pnpm test:e2e
to run the end-to-end tests
- Communication between external services and how to bring resilience to the project since external services may suffer instabilities
- Authentication services for the system
- Separate the domain of the application into other bounded contexts for better maintenance, scalability and readability of the project
- Use of Value Objects: Value objects offer a more interesting way of typing data given the specific behaviors that each piece of data can have, such as an Email, CPF or CNPJ that have specific data formats and their own validations.
- Add observability features for metrics and logs
- Store notification messages for history
- Possible better abstraction to deal with sending SMS or email
This project is under the MIT license. Access the link LICENSE for more details.
The source code of the application can be found on GitHub: Project Link
In case of doubts or suggestions, contact us through the email: [email protected].