How senjumarru/miniwallet works
MiniWallet is a Go payment and wallet core. Its main workflow accepts an authenticated, rate-limited payment request, applies idempotency and payment rules, creates a provider checkout session, and returns the result. Provider webhooks update payment state; a background reconciler checks stale pending payments. SQLite is the documented durable store, with an in-memory implementation also present. The tree does not include the README’s referenced server entry point, so startup wiring is not represented; some storage and provider connections are documented but not visible in the sampled call sites.
Main entry points: handler.go HTTP Routes · payment.go Payment Service · client.go Provider Client · reconciler.go Reconciler
Components 22
HTTP API
- HTTP Routes
internal/httpapi/handler.go - JWT Auth
internal/httpapi/auth.go - Rate Limits
internal/httpapi/ratelimit.go - HTTP Middleware
internal/httpapi/middleware.go - API Responses
internal/httpapi/response.go - HTTP Server
internal/httpapi/server.go
Payment Domain
- Payment Service
internal/service/payment.go - Reconciler
internal/service/reconciler.go - Service Contracts
internal/service/interfaces.go - Payment Models
internal/domain/models.go - Domain Clock
internal/domain/clock.go
Provider Integration
- Provider Client
internal/provider/client.go - Circuit Breaker
internal/provider/circuit_breaker.go - Provider Contract
internal/provider/provider.go
Persistence
- SQLite Database
internal/storage/sqlite/sqlite.go - SQLite Repositories
internal/storage/sqlite/repositories.go - Memory Storage
internal/storage/memory/memory.go - Database Schema
migrations/001_init.sql
Operations
- Configuration
internal/config/config.go - Prometheus Metrics
internal/metrics/metrics.go
Other components
- API Client
- PSP
Connections 23
- API Client → HTTP Routes: sends requests
internal/httpapi/handler.go - HTTP Routes → JWT Auth: applies JWT
internal/httpapi/handler.go - HTTP Routes → Rate Limits: applies limits
internal/httpapi/handler.go - HTTP Routes → Payment Service: calls service
internal/httpapi/handler.go - HTTP Routes → API Responses: formats errors
internal/httpapi/response.go - HTTP Routes → HTTP Middleware: wraps routes
- Payment Service → Provider Client: creates checkout
- Payment Service → Payment Models: uses models
internal/service/payment.go - Payment Service → Service Contracts: uses interfaces
internal/service/interfaces.go - Payment Service → SQLite Repositories: persists state
- Payment Service → Memory Storage: alternative storage
- Reconciler → Provider Client: checks status
internal/service/reconciler.go - Reconciler → SQLite Repositories: loads stale payments
- Provider Client → PSP: calls PSP
README.md - Provider Client → Circuit Breaker: checks circuit
internal/provider/client.go - Provider Client → Provider Contract: implements contract
- SQLite Repositories → SQLite Database: queries database
- SQLite Database → Database Schema: uses schema
- Reconciler → Domain Clock: uses clock
internal/service/reconciler.go - Provider Client → Prometheus Metrics: records metrics
internal/provider/client.go - HTTP Routes → Prometheus Metrics: exposes metrics
internal/httpapi/handler.go - HTTP Server → HTTP Routes: serves handler
- Configuration → HTTP Server: configures startup