- This is a Ruby on Rails-based application that provides APIs for user management, wallet operations, transfers, withdrawals, and deposits.
- It includes authentication via JWT, Sidekiq for background processing, and RSpec for testing.
- Using Event Sourcing thoughts(every change to wallet amount will base on an event)
>= 3.0
- MySQL: Version
>= 8.0(Recommended) - Redis: Required for Sidekiq background processing
git clone <repository_url>
cd <repository_folder>Run the following command to install dependencies:
bundle installCopy the example .env.development file to .env:
cp .env.development .envUpdate the .env file with your database and other environment-specific configurations.
Drop, create, and migrate the database:
rails db:drop
rails db:create
rails db:migrateRun the Rails server locally:
rails serverBy default, the server runs on http://localhost:3000.
Ensure Redis is running, then start Sidekiq:
bundle exec sidekiqExecute all tests using the following command:
rspec- Authentication:
- JWT-based authentication.
- Users can register, log in, and fetch their profile.
- Wallet Management:
- Check wallet balance.
- Automated updates on transactions.
- Transfers:
- Transfer funds between users.
- Includes error handling for insufficient balance or invalid operations.
- Withdrawals:
- Create and confirm withdrawals.
- Includes error handling for failed transactions.
- Deposits:
- Deposit funds to wallets.
- Supports multiple payment platforms.
- Background Processing:
- Uses Sidekiq for handling asynchronous tasks.
POST /users/register- Register a new user.POST /users/login- Log in and get a JWT token.GET /users/me- Get the logged-in user's profile.
GET /wallets/user_balance- Get the wallet balance of the authenticated user.
GET /transfers- List all transfers for the authenticated user.POST /transfers- Create a new transfer.
GET /withdrawals- List all withdrawals for the authenticated user.POST /withdrawals- Create a new withdrawal.POST /withdrawals/confirm- Confirm a withdrawal.
GET /deposits- List all deposits for the authenticated user.POST /deposits- Create a new deposit.
- Write tests for your feature using RSpec.
- Ensure all tests pass before submitting a pull request:
rspec
Add unit tests to improve test coverage. Consider using tools like simplecov for tracking coverage.
This project is licensed under the MIT License.
- Add Swagger documentation for APIs.
- Add ut coverage rate check tool(like coverall).
- Add event record automatically(by using some gems)