Skip to content

Timverhoogt/Measurement

Repository files navigation

DMAIC Measurement Application

A comprehensive measurement phase application for the DMAIC (Define, Measure, Analyze, Improve, Control) cycle, specifically designed for petrochemical storage terminal operations while maintaining general applicability.

Features

Phase 1 & 2 Complete Implementation

  • AI-Powered Method Suggestions: Live OpenRouter/Claude API integration for personalized recommendations
  • Method Customization: Complete 3-step workflow for customizing measurement methods with drag-drop interface
  • Advanced Data Collection: Comprehensive forms with validation, auto-save, bulk entry, and import/export
  • Analytics Dashboard: Interactive Chart.js visualizations with trend analysis and AI insights
  • Comprehensive Method Library: 6 pre-built templates for petrochemical terminal and general manufacturing
  • Multi-language Support: English and Dutch translations for international operations
  • Real-time AI Guidance: Context-aware chatbot with OpenRouter/Claude integration
  • Export Capabilities: JSON, CSV, and chart export for analysis phase integration
  • Session Management: Full session tracking with timer, pause/resume, and data persistence

Technology Stack

Frontend

  • HTML5 with semantic structure
  • Tailwind CSS for responsive styling
  • Chart.js for data visualization
  • Vanilla JavaScript for application logic
  • Context-aware AI chatbot integration

Backend

  • Node.js/Express server with comprehensive middleware
  • RESTful API architecture with full CRUD operations
  • OpenRouter/Claude API integration with fallback support
  • Advanced AI service layer for recommendations and insights
  • In-memory storage (development) / Database ready (production)

Security & Performance

  • Helmet.js for security headers
  • Rate limiting protection
  • CORS configuration
  • Request validation
  • Compression middleware

Quick Start

Prerequisites

  • Node.js 16+ and npm 8+
  • Modern web browser
  • OpenRouter API key (optional, for AI features)

Installation

  1. Clone and setup:

    git clone <repository-url>
    cd dmaic-measurement-app
    npm install
  2. Environment configuration:

    copy .env.example .env

    Edit .env with your configuration values.

  3. Start development server:

    npm run dev
  4. Serve static files (alternative):

    npm run serve
  5. Access the application: Open http://localhost:3001 in your browser

Development Commands

# Development
npm run dev          # Start with auto-reload
npm run serve        # Serve static files only

# Production
npm start            # Start production server

# Quality
npm run lint         # Check code style
npm run lint:fix     # Fix code style issues
npm test             # Run tests
npm run build        # Build and validate

# Docker
npm run docker:build # Build Docker image
npm run docker:run   # Run in container

Project Structure

dmaic-measurement-app/
├── app/lib/                    # Frontend JavaScript modules
│   ├── measure.js             # Core measurement functionality
│   ├── measurement-methods.js # Method database and management
│   ├── auth.js               # Authentication system
│   ├── session-handler.js    # Session management
│   └── i18n.js              # Internationalization
├── server/                    # Backend Express application
│   ├── api/                  # API route handlers
│   ├── data/                 # Data files and schemas
│   └── index.js             # Main server file
├── data/                     # Client-side data storage
├── measure.html             # Main application page
├── inject-chatbot.js        # Chatbot integration
├── package.json             # Dependencies and scripts
└── README.md               # This file

API Endpoints

Measurement Methods

  • GET /api/measurement-methods - List all methods
  • GET /api/measurement-methods/:id - Get specific method
  • POST /api/measurement-methods/recommendations - Get AI recommendations
  • POST /api/measurement-methods/:id/customize - Customize method
  • POST /api/measurement-methods/validate - Validate measurement data

Measurement Data

  • GET /api/measurement-data - Get measurement data
  • POST /api/measurement-data - Store new measurement
  • GET /api/measurement-data/:id - Get specific measurement
  • PUT /api/measurement-data/:id - Update measurement
  • DELETE /api/measurement-data/:id - Delete measurement
  • GET /api/measurement-data/export - Export data (CSV/JSON)
  • GET /api/measurement-data/stats - Get statistics

Chatbot

  • POST /api/chatbot/message - Send message to chatbot
  • GET /api/chatbot/conversations/:id - Get conversation history
  • POST /api/chatbot/analyze-context - Analyze project context

Define Phase Integration

  • GET /api/define/projects - Get Define phase projects
  • GET /api/define/context - Get current project context
  • POST /api/define/projects/:id/transition-to-measure - Transition to Measure

Configuration

Environment Variables

See .env.example for all available configuration options.

AI Integration

Configure OpenRouter API access for Claude AI suggestions:

OPENROUTER_API_KEY=your_key_here
OPENROUTER_MODEL=anthropic/claude-3.5-sonnet

Database Setup (Production)

For production deployment, configure database connection:

DATABASE_URL=postgresql://user:password@localhost:5432/dmaic_measurement
DATABASE_TYPE=postgresql

Industry-Specific Features

Petrochemical Terminal Operations

  • Tank cleaning time and motion studies
  • Equipment utilization tracking
  • Product quality and compliance measurements
  • Safety and environmental monitoring
  • Multi-product handling workflows

General Manufacturing

  • Process cycle time analysis
  • Defect rate and quality tracking
  • Customer satisfaction measurement
  • Statistical process control
  • Resource utilization monitoring

Integration Points

From Define Phase

  • Import project goals and context
  • Transition readiness assessment
  • Stakeholder information
  • Success criteria and constraints

To Analysis Phase

  • Structured measurement data export
  • Statistical analysis preparation
  • Data quality validation
  • Baseline and trend data

Security Considerations

  • Input validation on all endpoints
  • Rate limiting to prevent abuse
  • CORS configuration for trusted origins
  • Session management with timeouts
  • Secure headers with Helmet.js
  • No sensitive data in client-side code

Performance Optimization

  • Gzip compression enabled
  • Static file caching
  • Database query optimization ready
  • Frontend lazy loading
  • Chart.js for efficient visualization
  • Minimal JavaScript framework overhead

Browser Support

  • Chrome 90+
  • Firefox 88+
  • Safari 14+
  • Edge 90+
  • Modern mobile browsers

Contributing

  1. Follow existing code style and patterns
  2. Add tests for new functionality
  3. Update documentation for API changes
  4. Use semantic commit messages
  5. Test across supported browsers

License

MIT License - see LICENSE file for details

Support

For technical support or feature requests, please create an issue in the project repository.


Note: This application is part of a larger DMAIC platform. Ensure integration with Define and Analysis phase applications for complete workflow support.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published