CrediWallet is a wallet application that allows users to fund their accounts, transfer funds, and withdraw money. It includes features for user management, authentication, and admin functionalities.
- Overview
- Features
- Technologies
- Setup
- Usage
- API Documentation
- E-R Diagram
- Testing
- Contributing
- License
- User Registration and Authentication
- Account Funding
- Funds Transfer
- Withdrawal
- Admin functionalities (block/unblock user, assign/remove admin role)
- Detailed Transaction History
- Input validation and error handling
- JWT-based Authentication
- Backend: Node.js, Express.js, TypeScript
- Database: MySQL, Knex.js ORM
- Testing: Jest
- Other Libraries: bcrypt, jsonwebtoken, body-parser, express-validator
- Node.js
- MySQL
- npm or yarn
- Clone the repository:
- Install dependencies:
- Create a
.env
file in the root directory and add the necessary environment variables: - Run database migrations:
npx knex migrate:latest
To start the application, run:
npm start
Detailed API documentation is available and accessible via Swagger UI. To view the documentation, navigate to:
http://localhost:3000/api/docs
The Entity-Relationship diagram provides a visual representation of the database schema and relationships.
-
User
id
(PK, Integer)name
(String)email
(String)password
(String)account_number
(String)balance
(Float)role
(String, enum: ['user', 'admin'])created_at
(Timestamp)updated_at
(Timestamp)
-
Transaction
id
(PK, Integer)user_id
(FK, Integer)type
(String, enum: ['fund', 'withdraw', 'transfer'])amount
(Float)recipient_id
(FK, Integer, nullable)description
(String)created_at
(Timestamp)updated_at
(Timestamp)
- A User can have multiple Transactions (One-to-Many).
- A Transaction is associated with one User as the initiator (Many-to-One).
- For transfer transactions, there is a recipient User (Many-to-One).
To run tests, use:
npm test
The project includes unit tests for both positive and negative scenarios, covering key functionalities such as user registration, authentication, transactions, and admin actions. The tests are designed to ensure code reliability and robustness.
- Ensure a new user can register with valid data.
- Verify the response contains a success message and user details.
- Attempt registration with missing fields and expect validation errors.
- Attempt registration with an already registered email and expect a conflict error.