Skip to content

nwokoyepraise/wallet-service

Repository files navigation

🏦 Wallet Service

Table of Contents

  1. About The Project
  2. Services Available
  3. Built with
  4. Getting Started
  5. Running Tests
  6. API Reference
  7. Entity Relationship Diagram
  8. Roadmap
  9. Contributing
  10. License
  11. Contact

About the Project

Wallet service is a container-based NestJs Backend server wallet application where users are able to create accounts, fund their wallets, handle transfers bettween wallet owners, withdraw their funds, retrieve transactions history, etc.

Very importantly, this application, features both local and stateless authetication using JSON Web Tokens which has been implemented using Passport library, and payment gateway integration for funds management and use of database transactions to ensure data integrity in critical multi-table queries and operations.

β›³ Services Available

  • User registeration
  • Email verification
  • Login
  • Wallet funding
  • Transfer between wallets
  • Withdrawals
  • Transactions history
  • Retrieve wallet

πŸ”¨ Built With

  • Node.js
  • NestJs (Typescript)
  • MySQL
  • KnexJs Query Builder
  • Docker
  • Passport.JS (Authentication)

🏁 Getting Started

πŸ”© Bare metal

To build the project locall,, bare metal without docker, simply clone the github repository. Navigate to root project folder and run the following to install packages:

$ npm install

and add appropriate .env file in the project root folder

Development

After packages have been installed. Proceed to run:

$ npm run start:dev

Production

After packages have been installed. Proceed to run:

$ npm run start:prod

βš“ Docker

To run the application in a docker which, depending on the docker CLI tool available in your local system, navigate to the project root foler, add the appropriate .env file

if docker-compose is available in your local system, please run the following commands in your terminal:

$ docker-compose build
$ docker-compose up -d

If the local system is running Linux, sudo privileges may be need to run the commands appropriately.

Running Tests

To run unit tests, run the following command

  $ npm run test

To run coverage test, run the following command

  $ npm run test:cov

API Reference

πŸ“ž Server Ping

GET /

Response:
  {
    "message": "server active!"
  }

πŸ”‘ Authentication

User Registeration

POST /users
Content-Type: application/json

Response:
    {
      "email": "string",
      "user_id": "string"
    }
Parameter Type Description
email string Required. Must be a valid email string
password string Required.

Verify Email

PATCH /auth/verify-email
Content-Type: application/json

Response:
  {
    "message": "success"
  }
Parameter Type Description
email string Required.
user_id string Required.
token string Required. Token for verification

Login

POST /auth/login
Content-Type: application/json

Response:
  {
    "user_id": "string",
    "jwt": "string"
  }
Parameter Type Description
email string Required.
password string Required.

🏦 Wallets

Retrieve Wallet

GET /wallets/me
Authorization: Bearer Token <JWT>

Response:
  {
    "wallet_id": "string",
    "user_id": "string",
    "balance": "number",
    "currency": "ISO4217 currency code",
    "created_at": "date string",
    "updated_at": "date string"
  }
Parameter Type Description
wallet_id string Required.

πŸ”„ Transactions

Add funds

This endpoints takes in the amount reuired for funding. It returns the transaction details which includes a link field which is the payment link which will be used to pay over any browser powered by Flutterwave.

POST /transactions/fund-wallet
Content-Type: application/json
Authorization: Bearer Token <JWT>

Response:
  {
    "link": "string (payment-link)",
    "transaction_id": "string",
    "ref": "string",
    "source": "string",
    "amount": "number",
    "currency": "NGN",
    "status": "PENDING",
    "type": "FUNDING"
  }
Parameter Type Description
amount number Required.
beneficiary_wallet string Required.

Transfer funds

POST /transactions/transfer
Content-Type: application/json
Authorization: Bearer Token <JWT>

Response:
  {
    "message": "success"
  }
Parameter Type Description
amount number Required.
wallet string Required.

Withdraw funds

POST /transactions/withdraw
Content-Type: application/json
Authorization: Bearer Token <JWT>

Response:
  {
    "transaction_id": "string",
    "ref": "string",
    "source": "string",
    "amount": "number",
    "currency": "NGN",
    "status": "PENDING",
    "type": "WITHDRAWAL"
  }
Parameter Type Description
amount number Required.
bank_code string Required.
account_number string Required.

Retrieve own Transactions

GET /transactions
Authorization: Bearer Token <JWT>

Response:
  [{
    "transaction_id": "string",
    "ref": "string",
    "source": "string",
    "amount": "number",
    "currency": "NGN",
    "status": "PENDING",
    "type": "WITHDRAWAL"
  }]

Retrieve Transaction

GET /transactions/:transaction_id
Authorization: Bearer Token <JWT>

Response:
  {
    "transaction_id": "string",
    "ref": "string",
    "source": "string",
    "amount": "number",
    "currency": "NGN",
    "status": "PENDING",
    "type": "WITHDRAWAL"
  }

Entity Relation Diagram

wallet-service drawio

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the GNU-V3 License. See LICENSE for more information.

Contact

Project Link: https://github.com/nwokoyepraise/wallet-service

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages