You will need the following to use this:
Item | Description | Documentation |
---|---|---|
nodejs | As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications. | https://nodejs.org/en/ |
Docker | We will use docker to launch a postgres instance and kafka | https://www.docker.com/get-started |
yarn | We will use yarn as the package manager for this project | https://yarnpkg.com/getting-started/install |
Use of NestJs with microservices Graphql Apollo Federation, broker message Kafka, hexagonal + DDD architecture, dependency injection and very good practices.
Name | Description |
---|---|
🚀 Gateway-graphql | This application is an API gateway that uses Apollo Federation 2, allowing you to connect to other applications that expose a GraphQL API through introspection, bringing the information of each API. At the moment it only connects to one, which is the one that exposes the transaction app. |
🚀 Transaction-ms | This application is the core of the business currently since it is responsible for administering and managing each transaction by sending events and receiving events through Kafka. This application has a Postgres database and manages it using Prisma ORM. |
🚀 Anti-fraud-ms | This application allows you to listen to all transactions and react by sending state change events for said transactions. |
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Nodejs v.16 or higher
node --version
Configure the .env file using the example file .env.example as a reference
GATEWAY_PORT=3000
TRANSACTION_MS_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/transaction?schema=public
TRANSACTION_MS_PORT=3001
TRANSACTION_MS_SERVICE_URL=http://localhost:${TRANSACTION_MS_PORT}/graphql
KAFKA_BROKER_URL=localhost:9092
Add project dependencies [NPM | YARN]
npm install
yarn
docker compose up -d
Run the application in development
- Required steps
yarn migrate
yarn seed
To avoid any inconvenience, execute the commands in an orderly manner as described.
yarn start:dev transaction-ms
yarn start:dev anti-fraud-ms
yarn start:dev gateway-graphql
To view and interact with API GRAPHQL visit the documentation.
localhost:{your_port_for_gateway-graphql-ms}/graphql
example: [Graphql Apollo Federation](http://localhost:3000/graphql)
Operation
mutation CreateTransaction($createTransactionInput: CreateTransactionInput!) {
createTransaction(createTransactionInput: $createTransactionInput) {
transactionExternalId
transactionStatus {
name
}
transactionType {
name
}
createdAt
value
}
}
Variables
{
"createTransactionInput": {
"accountExternalIdCredit": "d10bd8c7-e9d7-472b-b5b9-5de263bf3c7f",
"accountExternalIdDebit": "0905213a-55f3-45a5-a827-5988d339aafa",
"typeId": 1,
"value": 800
}
}
Operation
query Transaction($transactionId: String!) {
findOne(transactionId: $transactionId) {
transactionExternalId
transactionType {
name
}
transactionStatus {
name
}
value
createdAt
}
}
Variables
{
"transactionId": "UUID"
}
run the tests
npm run test
or
yarn test
- NodeJs - Server Environment
- NestJS - Server Framework
- Prisma - ORM Database
- PostgreSQL - Database
- Kafka - Message Broker
- Docker - Docker
- @ArthurDev - Idea & Initial work