A RESTful API for a digital wallet system built with Go, featuring user management, transactions, and background processing.
- User registration and authentication (JWT)
- Top-up balance
- Make payments
- Transfer money between users (async processing)
- Transaction history
- Profile management
- Background task monitoring dashboard
- Go 1.21
- Gin Web Framework
- GORM (PostgreSQL)
- JWT Authentication
- Redis + Asynq (Background Processing)
- Asynqmon (Task Monitoring Dashboard)
.
├── cmd
│ └── api
│ └── main.go
├── config
│ └── config.yaml
├── internal
│ ├── delivery
│ │ └── http
│ ├── domain
│ ├── middleware
│ ├── repository
│ └── usecase
├── pkg
│ ├── auth
│ ├── database
│ └── queue
└── README.md
-
Clone the repository:
git clone https://github.com/yourusername/wallet-api.git cd wallet-api
-
Configure the application:
- Copy
config/config.yaml.example
toconfig/config.yaml
- Update the configuration values if needed
- Copy
-
Start the application:
go run cmd/api/main.go
The API will be available at http://localhost:8080
The monitoring dashboard will be available at http://localhost:8081/monitoring
The application includes a web-based monitoring dashboard for background tasks. You can access it at http://localhost:8081/monitoring
. The dashboard provides:
- Real-time monitoring of queue tasks
- View task details including payload and status
- View worker processes and their status
- View retry attempts and failures
- Queue statistics and metrics
- Ability to retry failed tasks
- Queue management capabilities
POST /register
- Register a new userPOST /login
- Login and get JWT tokens
POST /topup
- Add balance to walletPOST /pay
- Make a paymentPOST /transfer
- Transfer money to another userGET /transactions
- Get transaction historyPUT /profile
- Update user profile
curl -X POST http://localhost:8080/register \
-H "Content-Type: application/json" \
-d '{
"first_name": "John",
"last_name": "Doe",
"phone_number": "1234567890",
"address": "123 Main St",
"pin": "123456"
}'
curl -X POST http://localhost:8080/login \
-H "Content-Type: application/json" \
-d '{
"phone_number": "1234567890",
"pin": "123456"
}'
curl -X POST http://localhost:8080/topup \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"amount": 100000
}'
go test ./...
The application uses GORM auto-migration to manage the database schema. Migrations are automatically applied when the application starts.
MIT License