Skip to content
neuralforgeioPublic

About

Multi-tenant business operations platform for Indonesian companies: inventory, purchasing, sales, finance, payments, approval workflows, and reporting. Go + Next.js + PostgreSQL.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

54 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

StockKit StockKit

Multi-tenant Business Operations Platform for Indonesian Companies

Go Next.js PostgreSQL Redis Docker License Release Last commit

Quick Start β€’ Features β€’ Architecture β€’ API Docs β€’ Frontend β€’ Contributing


Multi-tenant Business Operations Platform for Indonesian Companies

Quick Start β€’ Features β€’ Architecture β€’ API Docs β€’ Frontend β€’ Contributing


πŸ“– Overview

StockKit is a production-grade, multi-tenant ERP-like platform built for Indonesian businesses β€” from UMKM to project-based enterprises. It covers the complete business cycle: inventory β†’ purchasing β†’ sales β†’ finance β†’ reporting, with built-in approval workflows, FX rate management, and a developer-focused observability suite.

Designed for: Indonesian companies needing localized tax IDs (NPWP), IDR-first accounting, BPJS-ready payroll hooks, and regulatory-compliant audit trails.


✨ Features

πŸ—‚οΈ Core Modules

Module Description
πŸ“¦ Inventory Multi-warehouse stock levels, FIFO/Average costing, adjustments, movements with full audit trail
πŸ›’ Purchasing Purchase requests β†’ approval β†’ PO β†’ goods receipt β†’ supplier invoice flow
πŸ’° Sales Sales orders β†’ checkout (reserve) β†’ deliver β†’ invoice β†’ receipt (cash flow)
🏦 Finance Cash accounts, multi-currency payments, AR/AP aging, net working capital
πŸ“Š Reports P&L, inventory valuation, AR/AP aging, digital signature on PDF export
🌐 FX Rates Daily rate management with automatic document conversion
βœ… Approvals Multi-step approval workflows with threshold-based rules
πŸ‘₯ Users & Roles 8 RBAC roles: developer, owner, admin, finance, sales, purchasing, warehouse, auditor

🎨 UX Highlights

  • Theme-aware UI β€” Light / Dark / System with design tokens
  • Signature Pad β€” Canvas-based digital signature for PDF reports (localStorage reuse)
  • Matrix Rain β€” Developer suite accent (role-gated)
  • Auto-refresh charts β€” Real-time observability (5s interval, role-gated)
  • Mobile-ready β€” Responsive sidebar with Ctrl+B collapse shortcut

πŸ”’ Security & Compliance

  • AES-256-GCM encryption for supplier bank accounts
  • JWT refresh token rotation with reuse detection
  • CSRF protection on all state-changing endpoints
  • Structured colored logs with PII redaction (password, token, credit card)
  • Daily log rotation (.log colored + .jsonl machine-readable)

πŸ—οΈ Architecture

flowchart TB
    subgraph Client[Frontend Layer]
        UI[Next.js 16 UI]
        API_Client[API Client + Auto-Refresh]
        WS[WebSocket Singleton]
    end

    subgraph Server[Backend Layer]
        Chi[Chi Router + Middleware]
        Handlers[Handlers]
        Services[Business Services]
        Repositories[Repositories]
        RT[Realtime Hub]
        AuditListener[Audit LISTEN]
        ProfileListener[Profile LISTEN]
    end

    subgraph Data[Data Layer]
        PG[(PostgreSQL 18)]
        Redis[(Redis 7)]
        MinIO[(MinIO S3)]
        Logs[./logs/]
    end

    UI -->|HTTPS| Chi
    API_Client -->|Bearer + CSRF| Chi
    WS <-->|WebSocket| RT
    Chi -->|AuthN + CSRF + Logging| Handlers
    Handlers --> Services
    Services --> Repositories
    Repositories --> PG
    Repositories --> Redis
    Repositories --> MinIO
    Handlers --> Logs
    PG -->|pg_notify audit_events| AuditListener
    PG -->|pg_notify user_profile_events| ProfileListener
    AuditListener --> RT
    ProfileListener --> RT
    RT --> WS
