Skip to content

johnkrator/wallet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo Credit Solution

Welcome to the Demo Credit solution, a platform designed for financial transactions and user management.

Table of Contents

  1. Introduction
  2. Setup Instructions
  3. Folder Structure
  4. Endpoints
  5. Middleware
  6. Database
  7. Error Handling
  8. Environment Variables
  9. Deployment
  10. Contributing
  11. License
  12. Postman Documentation

Introduction

Demo Credit is a fintech application built on Node.js and Express.js, designed to facilitate financial transactions such as deposits, withdrawals, transfers, and manage user information securely.

Setup Instructions

To run the Demo Credit application locally, follow these steps:

  1. Clone the repository:

    git clone <repository-url>
    cd lendsqr-fintech
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    Create a .env file in the root directory with the following variables:

    PORT=3000
    JWT_SECRET=your_jwt_secret
    
    DB_HOST=localhost
    DB_USER=root
    DB_PASSWORD=
    DB_NAME=xxxxDB
    DB_PORT=3306
    
    FROM_EMAIL=xxxx
    EMAIL_USERNAME=xxxx
    EMAIL_PASSWORD=xxxx
    
  4. Run database migrations:

    npm run migrate
  5. Start the server:

    npm start

    The server will run on http://localhost:3000 by default.

Folder Structure

wallet/
│
├── controllers/
│   ├── transaction.controllers.ts
│   └── users/
│       ├── onboarding.controller.ts
│       └── user.controller.ts
│
├── db/
│   ├── dbConnection.ts
│   ├── migrations/
│   │   ├── createDatabase.ts
│   │   └── otherMigrations.ts
│   └── seeds/
│
├── helpers/
│   ├── emailService/
│   │   ├── sendRegistrationVerificationEmail.ts
│   │   └── sendTransactionNotificationEmail.ts
│   ├── middlewares/
│   │   ├── authMiddleware.ts
│   │   ├── checkBlacklist.ts
│   │   └── errorMiddleware.ts
│   ├── generateToken.ts
│   ├── getCircularReplacer.ts
│   └── logger.ts
│
├── routes/
│   ├── transaction.routes.ts
│   └── users/
│       ├── onboarding.routes.ts
│       └── users.routes.ts
│
├── .env
├── .env.example
├── .gitignore
├── app.log
├── knexfile.ts
├── package.json
├── package-lock.json
├── README.md
├── tsconfig.json
└── app.ts

Endpoints

Authentication and User Management

  • POST /api/v1/auth/register
    • Register a new user.
  • POST /api/v1/auth/verify-email
    • Verify user's email after registration.
  • POST /api/v1/auth/login
    • User login.

User Management

  • GET /api/v1/users/
    • Get all users.
  • GET /api/v1/users/me
    • Get current user's profile.
  • GET /api/v1/users/:id
    • Get user by ID.
  • PUT /api/v1/users/:id
    • Update user information.
  • DELETE /api/v1/users/:id
    • Delete user.

Wallet and Transaction Management

  • POST /api/v1/wallets/deposit
    • Deposit funds into the user's wallet.
  • POST /api/v1/wallets/withdraw
    • Withdraw funds from the user's wallet.
  • POST /api/v1/wallets/transfer
    • Transfer funds between wallets.
  • GET /api/v1/wallets/:walletId
    • Get transactions for a specific wallet.

Middleware

  • authenticate: Ensures that API endpoints are accessed by authenticated users only.
  • errorMiddleware: Handles errors globally and provides appropriate responses.

Database

The application uses a relational database managed through Knex.js for schema migrations and queries. Database connection details are configured in dbConnection.ts.

Error Handling

Errors are handled centrally using middleware (errorMiddleware.ts). HTTP responses include appropriate status codes and error messages for ease of debugging and client-side error handling.

Environment Variables

  • PORT: Port number for the server to listen on.
  • JWT_SECRET: Secret key for JWT token generation and verification.
  • DATABASE_URL: Connection string for the database.

Deployment

For deployment, ensure that environment variables are properly configured on your hosting provider. Use a process manager like PM2 or Docker for containerization to manage the application in production environments.

Contributing

Contributions to the Lendsqr fintech solution are welcome! Fork the repository, create your branch, commit your changes, and submit a pull request.

License

This project is licensed under the MIT License.

For detailed API documentation, refer to the Postman collection:

Postman Documentation

Postman Documentation


About

Wallet is a minimalist wallet service application designed to offer essential digital wallet functionalities with a focus on simplicity and security. With Wallet, users can easily manage their finances by creating an account, adding funds, transferring money to other users, and withdrawing funds.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors