Go to file
2025-11-05 15:38:08 +05:30
.cursor first commit 2025-10-29 19:31:40 +05:30
data tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
database first commit 2025-10-29 19:31:40 +05:30
docs tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
scripts added websocket implementaion and enhanced activity logs 2025-11-03 21:18:05 +05:30
src configuration screen added added 2025-11-05 15:38:08 +05:30
tests first commit 2025-10-29 19:31:40 +05:30
.dockerignore first commit 2025-10-29 19:31:40 +05:30
.eslintrc.json first commit 2025-10-29 19:31:40 +05:30
.gitignore first commit 2025-10-29 19:31:40 +05:30
.prettierrc first commit 2025-10-29 19:31:40 +05:30
ADMIN_CONFIGURATIONS.md configuration screen added added 2025-11-05 15:38:08 +05:30
AUTO_MIGRATION_SETUP_COMPLETE.md configuration screen added added 2025-11-05 15:38:08 +05:30
babel.config.js first commit 2025-10-29 19:31:40 +05:30
backend_structure.txt created create request flow 2025-10-30 18:09:05 +05:30
COMPLETE_TAT_IMPLEMENTATION_GUIDE.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
CONFIGURATION.md configuration screen added added 2025-11-05 15:38:08 +05:30
debug_tat_alerts.sql tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
DESIGN_VS_IMPLEMENTATION.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
docker-compose.yml tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
Dockerfile first commit 2025-10-29 19:31:40 +05:30
DYNAMIC_TAT_THRESHOLDS.md configuration screen added added 2025-11-05 15:38:08 +05:30
DYNAMIC_WORKING_HOURS.md configuration screen added added 2025-11-05 15:38:08 +05:30
env.example tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
ERD_Mermaid.txt first commit 2025-10-29 19:31:40 +05:30
FIXES_APPLIED.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
HOLIDAY_AND_ADMIN_CONFIG_COMPLETE.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
HOLIDAY_EXPRESS_TAT.md configuration screen added added 2025-11-05 15:38:08 +05:30
INSTALL_REDIS.txt tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
jest.config.js first commit 2025-10-29 19:31:40 +05:30
KPI_SETUP_COMPLETE.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
MIGRATION_QUICK_REFERENCE.md configuration screen added added 2025-11-05 15:38:08 +05:30
MIGRATION_WORKFLOW.md configuration screen added added 2025-11-05 15:38:08 +05:30
nodemon.json first commit 2025-10-29 19:31:40 +05:30
package-lock.json tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
package.json configuration screen added added 2025-11-05 15:38:08 +05:30
QUICK_FIX_CONFIGURATIONS.md configuration screen added added 2025-11-05 15:38:08 +05:30
QUICK_START_SKIP_ADD_APPROVER.md configuration screen added added 2025-11-05 15:38:08 +05:30
README.md first commit 2025-10-29 19:31:40 +05:30
SETUP_COMPLETE.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
SETUP_SUMMARY.md configuration screen added added 2025-11-05 15:38:08 +05:30
setup.bat first commit 2025-10-29 19:31:40 +05:30
SKIP_AND_ADD_APPROVER.md configuration screen added added 2025-11-05 15:38:08 +05:30
SMART_MIGRATIONS_COMPLETE.md configuration screen added added 2025-11-05 15:38:08 +05:30
START_HERE.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
TAT_ALERTS_DISPLAY_COMPLETE.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
TAT_ENHANCED_DISPLAY_SUMMARY.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
TAT_QUICK_START.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
TROUBLESHOOTING_TAT_ALERTS.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
tsconfig.json first commit 2025-10-29 19:31:40 +05:30
UPSTASH_QUICK_REFERENCE.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30
WHY_NO_ALERTS_SHOWING.md tab job started implementing add holiday featre added in seetings worknote moved to request detail sceen 2025-11-04 20:35:42 +05:30

Royal Enfield Workflow Management System - Backend

A comprehensive backend API for the Royal Enfield Workflow Management System built with Node.js, TypeScript, Express.js, and PostgreSQL.

Features

  • Frontend SSO Integration: Handles user authentication via frontend SSO
  • JWT Authentication: Secure token-based authentication with refresh tokens
  • User Management: Create and update users based on SSO data
  • Workflow Management: Complete workflow request lifecycle
  • Approval System: Multi-level approval workflow
  • Document Management: File upload and management
  • Notification System: Real-time notifications
  • TAT Tracking: Turnaround time monitoring
  • Audit Logging: Comprehensive activity tracking
  • RESTful API: Well-structured API endpoints

Technology Stack

  • Runtime: Node.js 22 LTS
  • Language: TypeScript 5.7
  • Framework: Express.js 4.21
  • Database: PostgreSQL 16
  • ORM: Sequelize 6.37
  • Authentication: JWT + Frontend SSO
  • Validation: Zod
  • Logging: Winston
  • Testing: Jest + Supertest
  • Process Manager: PM2

Quick Start

Prerequisites

  • Node.js 22.x LTS
  • PostgreSQL 16.x
  • npm 10.x or higher

Installation

  1. Clone the repository

    git clone <repository-url>
    cd re-workflow-backend
    
  2. Install dependencies

    npm install
    
  3. Setup environment

    cp env.example .env
    # Edit .env with your configuration
    
  4. Setup database

    # Create database
    createdb re_workflow_db
    
    # Run schema
    psql -U postgres -d re_workflow_db -f database/schema/schema.sql
    
  5. Start development server

    npm run dev
    

The API will be available at http://localhost:5000

Docker Setup

# Copy environment file
cp env.example .env

# Start services
docker-compose up --build -d

# Check logs
docker-compose logs -f

API Endpoints

Authentication

  • POST /api/v1/auth/sso-callback - SSO callback from frontend
  • GET /api/v1/auth/me - Get current user profile
  • POST /api/v1/auth/refresh - Refresh access token
  • POST /api/v1/auth/logout - Logout user
  • GET /api/v1/auth/validate - Validate token

Health Check

  • GET /health - API health status
  • GET /api/v1/health - Detailed health check

Environment Variables

See env.example for all required environment variables.

Development

# Run in development mode
npm run dev

# Run tests
npm test

# Run linting
npm run lint

# Run type checking
npm run type-check

# Build for production
npm run build

Project Structure

src/
├── app.ts                 # Express app configuration
├── server.ts              # Server entry point
├── config/                # Configuration files
├── controllers/           # Request handlers
├── services/              # Business logic
├── models/                # Sequelize models
├── routes/                # API routes
├── middlewares/           # Express middlewares
├── validators/            # Request validation schemas
├── utils/                 # Utility functions
└── types/                 # TypeScript type definitions

Database Schema

The database schema includes all tables from the ERD:

  • users - User information
  • workflow_requests - Main workflow requests
  • approval_levels - Approval hierarchy
  • participants - Workflow participants
  • documents - Document metadata
  • work_notes - Communication within workflow
  • activities - Activity log
  • notifications - User notifications
  • tat_tracking - TAT monitoring
  • And more...

Authentication Flow

  1. Frontend handles SSO authentication
  2. Frontend sends user data to /api/v1/auth/sso-callback
  3. Backend creates/updates user record
  4. Backend generates JWT tokens
  5. Frontend uses tokens for subsequent API calls

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

License

This project is proprietary to Royal Enfield.

Support

For support and questions, please contact the development team.