Loading

Tech Stack

Layer Technology Purpose
Frontend Next.js 16.3.6, React 19, TypeScript, Tailwind CSS, Recharts, Framer Motion SPA, charts, animations
Backend Go 1.27.1, Chi router, pgx v5, slog, golang-migrate REST API, migrations, structured logging
Database PostgreSQL 18.6 OLTP, ACID transactions
Cache Redis 7 Sessions, rate limiting (graceful degradation)
Storage MinIO (S3-compatible) Product images, user avatars
Infra Docker Compose Local dev orchestration

πŸš€ Quick Start

Prerequisites

  • Go 1.27.1+
  • Node.js 20+
  • Docker & Docker Compose
  • Git

Installation

# Clone
git clone https://github.com/neuralforgeio/StockKit.git
cd StockKit

# Environment
cd backend
cp .env.example .env
# Edit .env β€” set POSTGRES_PASSWORD, JWT_EDDSA_KEY, FIELD_ENCRYPTION_KEY (see .env.example)

# Start PostgreSQL (if not using Docker)
# Or: docker compose up -d

# Backend
go mod tidy
go run ./cmd/api migrate up
go run ./cmd/api seed          # seeds tenant, roles, developer user, initial data
go run ./cmd/api serve         # :8080
# Frontend (separate terminal)
cd frontend
npm install
npm run dev                    # :3000

Bootstrap User (Alternative So Seed)

# Interactive prompts (password hidden, zero leak)
# -> Email: admin@company.com
# -> Password: ********
# -> Confirm Password: ********

CLI Commands

go run ./cmd/api serve        # Start API server
go run ./cmd/api migrate up   # Run pending migrations
go run ./cmd/api migrate down # Rollback last migration
go run ./cmd/api migrate version  # Show current version
go run ./cmd/api seed         # Seed initial data (idempotent)
go run ./cmd/api version      # Show build info

πŸ“š Documentation

Document Description
πŸ“˜ API Reference Complete REST API documentation with request/response examples
🎨 Frontend Guide Page structure, routing, component patterns
πŸ›οΈ Architecture Deep-dive into modules, data flow, decisions
🚒 Deployment Production deployment & security hardening
πŸ” Security Auth flow, encryption, redaction, CSRF
πŸ” Audit System Realtime audit logs, LISTEN/NOTIFY, diff formatter, UUID resolution
πŸ‘₯ User Management User lifecycle, RBAC, audit trail, bootstrap CLI

πŸ”„ Business Flow Example

sequenceDiagram
    participant U as Sales User
    participant SO as Sales Orders
    participant A as Approvals
    participant I as Inventory
    participant F as Finance

    U->>SO: Create draft SO
    U->>SO: Submit for approval
    SO->>A: Create approval instance
    A-->>U: Notify approver

    Note over A: Approval required when amount is at or above threshold

    A->>A: Approver reviews and decides
    A-->>SO: Status becomes approved

    SO->>I: Checkout and reserve stock
    SO->>I: Deliver goods and record OUT movement
    SO->>F: Create customer invoice and record AR
    F->>F: Record customer receipt
Loading

πŸ“‚ Project Structure

