Professional-grade Golang backend with 25 REST APIs
Complete inventory management system built with Go, PostgreSQL, and GORM. Ready for production deployment.
- ✅ Product catalog management
- ✅ Multi-warehouse inventory tracking
- ✅ Stock movement auditing
- ✅ Supplier management
- ✅ Purchase order processing
- ✅ Sales order management
- ✅ Real-time stock reports
- ✅ Comprehensive audit logs
- ✅ Low-stock alerts
Golang/
├── cmd/
│ └── root.go
├── internal/
│ ├── models.go # All database models
│ ├── db.go # Database & audit functions
│ ├── products/ # Product handlers
│ ├── warehouses/ # Warehouse handlers
│ ├── inventory/ # Inventory handlers
│ ├── suppliers/ # Supplier handlers
│ ├── orders/ # Order handlers (PO & Sales)
│ └── reports/ # Reports & audit handlers
├── migrations/
│ └── 002_ims_schema.sql
├── main.go # Server & routes
└── .env
| Method | Endpoint | Description |
|---|---|---|
| POST | /products |
Create new product |
| GET | /products |
List all products |
| GET | /products/{id} |
Get product by ID |
| PUT | /products/{id} |
Update product |
| DELETE | /products/{id} |
Delete product |
| GET | /products/search?q=keyword |
Search products |
Example Request (Create Product):
POST /products
{
"name": "Widget Pro",
"sku": "WGT-PRO-001",
"description": "Premium widget",
"category": "Electronics",
"price": 299.99,
"cost": 150.00,
"unit": "piece"
}| Method | Endpoint | Description |
|---|---|---|
| POST | /warehouses |
Create warehouse |
| GET | /warehouses |
List all warehouses |
| GET | /warehouses/{id} |
Get warehouse by ID |
Example Request:
POST /warehouses
{
"name": "North Warehouse",
"location": "Seattle, WA",
"capacity": 15000
}| Method | Endpoint | Description |
|---|---|---|
| GET | /inventory |
Get current stock levels |
| GET | /inventory/{productId} |
Get stock for specific product |
| POST | /inventory/adjust |
Manual stock adjustment |
| GET | /inventory/low-stock |
Get low-stock alerts |
| GET | /inventory/movements |
View stock movement history |
Example Request (Adjust Stock):
POST /inventory/adjust
{
"product_id": 1,
"warehouse_id": 1,
"quantity": 100,
"reason": "Initial stock"
}| Method | Endpoint | Description |
|---|---|---|
| POST | /suppliers |
Create supplier |
| GET | /suppliers |
List all suppliers |
| PUT | /suppliers/{id} |
Update supplier |
Example Request:
POST /suppliers
{
"name": "TechParts Inc",
"contact_name": "John Doe",
"email": "john@techparts.com",
"phone": "+1-555-0123",
"address": "123 Supply St, NY",
"rating": 4.5
}| Method | Endpoint | Description |
|---|---|---|
| POST | /purchase-orders |
Create purchase order |
| GET | /purchase-orders |
List purchase orders |
| PUT | /purchase-orders/{id}/receive |
Mark PO as received |
Example Request (Create PO):
POST /purchase-orders
{
"supplier_id": 1,
"items": [
{
"product_id": 1,
"quantity": 500,
"unit_price": 15.00
}
]
}Example Request (Receive PO):
PUT /purchase-orders/1/receive
{
"warehouse_id": 1
}| Method | Endpoint | Description |
|---|---|---|
| POST | /orders |
Create sales order |
| GET | /orders |
List sales orders |
| PUT | /orders/{id}/status |
Update order status |
Example Request (Create Order):
POST /orders
{
"customer_name": "ABC Corp",
"customer_email": "orders@abc.com",
"items": [
{
"product_id": 1,
"warehouse_id": 1,
"quantity": 10
}
]
}Example Request (Update Status):
PUT /orders/1/status
{
"status": "shipped"
}Order Statuses: pending, processing, shipped, delivered, cancelled
| Method | Endpoint | Description |
|---|---|---|
| GET | /reports/stock-summary |
Get stock value report |
| GET | /audit-logs |
View audit trail |
Stock Summary Response:
{
"status": "success",
"data": {
"items": [...],
"total_value": 125000.50,
"total_items": 2500
}
}Tables:
products- Product catalogwarehouses- Storage locationsinventories- Current stock levelsstock_movements- Stock transaction historysuppliers- Supplier informationpurchase_orders- Purchase orderspo_items- PO line itemsorders- Sales ordersorder_items- Order line itemsaudit_logs- System audit trail
Create .env file:
DB_HOST=localhost
DB_PORT=5432
DB_NAME=ims_db
DB_USER=postgres
DB_PASSWORD=yourpasswordpsql -U postgres -f migrations/002_ims_schema.sqlgo mod tidygo run main.goServer starts on: http://localhost:8080
curl http://localhost:8080/healthcurl -X POST http://localhost:8080/products \
-H "Content-Type: application/json" \
-d '{
"name": "Test Product",
"sku": "TST-001",
"price": 99.99,
"cost": 50.00
}'curl http://localhost:8080/inventory/low-stock- IN - Stock added (from purchase orders)
- OUT - Stock removed (from sales orders)
- ADJUST - Manual adjustments
- ✅ Creating sales order → reduces inventory
- ✅ Receiving purchase order → increases inventory
- ✅ All movements logged in
stock_movements - ✅ All actions recorded in
audit_logs
- ❌ Cannot create order if insufficient stock
⚠️ Low-stock alerts whenquantity <= min_stock
✅ GORM ORM with auto-migrations
✅ Foreign key constraints
✅ Indexed queries for performance
✅ Audit logging for compliance
✅ Error handling & validation
✅ RESTful API design
✅ Transaction history
- Language: Go 1.21+
- Framework: net/http (stdlib)
- Database: PostgreSQL 14+
- ORM: GORM v2
- Config: godotenv
- JWT authentication
- Pagination for list endpoints
- CSV/Excel export for reports
- Email notifications (low stock, orders)
- Redis caching
- Docker containerization
- API documentation (Swagger)
- Unit tests
MIT License - Free to use commercially
Perfect for:
- Retail businesses - Multi-location inventory
- Distributors - Supplier & order management
- Manufacturers - Raw material tracking
- E-commerce - Order fulfillment
- Small warehouses - Stock control
Built with ❤️ using Golang