A full-featured backend service for managing products, stock levels, movement logs, alerts, and metrics โ built in Go with PostgreSQL.
- โ Product CRUD with validation
- ๐ Atomic stock adjustments with history
- ๐ Admin dashboard metrics
- ๐ Low stock alerts
- ๐๏ธ Product filtering + pagination
- ๐ฅ Batch CSV import (with update/skip modes)
- ๐ค Movement export (CSV/JSON)
- ๐ง User auth with JWT
- ๐ Role-Based Access Control (RBAC) with roles & permissions
- ๐ฆ API rate limiting using Redis-based token bucket with per-user and role-specific quotas
- ๐ก๏ธ Ban & session revocation stored in Redis with TTL
- ๐ OpenAPI docs (
/swagger) - ๐ Prometheus
/metricsendpoint for monitoring (planned) - ๐ก๏ธ Ban & session revocation system
- ๐ง Email alerts via SMTP
- ๐งช Full test coverage
| Layer | Tech |
|---|---|
| Language | Go 1.24.4 |
| Router | Chi |
| Database | PostgreSQL |
| Migrations | Soda |
| Docs | Swaggo |
| Auth | JWT |
| RBAC | File-based roles & permissions |
| Rate Limiting | Redis-backed token bucket with role-based quotas |
| Monitoring | Prometheus + Grafana |
| Container | Docker, Docker Compose |
| Tests | go test, Dockerized |
make rundocker-compose up --build- Swagger UI: /swagger
- OpenAPI JSON: /swagger/doc.json
Run tests locally:
make testRun tests in Docker:
make test-dockername,price,quantity,threshold
Mouse,25.99,10,2
Keyboard,45.00,5,1
Monitor,199.99,2,1Upload with:
curl -X POST http://localhost:8080/products/import \
-F "file=@products.csv"Use ?mode=update to overwrite existing products.
Use /register or /login to get a JWT token.
Then send it via:
Authorization: Bearer <your-token>Query high-level metrics:
GET /metrics/dashboardReturns product count, low stock alerts, most moved item, average prices, etc.
api/ # Entry point
internal/
http/ # Handlers and routes
repo/ # Repositories and interfaces
db/ # Postgres connector
docs/ # Swagger files (generated)
make build # local
make docker-build # containerMIT โ free to use, modify, and share.