Back to Portfolio

StockFlow ERP

A lightweight full-stack ERP and CRM system for wholesale and distribution businesses — managing customers, products, inventory, sales challans, and follow-up activities across internal teams.

Full Stack Developer React · Node.js · PostgreSQL Case Study
StockFlow ERP Dashboard

StockFlow ERP — Business summary dashboard with KPIs, recent activity, and low stock alerts.

01. Project Overview

StockFlow ERP is a comprehensive production-grade solution designed to handle core business operations for a wholesale/distribution enterprise. Built as a full-stack developer case study, it showcases REST API design, complex database modeling, role-based authentication, and real inventory business logic wrapped in a modern SaaS-style UI built with Tailwind CSS v4.

The system manages customers, products, inventory, sales challans, and follow-up activities for internal teams such as Sales, Warehouse, and Accounts — each with role-specific access.

02. Tech Stack

  • Frontend: React + TypeScript + Vite — fast HMR during development; React Router for multi-page navigation.
  • Styling: Tailwind CSS v4 for a consistent, responsive SaaS design system.
  • Backend: Node.js + Express.js (TypeScript) — RESTful API with modular routes, controllers, services, and middleware layers.
  • Database & ORM: PostgreSQL with Prisma ORM — type-safe, migration-driven schema management.
  • Auth & Validation: JWT Authentication, Zod schema validation on all API inputs, role-based middleware on every protected route.
  • Deployment: Vercel (Frontend), Render (Backend), GitHub Actions CI/CD pipeline.
Architectural Decision: Using TypeScript across the entire stack alongside Prisma ORM ensured type safety from database schema through to API responses and frontend components — drastically reducing runtime errors during development and making the codebase self-documenting.

03. Authentication & CRM

The system implements JWT-based authentication with distinct role access levels. A single requireRole() middleware guards every protected route, ensuring each team sees only what's relevant to them:

  • Admin: Full access — users, products, customers, challans, reports.
  • Sales: Manage customers and create/view challans.
  • Warehouse: View and manage inventory and stock movements.
  • Accounts: View challans, financial summaries, and reports.
StockFlow ERP Login Screen StockFlow ERP Customer CRM

Login screen (left) and Customer CRM with follow-up notes and status tracking (right).

04. Inventory Management

The inventory module handles complete product lifecycle management with built-in safeguards:

  • Product & SKU Management: Add, edit, and categorize products with full SKU assignment.
  • Real-Time Stock Tracking: Live stock levels with configurable minimum stock alerts for low inventory warnings.
  • Immutable Movement Log: Every stock change (IN/OUT) creates a timestamped, paginated audit log — capturing the product, quantity, reason, responsible user, and timestamp.
StockFlow ERP Inventory Management

Inventory page — product list with stock levels, SKUs, and minimum stock alert indicators.

05. Sales Challan Flow

The challan system is the core business workflow of StockFlow ERP, requiring precise implementation of business rules:

  • Sequential Numbering: Challans are auto-assigned a sequential ID in the format CH-YYYY-NNNNN, auto-incremented at the database level to prevent duplicates.
  • Draft → Confirmed → Cancelled: Challans go through a state machine; stock is only deducted on confirmation.
  • Product Snapshot: Product name, SKU, unit price, and quantity are snapshotted at time of sale in a JSONB column — preserving historical accuracy even if product details change later.
Critical Business Rule — Preventing Negative Stock: Confirming a challan with insufficient stock is blocked at the database level using PostgreSQL row-level locking (SELECT ... FOR UPDATE) before the quantity check and deduction, eliminating race conditions entirely.
StockFlow ERP Sales Challan

Sales challan creation — multi-product selection, automatic numbering, and state management.

06. CI/CD & Deployment

  • GitHub Actions: A CI pipeline (.github/workflows/ci.yml) runs on every push — linting, type-checking, and building both frontend and backend to catch regressions early.
  • Vercel: Frontend is deployed with VITE_API_URL pointing to the production backend — zero config, instant CDN distribution.
  • Render: Backend runs with environment variables for database, JWT secret, and CORS origin — npx prisma migrate deploy runs automatically on startup to keep schema in sync.
Note for Reviewers: The backend is hosted on Render's free tier, which sleeps after 15 minutes of inactivity. The first login may take 45–50 seconds for the server to wake up. All subsequent requests are instant.
Live Demo View on GitHub All Projects