flow-debugger

v1.9.5 โ€ข STABLE

Debug your application flow with high granularity and low overhead.

Readme.md

# ๐Ÿ” flow-debugger > [!IMPORTANT] > **Production-safe flow-level debugging SDK for Node.js, Web, and React Native.** <p align="center"> <strong>๐Ÿ”ฌ Trace Requests Step-by-Step with Root Cause Detection</strong> </p> <div align="center"> <img src="https://img.shields.io/npm/v/flow-debugger" alt="NPM Version"> <img src="https://img.shields.io/bundlephobia/minzip/flow-debugger" alt="Bundle Size"> <img src="https://img.shields.io/npm/dm/flow-debugger" alt="Downloads"> <img src="https://img.shields.io/badge/TypeScript-100%25-blue" alt="TypeScript"> <img src="https://img.shields.io/badge/Node.js-14%2B-green" alt="Node.js 14+"> </div> --- ## ๐ŸŒŸ Core Highlights > **"Debug production issues in minutes, not hours."** > - **3-Line Setup** โ€” Professional dashboard in minutes > - **Auto-Instrument** โ€” MongoDB, MySQL, PostgreSQL, Redis โ€” zero code > - **Root Cause Detection** โ€” Automatically identifies failures > - **Never Crashes** โ€” All try/catch wrapped, production-safe --- ## ๐Ÿ“Š Dashboard Preview ### **Flow Debugger Dashboard** Traces requests step-by-step with timing analytics: ``` โ”Œโ”€โ”€โ”€ flow-debugger โ”€โ”€ req_m3k2_abc123_1 โ”€โ”€ POST /api/login โ”€โ”€โ”€ โ”‚ [0ms] Request start โ”‚ [2ms] DB find user โœ” (14ms) [mongo] โ”‚ [16ms] Redis cache session โœ” (3ms) [redis] โ”‚ [20ms] JWT generate โœ” (1ms) โ”‚ [21ms] Response 200 โ”‚ โ”‚ Classification: INFO โ”‚ Total: 21ms โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ ``` --- ## ๐Ÿ—๏ธ Architecture ### **System Flow** ```mermaid graph LR A[Request Starts] --> B[Flow Tracer] B --> C[Internal Logic Steps] C --> D[Trace Injection] D --> E[Real-Time Dashboard] E --> F[Success/Error Monitoring] ``` ### **Request Lifecycle** ```mermaid graph TB A[Incoming Request] --> B[Generate traceId] B --> C[Create Tracer] C --> D[Execute Steps] D --> E{Step Success?} E -->|Yes| F[Record Timing] E -->|No| G[Classify Error] F --> H[Send to Dashboard] G --> H H --> I[Update Analytics] ``` ### **Core Components** ```mermaid graph TB A[Express Middleware] --> B[Tracer Factory] B --> C[Step Executor] C --> D[Timing Calculator] D --> E[Error Classifier] E --> F[Root Cause Detector] F --> G[Dashboard API] F --> H[Console Timeline] F --> I[Analytics Engine] G --> J[Live Dashboard] H --> K[Terminal Output] I --> L[Endpoint Stats] ``` --- ## โœจ Key Features ### ๐Ÿ”ฌ **Request Tracing** - **Unique traceId** โ€” Every request gets a unique identifier - **Step-by-step timing** โ€” Precise measurement for each operation - **Service detection** โ€” Auto-identifies MongoDB, Redis, MySQL, etc. - **Console timeline** โ€” Visual request flow in terminal ### ๐ŸŽฏ **Auto-Instrumentation** | Database | Status | Operations Traced | |----------|--------|-------------------| | **MongoDB** | โœ… Full | find, findOne, insert, update, delete | | **MySQL** | โœ… Full | query, execute | | **PostgreSQL** | โœ… Full | query | | **Redis** | โœ… Full | get, set, del, hget, hset | ### ๐Ÿšจ **Error Intelligence** - **Error Classification** โ€” INFO / WARN / ERROR / CRITICAL - **Root Cause Detection** โ€” Identifies why requests fail - **Timeout Detection** โ€” Catches hanging queries/operations - **Slow Query Detection** โ€” Flags slow DB operations ### ๐Ÿ“Š **Analytics Dashboard** - **Endpoint Analytics** โ€” Per-route stats (requests, errors, latency) - **Service Health Monitor** โ€” Real-time dependency health - **Live Dashboard** โ€” Beautiful UI at `/__debugger/dashboard` - **P95/P99 Metrics** โ€” Advanced latency percentiles ### ๐Ÿ›ก๏ธ **Production-Safe** - **Never blocks** โ€” All async, non-blocking - **Never crashes** โ€” All try/catch wrapped - **Sampling support** โ€” Configurable rate for high-traffic - **Zero dependencies** โ€” Lightweight core --- ## ๐Ÿ“ฆ Package Info - **Version**: 1.9.5 - **License**: MIT - **TypeScript**: 100% type-safe - **Node.js**: >=14.0.0 - **Dependencies**: 0 production dependencies - **Peer Dependencies**: Express, Mongoose, MySQL2, PG, Redis (optional) --- ## ๐Ÿงช Testing ### **Test Coverage** ```bash npm test ``` --- ## ๐Ÿ“ˆ Version History | Version | Features | Status | |---------|----------|--------| | **1.0.0 - 1.5.0** | Basic tracing | โœ… Stable | | **1.5.1 - 1.8.0** | Auto-instrument | โœ… Stable | | **1.8.1 - 1.9.5** | Root cause detection | โœ… Current | --- ## ๐Ÿ”— Links - **GitHub**: [flow-debugger](https://github.com/sannuk79/PROJECTS-AND-NPM-PACKAGES-) - **NPM**: [flow-debugger](https://www.npmjs.com/package/flow-debugger) - **Issues**: [Report a bug](https://github.com/sannuk79/debugerpackages/issues)