Welcome to the Demo Credit solution, a platform designed for financial transactions and user management.
- Introduction
- Setup Instructions
- Folder Structure
- Endpoints
- Middleware
- Database
- Error Handling
- Environment Variables
- Deployment
- Contributing
- License
- Postman Documentation
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.
To run the Demo Credit application locally, follow these steps:
-
Clone the repository:
git clone <repository-url> cd lendsqr-fintech
-
Install dependencies:
npm install
-
Set up environment variables:
Create a
.envfile 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 -
Run database migrations:
npm run migrate
-
Start the server:
npm start
The server will run on
http://localhost:3000by default.
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
- 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.
- 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.
- 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.
- authenticate: Ensures that API endpoints are accessed by authenticated users only.
- errorMiddleware: Handles errors globally and provides appropriate responses.
The application uses a relational database managed through Knex.js for schema migrations and queries. Database
connection details are configured in dbConnection.ts.
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.
- 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.
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.
Contributions to the Lendsqr fintech solution are welcome! Fork the repository, create your branch, commit your changes, and submit a pull request.
This project is licensed under the MIT License.
For detailed API documentation, refer to the Postman collection: