This project is a sample bank API built with MongoDB, KoaJS, and GraphQL. It provides CRUD operations for managing users, companies, accounts, and transactions. The API enables secure transactions between accounts, calculates balances based on transaction history, and includes JWT authentication for access control.
- Account and Transaction Management: Complete CRUD operations for accounts and transactions.
- Account Transfers: Enables secure transactions between accounts.
- Balance Calculation: Automatically calculates account balances based on the transaction history.
- JWT Authentication: Protects routes, allowing access only to authenticated users.
- Access Control: Verifies access permissions for sensitive operations.
Ensure the following are installed and configured:
After cloning the repository, in your project directory:
-
Create Environment File:
- Make a copy of the
.env.example
file and rename it to.env
. - Update the values in the
.env
file with your actual configuration settings.
- Make a copy of the
-
Start Docker Environment:
-
Run the following command to start the Docker environment in the background:
$ docker compose up -dV
-
Apollo Explorer: http://localhost:4000/graphql
Use the Apollo Explorer at the above link to test queries and mutations, visualize the schema, and explore the data.
To run the test suite and validate API functionality, use the command:
$ npm run test
This command will execute the defined tests, ensuring reliability of operations.
To facilitate development and testing with Postman, the GraphQL schema can be converted into a JSON file, allowing you to import API definitions directly into Postman.
To generate the JSON file, run:
$ npm run postman:json
This file can be imported into Postman, enabling quick testing of the defined queries and mutations.