Skip to content

Shashikumar-ezhilarasu/HR-Workflow-Design

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

40 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

HR Workflow Designer

HR Workflow Designer

A sophisticated, production-grade HR Workflow Designer built with React, TypeScript, and advanced graph algorithms

React TypeScript React Flow Zustand Tailwind CSS License

Demo โ€ข Features โ€ข Installation โ€ข Documentation โ€ข Architecture


๐Ÿ“‹ Table of Contents


๐ŸŽฏ Overview

The HR Workflow Designer is a sophisticated visual workflow builder that enables HR administrators to architect, configure, and simulate complex internal workflows such as employee onboarding, leave approvals, and automated document verification. Built as a technical showcase, this platform demonstrates expertise in React architecture, advanced graph algorithms, and modular frontend design.

What Makes This Special?

  • Graph Theory at its Core: Real DAG (Directed Acyclic Graph) validation with cycle detection using depth-first search (DFS).
  • Execution Engine: Topological sort-based simulation using Kahn's Algorithm for deterministic workflow execution paths.
  • Production-Ready Prototype: MSW (Mock Service Worker) enabled in production for a functional demo, Zustand for state management, and full TypeScript coverage.
  • Extensible Registry: Modular node pattern for seamless addition of new node types (Start, Task, Approval, Automated, End).

๐ŸŒŸ Vision & Principles

1. Architectural Scalability

Utilizing a modular pattern for nodes and configuration forms allows for easy extension. New node types can be integrated by updating the node factory and type definitions without rewriting core canvas logic.

2. Algorithmic Integrity

Moving beyond simple UI drag-and-drop to true Graph Theory application. The system enforces DAG constraints, performs reachability analysis (Forward/Backward BFS), and executes workflows using proven computer science algorithms.

3. Simulation-First Design

A sandbox that doesn't just "show" steps but executes a logical model of the workflow, complete with conditional branching, approval thresholds, and automated action simulation.


โœจ Features

Canvas & Visual Design

  • โœ… Visual Workflow Designer - Drag-and-drop interface powered by React Flow
  • โœ… Custom Node Types - specialized Start, Task, Approval, Automated, and End nodes
  • โœ… Auto-Layout Engine - Intelligent positioning using Dagre graph layout
  • โœ… Undo/Redo - Full history management with state snapshots in Zustand

Advanced Graph Validation

  • โœ… Cycle Detection - DFS-based algorithm that traces the exact path of circular dependencies
  • โœ… Reachability Analysis - Forward BFS from Start node and Backward BFS from End nodes to find orphans and dead-ends
  • โœ… Workflow Health Score - Real-time weighted metric (0-100%) for structural integrity

Execution Engine

  • โœ… Topological Sort - Kahn's Algorithm used to determine valid linear execution order
  • โœ… Conditional Branching - Resolves approval paths based on thresholds and edge labels
  • โœ… Simulation Sandbox - Real-time execution timeline with collapsible detail logs

Configuration & State

  • โœ… Dynamic Node Forms - Context-aware configuration panels with auto-save (onBlur)
  • โœ… JSON Import/Export - Full serialization for workflow persistence and portability
  • โœ… Dark/Light Mode - Polished Zinc design system with theme persistence

๐Ÿ— Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   Presentation Layer                         โ”‚
โ”‚  Designer.tsx โ€ข WorkflowCanvas โ€ข Node Forms โ€ข SandboxPanel  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Business Logic Layer                        โ”‚
โ”‚  graphValidator.ts โ€ข handlers.ts (Exec Engine) โ€ข Zustand     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Data & Integration Layer                     โ”‚
โ”‚  MSW browser.ts โ€ข serializer.ts โ€ข Dagre Layout              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ›  Tech Stack

Technology Purpose
React 18 UI framework with concurrent features
TypeScript Strict type safety across the entire graph engine
React Flow Node-graph visualization engine
Zustand Lightweight state management with History (Undo/Redo)
MSW API mocking at the network layer (Production-enabled)
Tailwind CSS Premium Zinc styling system
Dagre Graph layout algorithms

๐Ÿš€ Quick Start

# Install dependencies
npm install

# Start development server
npm run dev

The application will be available at http://localhost:5173


๐Ÿ“ Project Structure

