0%

Enterprise ERP Platform

[ 2026 ]

Built for Setuna Plastik — Solo-Developed, Production-Deployed

A full enterprise ERP system covering the manufacturing pipeline from raw material procurement to finished goods delivery. 83 Prisma models span 18 business modules — purchasing, production, warehousing, quality control, sales, finance, and HR. Authentication runs through Microsoft Entra ID (Azure AD) with session versioning that can force-refresh all JWTs company-wide. The RBAC system maps 18 modules by 4 actions into 72 permission points enforced at middleware level. The stock engine handles FEFO/FIFO lot picking, atomic reservation transactions, and 8 movement types in a single transactional flow.

Core Mechanics

A new packaging and bottle manufacturing company needed a complete ERP system tailored exactly to their needs — covering procurement, production planning, inventory with lot tracking, quality control, sales pipeline, and financial reporting. Off-the-shelf and existing solutions lacked the bespoke depth required for their unique manufacturing processes.

Technology Stack
Next.js 14TypeScriptPrisma 5PostgreSQLAzure AD (Entra ID)Tailwind CSSRechartsReact FlowFramer MotionRender
demo/setuna-erp
Status: Online
System Secure

Project Impact & Scope

Lines of Code~59,500
Database Models83
API Routes147
AuthAzure AD SSO + Session Versioning
Modules18 (72 permission points)
Stock EngineFEFO/FIFO + Atomic Reservations

Architecture & Solution

Designed and built the entire system solo. The 83-model Prisma schema covers every business entity from raw material lots through production orders to customer invoices. The stock engine (599 lines) implements FEFO/FIFO picking strategies with automatic multi-lot splitting, atomic AVAILABLE-to-RESERVED transitions, and 8 movement types (receipt, issue, transfer, adjustment, scrap, return, production input/output) all within single database transactions. Azure AD SSO uses the tenant-wide OID claim instead of the app-specific SUB for stable identity. A session versioning mechanism lets admins invalidate all active sessions instantly. The BOM (Bill of Materials) editor uses React Flow for visual tree construction.

Monolithic Next.js — deliberate choice at this scale. Prisma provides type-safe access across 83 models with PostgreSQL on Render. The stock engine runs all movements inside prisma.$transaction() for atomicity. RBAC enforces a module-by-action matrix at middleware level with a SuperAdmin env fallback for lockout recovery. Sequence generator produces typed document numbers (PO-001, SM-001, RES-001). React Flow powers the visual BOM editor. Recharts handles dashboard analytics.

Critical Challenges

  • 01Designing 83 interconnected models without circular dependencies — the schema alone is 2,263 lines of Prisma
  • 02Building a stock engine that handles FEFO/FIFO lot picking with atomic reservation transactions across multiple warehouses
  • 03Implementing Azure AD SSO with OID-based identity, session versioning, and 1-minute permission refresh intervals
  • 04Creating an RBAC system granular enough for 18 modules with 4 actions each while keeping middleware enforcement performant

Screenshots

ERP Dashboard — KPIs, Kanban boards, and calendar

ERP Dashboard — KPIs, Kanban boards, and calendar

Warehouse & Inventory — Stock tracking and movements

Warehouse & Inventory — Stock tracking and movements

Production Dashboard — Manufacturing orders and KPIs

Production Dashboard — Manufacturing orders and KPIs

Bill of Materials — Product tree editor

Bill of Materials — Product tree editor

Reports — Analytics and data visualization

Reports — Analytics and data visualization

Try It Out