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)