HR-workflow/
โ”œโ”€โ”€ public/                      # Static assets & MSW Worker
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ api/                    # Mock API Layer (MSW)
โ”‚   โ”‚   โ”œโ”€โ”€ browser.ts          # Worker setup
โ”‚   โ”‚   โ”œโ”€โ”€ handlers.ts         # Simulation Engine & API Logic
โ”‚   โ”‚   โ””โ”€โ”€ mockData.ts         # Initial templates
โ”‚   โ”œโ”€โ”€ components/             # React Components
โ”‚   โ”‚   โ”œโ”€โ”€ canvas/             # Flow canvas & layout
โ”‚   โ”‚   โ”œโ”€โ”€ forms/              # Dynamic configuration forms
โ”‚   โ”‚   โ”œโ”€โ”€ layout/             # Sidebar & structure
โ”‚   โ”‚   โ”œโ”€โ”€ nodes/              # Custom node templates
โ”‚   โ”‚   โ”œโ”€โ”€ sandbox/            # Timeline & simulation panel
โ”‚   โ”‚   โ”œโ”€โ”€ sidebar/            # Node palette
โ”‚   โ”‚   โ””โ”€โ”€ ui/                 # Reusable primitives
โ”‚   โ”œโ”€โ”€ hooks/                  # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ useSimulate.ts      # Simulation orchestration
โ”‚   โ”‚   โ””โ”€โ”€ useAutomations.ts   # Action fetching
โ”‚   โ”œโ”€โ”€ pages/                  # Top-level views (Designer, Home)
โ”‚   โ”œโ”€โ”€ store/                  # Zustand state (workflowStore.ts)
โ”‚   โ”œโ”€โ”€ types/                  # Unified TS types (workflow.ts)
โ”‚   โ”œโ”€โ”€ utils/                  # Core Algorithms & Utilities
โ”‚   โ”‚   โ”œโ”€โ”€ graphValidator.ts   # DFS/BFS Validation logic
โ”‚   โ”‚   โ”œโ”€โ”€ layout.ts           # Dagre layout logic
โ”‚   โ”‚   โ”œโ”€โ”€ nodeFactory.ts      # Component registry
โ”‚   โ”‚   โ””โ”€โ”€ serializer.ts       # JSON Import/Export
โ”‚   โ”œโ”€โ”€ App.tsx                 # Routing
โ”‚   โ”œโ”€โ”€ main.tsx               # Entry & MSW Initialization
โ”‚   โ””โ”€โ”€ index.css              # Global styles & Zinc theme
โ””โ”€โ”€ package.json

๐Ÿงฎ Core Algorithms

1. Cycle Detection & Path Tracking

Location: src/utils/graphValidator.ts

Uses an iterative DFS with a color-coding scheme (WHITE/GRAY/BLACK) to not only detect cycles but reconstruct the exact path causing the circular dependency.

2. Topological Sort (Kahn's Algorithm)

Location: src/api/handlers.ts

The execution engine determines the correct execution sequence by calculating in-degrees of all nodes and processing them via a queue-based BFS.

3. Reachability Analysis

Location: src/utils/graphValidator.ts

  • Forward BFS: Identifies nodes unreachable from the "Start" node.
  • Backward BFS: Identifies nodes that can never reach an "End" node (dead-ends).

4. Workflow Health Score

Location: src/utils/graphValidator.ts

Calculates a weighted 0-100 score based on total errors (cycles, missing starts) and warnings (orphans, dead-ends) to provide instant user feedback.


๐Ÿ“ก API Documentation

The application uses Mock Service Worker (MSW) to handle logic as if a backend were present.

POST /api/simulate

Takes a WorkflowGraph and returns a SimulationResult containing:

  • steps: Array of execution updates with duration and status.
  • branchDecisions: Record of which paths were taken at approval forks.
  • executionPath: Sequential IDs of traversed nodes.

๐Ÿ—บ Roadmap

  1. Persistence: Integration with Supabase/PostgreSQL.
  2. Templates: Pre-defined onboarding patterns.
  3. Action Hooks: Real webhook integration (Slack/Discord notifications).
  4. AI Insights: Auto-suggestion for workflow optimization.

Built by Shashikumar Ezhilarasu
AI Agentic Engineering - Tredence Studio

About

A sophisticated, production-grade HR Workflow Designer module built as a technical showcase. This platform enables HR administrators to visually architect, configure, and simulate complex internal workflows such as onboarding, leave approvals, and automated document verification.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors