Skip to content

niloy104/Go-Wallet-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Wallet System — Production-Grade Digital Wallet API in Pure Go

Go PostgreSQL net/http License

A fully functional, secure, and atomic digital wallet backend built entirely in pure Gozero web frameworks (no Gin, no Echo, no Fiber).

This is how real payment systems work under the hood.

Live Postman Demo

Postman Collection Demo

(Full collection link below)

Core Features

  • User registration & login with JWT authentication
  • Atomic P2P money transfers (with row-level locking)
  • Top-up wallet balance
  • Real-time balance inquiry
  • Complete transaction history per user
  • Full input validation & error handling
  • Rate limiting, CORS, structured logging
  • Database migrations
  • Clean, scalable, layered architecture

Tech Stack

Layer Technology
Language Go (pure net/http)
Database PostgreSQL + sqlx
Auth JWT (self-implemented)
Architecture Domain-Driven Design (DDD) inspired
Concurrency Database transactions + FOR UPDATE
No dependencies Only standard library + sqlx

REST API Endpoints

Method Endpoint Description Auth
POST /users Create account Public
POST /users/login Login → JWT Public
GET /wallets/my-balance Get current balance JWT
POST /wallets/topup Add money JWT
POST /wallets/transfer Send money to another user JWT
GET /transactions Full transaction history JWT

Key Engineering Concepts Implemented

  • Atomic transactions using WithTx + FOR UPDATE row locking
  • Preventing race conditions in financial operations
  • Clean separation of concerns (Domain → Service → Repository → Handler)
  • Dependency inversion (interfaces in domain layer)
  • Secure JWT implementation from scratch
  • Structured error handling with custom domain errors
  • Middleware chain: Logger → CORS → Rate Limit → Auth
  • Production-ready response utilities

Project Structure (Clean & Scalable)

wallet/
├── cmd/ 
├── domain/           # Pure entities & business rules
├── migrations/
├── wallet/           # Application use cases 
├── user/ 
├── repo/             # Database implementations
├── rest/handlers/walletB/  # HTTP delivery layer
├── rest/middlewares/ # Auth, CORS, Logger, RateLimiter
├── infra/db/         # Connection + migrations
└── util/             # Response helpers, JWT, etc.
├── main.go           # main file

Run Locally
Bash: 
git clone https://github.com/niloy104/VaultGo.git
cd wallet
cp .env.example .env
go run main.go

Server: http://localhost:4000


Postman Collection
Download Full Postman Collection
View in Postman (link after upload)
Future Roadmap


Future Roadmap
Admin dashboard
Transaction search & filters
Docker + PostgreSQL compose
Unit & integration tests
WebSocket real-time balance updates

License
MIT © niloy104

About

Go Wallet System – A secure, minimal Golang backend for digital wallets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages