A high-performance, robust, and secure Point of Sales (POS) backend API designed using Clean Architecture principles in Go. Featuring built-in cybersecurity configurations, Redis-based rate limiting, and an abstract payment gateway integration (supporting Midtrans, extensible to Xendit).
- Transaction Processing: Automatic calculations of subtotals, taxes (GST/VAT), discount rates, and real-time inventory updates wrapped in transactional database scopes.
- Payment Handling: Modular payment gateway engine integrated with Midtrans (Snap/Core API) for credit/debit card, e-wallet, and cash payments.
- Inventory Management: Product catalog tracking, low-stock warnings, and barcode scanner lookup support.
- Customer Management: Tracks customer details, purchase histories, and a customer loyalty points system.
- Reporting and Analytics: Aggregate sales tracking, product performance analytics, and employee sales reports.
- Hardware Compatibility: Supports REST responses ideal for custom POS terminal integrations, barcode scanner keyboard inputs, and print-ready receipt formats.
- Production Security:
- CORS Protection
- Custom JWT Authentication (Session-based)
- Redis-based Rate Limiter (IP/Token based)
- CSRF Protection middleware
+---------------------------------------------+
| HTTP Delivery Layer |
| (Gin Handlers, CORS, JWT, Rate Limiter) |
+----------------------+----------------------+
|
v
+---------------------------------------------+
| Usecase Layer |
| (Transaction logic, Loyalty points engine) |
+----------------------+----------------------+
|
v
+---------------------------------------------+
| Repository Layer |
| (GORM Postgres, Redis Clients) |
+---------------------------------------------+
- Go (Golang):
v1.20+ - Database: PostgreSQL (GORM ORM)
- Caching & Rate Limiting: Redis
- Security & Middlewares: JWT (golang-jwt/jwt), CORS, CSRF, custom Redis limiter.
- Go 1.20+
- PostgreSQL
- Redis
Create a .env file in the root directory:
PORT=8080
ENV=development
# Database Configuration
DB_HOST=gothub_db
DB_USER=pos_user
DB_PASSWORD=pos_password
DB_NAME=pos_db
DB_PORT=5432
DB_SSLMODE=disable
# Redis Configuration
REDIS_ADDR=redis:6379
REDIS_PASSWORD=
REDIS_DB=0
# Security Credentials
JWT_SECRET=super_secret_signing_key_change_me
CSRF_SECRET=csrf_salt_key_change_me_32_bytes_long
# Midtrans Credentials
MIDTRANS_SERVER_KEY=your_midtrans_server_key
MIDTRANS_CLIENT_KEY=your_midtrans_client_key
MIDTRANS_IS_PRODUCTION=false# Get dependencies
go mod tidy
# Run application
go run cmd/server/main.go