Skip to content

Latest commit

ย 

History

180 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฎ Inventory Tracker API

A full-featured backend service for managing products, stock levels, movement logs, alerts, and metrics โ€” built in Go with PostgreSQL.


๐Ÿš€ Features

  • โœ… 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 /metrics endpoint for monitoring (planned)
  • ๐Ÿ›ก๏ธ Ban & session revocation system
  • ๐Ÿ“ง Email alerts via SMTP
  • ๐Ÿงช Full test coverage

๐Ÿ›  Tech Stack

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

๐Ÿงฐ Getting started

โ–ถ๏ธ Run Locally

make run

๐Ÿณ With Docker Compose

docker-compose up --build

๐Ÿ”— API Documentation

๐Ÿงช Testing

Run tests locally:

make test

Run tests in Docker:

make test-docker

๐Ÿงพ CSV Import Format

name,price,quantity,threshold
Mouse,25.99,10,2
Keyboard,45.00,5,1
Monitor,199.99,2,1

Upload with:

curl -X POST http://localhost:8080/products/import \
  -F "file=@products.csv"

Use ?mode=update to overwrite existing products.

๐Ÿ” Authentication

Use /register or /login to get a JWT token.

Then send it via:

Authorization: Bearer <your-token>

๐Ÿ“Š Admin Dashboard

Query high-level metrics:

GET /metrics/dashboard

Returns product count, low stock alerts, most moved item, average prices, etc.

๐Ÿ“ Project Structure

api/                 # Entry point
internal/
  http/              # Handlers and routes
  repo/              # Repositories and interfaces
  db/                # Postgres connector
docs/                # Swagger files (generated)

๐Ÿ“ฆ Build

make build           # local
make docker-build    # container

๐Ÿ“œ License

MIT โ€” free to use, modify, and share.

About

๐Ÿ“Š A basic inventory system to track stock levels and suppliers. Designed for small businesses and prototyping.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages