https://github.com/bangadam/wallet-api
https://github.com/bangadam/wallet-api
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bangadam/wallet-api
- Owner: bangadam
- Created: 2025-01-25T10:58:47.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2025-01-25T11:01:01.000Z (4 months ago)
- Last Synced: 2025-01-25T12:17:16.509Z (4 months ago)
- Language: Go
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Wallet API
A RESTful API for a digital wallet system built with Go, featuring user management, transactions, and background processing.
## Features
- User registration and authentication (JWT)
- Top-up balance
- Make payments
- Transfer money between users (async processing)
- Transaction history
- Profile management
- Background task monitoring dashboard## Tech Stack
- Go 1.21
- Gin Web Framework
- GORM (PostgreSQL)
- JWT Authentication
- Redis + Asynq (Background Processing)
- Asynqmon (Task Monitoring Dashboard)## Project Structure
```
.
├── cmd
│ └── api
│ └── main.go
├── config
│ └── config.yaml
├── internal
│ ├── delivery
│ │ └── http
│ ├── domain
│ ├── middleware
│ ├── repository
│ └── usecase
├── pkg
│ ├── auth
│ ├── database
│ └── queue
└── README.md
```## Getting Started
### Running the Application
1. Clone the repository:
```bash
git clone https://github.com/yourusername/wallet-api.git
cd wallet-api
```2. Configure the application:
- Copy `config/config.yaml.example` to `config/config.yaml`
- Update the configuration values if needed3. Start the application:
```bash
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`## Monitoring Dashboard
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## API Endpoints
### Public Endpoints
- `POST /register` - Register a new user
- `POST /login` - Login and get JWT tokens### Protected Endpoints (Requires JWT)
- `POST /topup` - Add balance to wallet
- `POST /pay` - Make a payment
- `POST /transfer` - Transfer money to another user
- `GET /transactions` - Get transaction history
- `PUT /profile` - Update user profile## Example Requests
### Register
```bash
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"
}'
```### Login
```bash
curl -X POST http://localhost:8080/login \
-H "Content-Type: application/json" \
-d '{
"phone_number": "1234567890",
"pin": "123456"
}'
```### Top Up
```bash
curl -X POST http://localhost:8080/topup \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"amount": 100000
}'
```## Development
### Running Tests
```bash
go test ./...
```### Database Migrations
The application uses GORM auto-migration to manage the database schema. Migrations are automatically applied when the application starts.
## License
MIT License