StockKit/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ cmd/api/              # Main entry point (serve, migrate, seed, version)
β”‚   β”œβ”€β”€ internal/
β”‚   β”‚   β”œβ”€β”€ approval/         # Multi-step approval workflows
β”‚   β”‚   β”œβ”€β”€ auth/             # JWT, EdDSA signing, refresh rotation
β”‚   β”‚   β”œβ”€β”€ categories/       # Product categories (hierarchical)
β”‚   β”‚   β”œβ”€β”€ codes/            # Sequential number allocator
β”‚   β”‚   β”œβ”€β”€ config/           # Environment config
β”‚   β”‚   β”œβ”€β”€ crypto/           # AES-256-GCM field cipher
β”‚   β”‚   β”œβ”€β”€ customers/        # Customer master data
β”‚   β”‚   β”œβ”€β”€ dashboard/        # Aggregated KPIs
β”‚   β”‚   β”œβ”€β”€ devutil/          # OS disk usage (windows/unix)
β”‚   β”‚   β”œβ”€β”€ finance/          # Cash accounts, payments
β”‚   β”‚   β”œβ”€β”€ fx/               # FX rates
β”‚   β”‚   β”œβ”€β”€ httpapi/          # Router, handlers, middleware
β”‚   β”‚   β”œβ”€β”€ inventory/        # Stock levels, movements, COGS
β”‚   β”‚   β”œβ”€β”€ invoices/         # Supplier invoices, payments
β”‚   β”‚   β”œβ”€β”€ logging/          # Colored rotating structured logs
β”‚   β”‚   β”œβ”€β”€ notify/           # In-app notifications
β”‚   β”‚   β”œβ”€β”€ products/         # Product catalog
β”‚   β”‚   β”œβ”€β”€ purchasing/       # Purchase requests, PO, goods receipts
β”‚   β”‚   β”œβ”€β”€ sales/            # Sales orders, customer invoices, receipts
β”‚   β”‚   β”œβ”€β”€ store/            # pg pool, redis client
β”‚   β”‚   β”œβ”€β”€ suppliers/        # Supplier master (encrypted bank accounts)
β”‚   β”‚   β”œβ”€β”€ units/            # Product units
β”‚   β”‚   └── warehouses/       # Warehouse master
β”‚   └── migrations/           # SQL migrations
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/                  # Next.js app router pages
β”‚   β”œβ”€β”€ components/           # UI primitives + layout
β”‚   └── lib/                  # API client, utils, export (PDF/Excel)
β”œβ”€β”€ docs/                     # Documentation
β”œβ”€β”€ infra/postgres/initdb/    # Database init scripts
└── docker-compose.yml        # Local dev orchestration

🎯 Roadmap

βœ… Completed (M1-M6)

  • Platform foundation (API, auth, migrations)
  • Master data: products, categories, units, warehouses, customers, suppliers
  • Inventory: stock levels, movements, adjustments, FIFO/Average costing
  • Purchasing: requests β†’ PO β†’ goods receipt β†’ supplier invoice
  • Sales: orders β†’ checkout β†’ deliver β†’ invoice β†’ receipt
  • Finance: cash accounts, payments, FX rates
  • Approvals: multi-step workflow with threshold rules
  • Reports: P&L, inventory valuation, AR/AP aging, PDF/Excel export
  • Developer suite: metrics, analytics, disk monitor, live logs
  • RBAC: sidebar gating for developer-only features

🚧 In Progress (M7)

  • Approval decided hook (sync document status on approve/reject)
  • Multi-currency auto-conversion on documents
  • Goods receipts UI polish

πŸ“… Planned (M8+)

  • BPJS/Tax integrations
  • Advanced forecasting (inventory demand)
  • Mobile app (React Native)
  • Webhook system for external integrations
  • Audit log viewer (immutable, filterable)

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m "feat(module): description")
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Commit Convention

We follow Conventional Commits:

  • feat: β€” new features
  • fix: β€” bug fixes
  • docs: β€” documentation only
  • refactor: β€” code refactoring
  • perf: β€” performance improvements
  • test: β€” adding tests
  • chore: β€” maintenance tasks

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


πŸ™ Acknowledgments

Built with ❀️ by Neural Forge Labs for Indonesian businesses.

Special thanks to:

  • Go community β€” pgx, chi, golang-migrate
  • Next.js team β€” App Router, Turbopack
  • Recharts β€” beautiful, composable charts
  • Indonesian UMKM β€” inspiration for localization

If you find StockKit useful, please ⭐ star the repository!

⬆ Back to top

About

Multi-tenant business operations platform for Indonesian companies: inventory, purchasing, sales, finance, payments, approval workflows, and reporting. Go + Next.js + PostgreSQL.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages