flow-debugger 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/PORTFOLIO_README_SECTION.md +0 -177
- package/example/server.ts +0 -234
- package/jest.config.js +0 -8
- package/portfolio-repo/APIRESPONSE DASH.png +0 -0
- package/portfolio-repo/PAYLOAD.png +0 -0
- package/portfolio-repo/README.md +0 -182
- package/src/core/Analytics.ts +0 -209
- package/src/core/Classifier.ts +0 -82
- package/src/core/HealthMonitor.ts +0 -92
- package/src/core/RootCause.ts +0 -105
- package/src/core/Sampler.ts +0 -35
- package/src/core/Timeline.ts +0 -108
- package/src/core/TraceEngine.ts +0 -266
- package/src/core/types.ts +0 -170
- package/src/index.ts +0 -42
- package/src/integrations/axios.ts +0 -164
- package/src/integrations/fetch.ts +0 -172
- package/src/integrations/mongo.ts +0 -130
- package/src/integrations/mysql.ts +0 -239
- package/src/integrations/postgres.ts +0 -217
- package/src/integrations/redis.ts +0 -122
- package/src/middleware/express.ts +0 -264
- package/tests/Analytics.test.ts +0 -136
- package/tests/Classifier.test.ts +0 -57
- package/tests/RootCause.test.ts +0 -69
- package/tests/TraceEngine.test.ts +0 -110
- package/tsconfig.cjs.json +0 -9
- package/tsconfig.esm.json +0 -9
- package/tsconfig.json +0 -31
- package/tsconfig.types.json +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flow-debugger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Production-safe flow-level debugging SDK. Traces requests, measures timing, classifies errors, detects root causes, and provides endpoint analytics with a live dashboard.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
# Flow Debugger - Portfolio README Section
|
|
2
|
-
|
|
3
|
-
Copy this section and add it to your portfolio README at:
|
|
4
|
-
https://github.com/sannuk79/PROJECTS-AND-NPM-PACKAGES-
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
### 🔍 3. Flow Debugger
|
|
9
|
-
**Production-safe request tracing with root cause detection and live analytics dashboard.**
|
|
10
|
-
|
|
11
|
-
[](https://www.npmjs.com/package/flow-debugger)
|
|
12
|
-
[](https://github.com/sannuk79/debugerpackages)
|
|
13
|
-
[](https://www.npmjs.com/package/flow-debugger)
|
|
14
|
-
|
|
15
|
-

|
|
16
|
-
|
|
17
|
-
### 🔄 Architecture Overview
|
|
18
|
-
```mermaid
|
|
19
|
-
graph LR
|
|
20
|
-
A[Request] --> B[Generate TraceID]
|
|
21
|
-
B --> C[Step-by-Step Tracking]
|
|
22
|
-
C --> D[Auto-Classify: INFO/WARN/ERROR/CRITICAL]
|
|
23
|
-
D --> E[Root Cause Detection]
|
|
24
|
-
E --> F[Analytics Dashboard]
|
|
25
|
-
F --> G[Search & Filter]
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### ✨ Key Features
|
|
29
|
-
|
|
30
|
-
**Auto-Instrumentation (Zero Code Changes):**
|
|
31
|
-
- ✅ MongoDB, MySQL, PostgreSQL, Redis
|
|
32
|
-
- ✅ Fetch API, Axios
|
|
33
|
-
- ✅ Express middleware
|
|
34
|
-
|
|
35
|
-
**External API Tracing:**
|
|
36
|
-
- 🔵 Stripe API auto-tagged
|
|
37
|
-
- 🟢 Razorpay API auto-tagged
|
|
38
|
-
- 🟡 SendGrid API auto-tagged
|
|
39
|
-
- 🟣 Twilio API auto-tagged
|
|
40
|
-
|
|
41
|
-
**Advanced Debugging:**
|
|
42
|
-
- 🎯 **Root Cause Detection**: Timeout → Failure → Slow bottleneck algorithm
|
|
43
|
-
- 📄 **Error Stack Preview**: Shows `errorFile:line` in dashboard (e.g., `auth.service.ts:42`)
|
|
44
|
-
- 📦 **Payload Size Detection**: Warns on large payloads (>1MB) slowing requests
|
|
45
|
-
- 🌍 **Environment Tagging**: Filter traces by dev/staging/production
|
|
46
|
-
- 🔍 **Trace Search**: Search by traceId, endpoint, error message
|
|
47
|
-
- 📊 **Live Dashboard**: Real-time analytics at `/__debugger/dashboard`
|
|
48
|
-
|
|
49
|
-
**Production-Safe:**
|
|
50
|
-
- ⚡ Never blocks requests
|
|
51
|
-
- 🛡️ All code wrapped in try/catch
|
|
52
|
-
- 🚀 <1ms overhead per request
|
|
53
|
-
|
|
54
|
-
### 📈 Performance Metrics
|
|
55
|
-
|
|
56
|
-
**Load Testing Results:**
|
|
57
|
-
```
|
|
58
|
-
✅ 56,000 requests in 10 seconds
|
|
59
|
-
✅ 100 concurrent connections
|
|
60
|
-
✅ 5,600 req/sec throughput
|
|
61
|
-
✅ <1ms average overhead
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**Test Coverage:**
|
|
65
|
-
```
|
|
66
|
-
✅ 30/30 tests passing
|
|
67
|
-
✅ CJS, ESM, TypeScript builds
|
|
68
|
-
✅ Production-tested
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### 🚀 Quick Start
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
npm install flow-debugger
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
const express = require('express');
|
|
79
|
-
const { flowDebugger, fetchTracer, axiosTracer } = require('flow-debugger');
|
|
80
|
-
const axios = require('axios');
|
|
81
|
-
|
|
82
|
-
const app = express();
|
|
83
|
-
app.use(express.json());
|
|
84
|
-
|
|
85
|
-
// Initialize with environment
|
|
86
|
-
const debugger_ = flowDebugger({
|
|
87
|
-
environment: 'production',
|
|
88
|
-
slowThreshold: 300,
|
|
89
|
-
largePayloadThreshold: 1024 * 1024, // 1MB
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
app.use(debugger_.middleware);
|
|
93
|
-
|
|
94
|
-
// Auto-trace external APIs
|
|
95
|
-
fetchTracer({ getTracer: debugger_.getTracer });
|
|
96
|
-
axiosTracer(axios, { getTracer: debugger_.getTracer });
|
|
97
|
-
|
|
98
|
-
// Your routes...
|
|
99
|
-
app.get('/api/users', async (req, res) => {
|
|
100
|
-
// All database calls, API calls automatically traced
|
|
101
|
-
const users = await User.find();
|
|
102
|
-
res.json(users);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
app.listen(3000);
|
|
106
|
-
// Dashboard: http://localhost:3000/__debugger/dashboard
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### 🎯 Real Production Use Cases
|
|
110
|
-
|
|
111
|
-
**1. Payment Gateway Failures**
|
|
112
|
-
```
|
|
113
|
-
🔍 Root Cause: Stripe API timed out after 2000ms
|
|
114
|
-
Service: stripe | Confidence: high
|
|
115
|
-
📄 payment.service.ts:89
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
**2. Large Payload Slowdown**
|
|
119
|
-
```
|
|
120
|
-
POST /api/upload 📦 5.2MB WARN 1200ms
|
|
121
|
-
Root Cause: Large payload (5.2MB) slowed JSON parsing
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**3. Environment-Specific Bugs**
|
|
125
|
-
```
|
|
126
|
-
Search: "redis" | Environment: production
|
|
127
|
-
Found 12 results — all showing ECONNREFUSED in production only
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**4. Service Failure Breakdown**
|
|
131
|
-
```
|
|
132
|
-
Top Failures:
|
|
133
|
-
Stripe API 42%
|
|
134
|
-
Redis 33%
|
|
135
|
-
PostgreSQL 12%
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### 📊 Dashboard Features
|
|
139
|
-
|
|
140
|
-
- **Real-time Monitoring**: Live request traces with auto-refresh
|
|
141
|
-
- **Service Health**: Track MongoDB, MySQL, PostgreSQL, Redis, external APIs
|
|
142
|
-
- **Endpoint Analytics**: Avg/P95/Max latency, error rates, slow query detection
|
|
143
|
-
- **Search & Filter**: Find traces by ID, endpoint, error message, environment
|
|
144
|
-
- **Root Cause Detection**: Automatic identification of failure origins
|
|
145
|
-
- **Error Stack Preview**: Direct file:line references for debugging
|
|
146
|
-
|
|
147
|
-
### 🔗 Links
|
|
148
|
-
|
|
149
|
-
**[View on NPM](https://www.npmjs.com/package/flow-debugger)** | **[Source Code](https://github.com/sannuk79/debugerpackages)** | **[Documentation](https://github.com/sannuk79/debugerpackages#readme)**
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## Combined Usage Example
|
|
154
|
-
|
|
155
|
-
Build a hardened, monitored, and debuggable API with all three packages:
|
|
156
|
-
|
|
157
|
-
```javascript
|
|
158
|
-
const { apiMonitor } = require('@sannuk792/api-response-monitor');
|
|
159
|
-
const { guard } = require('payload-guard-filter');
|
|
160
|
-
const { flowDebugger } = require('flow-debugger');
|
|
161
|
-
|
|
162
|
-
const debugger_ = flowDebugger({ environment: 'production' });
|
|
163
|
-
|
|
164
|
-
app.use(apiMonitor({ mode: 'minimal' })); // Global Monitoring
|
|
165
|
-
app.use(debugger_.middleware); // Request Tracing
|
|
166
|
-
|
|
167
|
-
app.post('/api/secure-data', (req, res) => {
|
|
168
|
-
const safeBody = userShape(req.body); // Precise Filtering
|
|
169
|
-
res.json(safeBody);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// Dashboards:
|
|
173
|
-
// - API Monitor: http://localhost:3000/__monitor
|
|
174
|
-
// - Flow Debugger: http://localhost:3000/__debugger/dashboard
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
---
|
package/example/server.ts
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────
|
|
2
|
-
// flow-debugger — Example Server
|
|
3
|
-
// Simulates real-world APIs with DB, Redis, and external calls
|
|
4
|
-
// Demonstrates all features: tracing, root cause, timeline, dashboard
|
|
5
|
-
// ─────────────────────────────────────────────────────────────
|
|
6
|
-
|
|
7
|
-
import express from 'express';
|
|
8
|
-
import { flowDebugger } from '../src/middleware/express';
|
|
9
|
-
|
|
10
|
-
const app = express();
|
|
11
|
-
app.use(express.json());
|
|
12
|
-
|
|
13
|
-
// ─── Initialize Flow Debugger ─────────────────────────────
|
|
14
|
-
const debugger_ = flowDebugger({
|
|
15
|
-
slowThreshold: 300,
|
|
16
|
-
slowQueryThreshold: 300,
|
|
17
|
-
enableTimeline: true,
|
|
18
|
-
enableDashboard: true,
|
|
19
|
-
samplingRate: 1, // 100% for testing
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
app.use(debugger_.middleware);
|
|
23
|
-
|
|
24
|
-
// ─── Simulated DB / Redis helpers ─────────────────────────
|
|
25
|
-
function simulateDelay(ms: number): Promise<void> {
|
|
26
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function randomBetween(min: number, max: number): number {
|
|
30
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// ─── API Routes ───────────────────────────────────────────
|
|
34
|
-
|
|
35
|
-
// 1. Login — simulates DB + Redis + JWT
|
|
36
|
-
app.post('/api/login', async (req, res) => {
|
|
37
|
-
const tracer = req.tracer!;
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
// Step 1: Find user in DB
|
|
41
|
-
const user = await tracer.step('DB find user', async () => {
|
|
42
|
-
await simulateDelay(randomBetween(5, 25));
|
|
43
|
-
return { id: 'u_123', name: 'Saurabh', email: 'saurabh@test.com' };
|
|
44
|
-
}, { service: 'mongo' });
|
|
45
|
-
|
|
46
|
-
// Step 2: Verify password
|
|
47
|
-
await tracer.step('Verify password', async () => {
|
|
48
|
-
await simulateDelay(randomBetween(2, 10));
|
|
49
|
-
return true;
|
|
50
|
-
}, { service: 'internal' });
|
|
51
|
-
|
|
52
|
-
// Step 3: Cache session in Redis
|
|
53
|
-
await tracer.step('Redis set session', async () => {
|
|
54
|
-
await simulateDelay(randomBetween(1, 8));
|
|
55
|
-
return 'OK';
|
|
56
|
-
}, { service: 'redis' });
|
|
57
|
-
|
|
58
|
-
// Step 4: Generate JWT
|
|
59
|
-
const token = await tracer.step('JWT generate', async () => {
|
|
60
|
-
await simulateDelay(randomBetween(1, 5));
|
|
61
|
-
return 'eyJhbGciOiJIUzI1NiJ9.mock_token';
|
|
62
|
-
}, { service: 'internal' });
|
|
63
|
-
|
|
64
|
-
res.json({ success: true, token, user });
|
|
65
|
-
} catch (err: any) {
|
|
66
|
-
res.status(500).json({ error: err.message });
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// 2. Orders — simulates slow DB query
|
|
71
|
-
app.get('/api/orders', async (req, res) => {
|
|
72
|
-
const tracer = req.tracer!;
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
// Slow query simulation
|
|
76
|
-
const orders = await tracer.step('DB query orders', async () => {
|
|
77
|
-
const delay = randomBetween(100, 600); // Sometimes slow!
|
|
78
|
-
await simulateDelay(delay);
|
|
79
|
-
return [
|
|
80
|
-
{ id: 'ord_1', amount: 2500, status: 'completed' },
|
|
81
|
-
{ id: 'ord_2', amount: 1800, status: 'pending' },
|
|
82
|
-
];
|
|
83
|
-
}, { service: 'postgres', metadata: { sql: 'SELECT * FROM orders WHERE user_id = ?' } });
|
|
84
|
-
|
|
85
|
-
// Cache result
|
|
86
|
-
await tracer.step('Redis cache orders', async () => {
|
|
87
|
-
await simulateDelay(randomBetween(1, 5));
|
|
88
|
-
return 'OK';
|
|
89
|
-
}, { service: 'redis' });
|
|
90
|
-
|
|
91
|
-
res.json({ orders });
|
|
92
|
-
} catch (err: any) {
|
|
93
|
-
res.status(500).json({ error: err.message });
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// 3. Dashboard — simulates multiple DB queries
|
|
98
|
-
app.get('/api/dashboard', async (req, res) => {
|
|
99
|
-
const tracer = req.tracer!;
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
const [stats, recentOrders, notifications] = await Promise.all([
|
|
103
|
-
tracer.step('MySQL stats query', async () => {
|
|
104
|
-
await simulateDelay(randomBetween(10, 40));
|
|
105
|
-
return { totalUsers: 1200, totalOrders: 890, revenue: 125000 };
|
|
106
|
-
}, { service: 'mysql', metadata: { sql: 'SELECT COUNT(*) FROM users' } }),
|
|
107
|
-
|
|
108
|
-
tracer.step('Postgres recent orders', async () => {
|
|
109
|
-
await simulateDelay(randomBetween(15, 50));
|
|
110
|
-
return [{ id: 'ord_1', amount: 500 }];
|
|
111
|
-
}, { service: 'postgres', metadata: { sql: 'SELECT * FROM orders ORDER BY created_at DESC LIMIT 10' } }),
|
|
112
|
-
|
|
113
|
-
tracer.step('Redis get notifications', async () => {
|
|
114
|
-
await simulateDelay(randomBetween(2, 8));
|
|
115
|
-
return [{ msg: 'New order received' }];
|
|
116
|
-
}, { service: 'redis' }),
|
|
117
|
-
]);
|
|
118
|
-
|
|
119
|
-
res.json({ stats, recentOrders, notifications });
|
|
120
|
-
} catch (err: any) {
|
|
121
|
-
res.status(500).json({ error: err.message });
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// 4. User Profile — simulates Redis failure
|
|
126
|
-
app.get('/api/profile/:id', async (req, res) => {
|
|
127
|
-
const tracer = req.tracer!;
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
// Try Redis cache first
|
|
131
|
-
let cached: any = null;
|
|
132
|
-
try {
|
|
133
|
-
cached = await tracer.step('Redis get cache', async () => {
|
|
134
|
-
// Randomly fail to simulate Redis issues
|
|
135
|
-
if (Math.random() > 0.5) {
|
|
136
|
-
throw new Error('ECONNREFUSED: Redis connection refused');
|
|
137
|
-
}
|
|
138
|
-
await simulateDelay(randomBetween(1, 5));
|
|
139
|
-
return null; // cache miss
|
|
140
|
-
}, { service: 'redis' });
|
|
141
|
-
} catch {
|
|
142
|
-
// Redis failed, fall through to DB
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Fetch from DB
|
|
146
|
-
const user = await tracer.step('Mongo find user', async () => {
|
|
147
|
-
await simulateDelay(randomBetween(8, 30));
|
|
148
|
-
return { id: req.params.id, name: 'Saurabh', role: 'admin' };
|
|
149
|
-
}, { service: 'mongo' });
|
|
150
|
-
|
|
151
|
-
res.json({ user, fromCache: false });
|
|
152
|
-
} catch (err: any) {
|
|
153
|
-
res.status(500).json({ error: err.message });
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// 5. Payment — simulates external API call with timeout potential
|
|
158
|
-
app.post('/api/payment', async (req, res) => {
|
|
159
|
-
const tracer = req.tracer!;
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
// Validate in DB
|
|
163
|
-
await tracer.step('MySQL validate order', async () => {
|
|
164
|
-
await simulateDelay(randomBetween(5, 20));
|
|
165
|
-
return true;
|
|
166
|
-
}, { service: 'mysql', metadata: { sql: 'SELECT * FROM orders WHERE id = ? AND status = ?' } });
|
|
167
|
-
|
|
168
|
-
// Call external payment gateway
|
|
169
|
-
await tracer.step('Payment Gateway API', async () => {
|
|
170
|
-
const delay = randomBetween(50, 400);
|
|
171
|
-
await simulateDelay(delay);
|
|
172
|
-
if (delay > 350) throw new Error('Gateway timeout');
|
|
173
|
-
return { transactionId: 'txn_abc123', status: 'success' };
|
|
174
|
-
}, { service: 'external', timeout: 5000 });
|
|
175
|
-
|
|
176
|
-
// Update DB
|
|
177
|
-
await tracer.step('MySQL update payment', async () => {
|
|
178
|
-
await simulateDelay(randomBetween(5, 15));
|
|
179
|
-
return true;
|
|
180
|
-
}, { service: 'mysql', metadata: { sql: 'UPDATE orders SET payment_status = ? WHERE id = ?' } });
|
|
181
|
-
|
|
182
|
-
// Clear cache
|
|
183
|
-
await tracer.step('Redis clear cache', async () => {
|
|
184
|
-
await simulateDelay(randomBetween(1, 5));
|
|
185
|
-
return 'OK';
|
|
186
|
-
}, { service: 'redis' });
|
|
187
|
-
|
|
188
|
-
res.json({ success: true, transactionId: 'txn_abc123' });
|
|
189
|
-
} catch (err: any) {
|
|
190
|
-
res.status(500).json({ error: err.message });
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// 6. Search — simulates heavy query
|
|
195
|
-
app.get('/api/search', async (req, res) => {
|
|
196
|
-
const tracer = req.tracer!;
|
|
197
|
-
const q = req.query.q || 'test';
|
|
198
|
-
|
|
199
|
-
try {
|
|
200
|
-
const results = await tracer.step('Postgres full-text search', async () => {
|
|
201
|
-
// Simulate a potentially slow full-text search
|
|
202
|
-
const delay = randomBetween(50, 800);
|
|
203
|
-
await simulateDelay(delay);
|
|
204
|
-
return [{ id: 1, title: `Result for: ${q}` }];
|
|
205
|
-
}, { service: 'postgres', metadata: { sql: `SELECT * FROM products WHERE to_tsvector(name) @@ to_tsquery('${q}')` } });
|
|
206
|
-
|
|
207
|
-
res.json({ results, count: results.length });
|
|
208
|
-
} catch (err: any) {
|
|
209
|
-
res.status(500).json({ error: err.message });
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
// ─── Start Server ─────────────────────────────────────────
|
|
214
|
-
const PORT = process.env.PORT || 3500;
|
|
215
|
-
app.listen(PORT, () => {
|
|
216
|
-
console.log('');
|
|
217
|
-
console.log(' ┌──────────────────────────────────────────────────┐');
|
|
218
|
-
console.log(' │ │');
|
|
219
|
-
console.log(' │ 🔍 Flow Debugger — Example Server │');
|
|
220
|
-
console.log(` │ Server: http://localhost:${PORT} │`);
|
|
221
|
-
console.log(` │ Dashboard: http://localhost:${PORT}/__debugger/dashboard │`);
|
|
222
|
-
console.log(` │ API: http://localhost:${PORT}/__debugger │`);
|
|
223
|
-
console.log(' │ │');
|
|
224
|
-
console.log(' │ Test endpoints: │');
|
|
225
|
-
console.log(' │ POST /api/login (DB + Redis + JWT) │');
|
|
226
|
-
console.log(' │ GET /api/orders (Slow DB query) │');
|
|
227
|
-
console.log(' │ GET /api/dashboard (Multi-service) │');
|
|
228
|
-
console.log(' │ GET /api/profile/:id (Redis failures) │');
|
|
229
|
-
console.log(' │ POST /api/payment (External API) │');
|
|
230
|
-
console.log(' │ GET /api/search?q=x (Heavy Postgres) │');
|
|
231
|
-
console.log(' │ │');
|
|
232
|
-
console.log(' └──────────────────────────────────────────────────┘');
|
|
233
|
-
console.log('');
|
|
234
|
-
});
|
package/jest.config.js
DELETED
|
Binary file
|
|
Binary file
|
package/portfolio-repo/README.md
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
# 🚀 Sannu Kumar - Full-Stack & Systems Engineer
|
|
2
|
-
|
|
3
|
-
> **Portfolio:** [sannu-portfolio.vercel.app](https://sannu-portfolio.vercel.app/portfolio) | **Catalog:** [Projects Catalog](https://sannu-portfolio.vercel.app/portfolio/projects)
|
|
4
|
-
|
|
5
|
-
Welcome to my professional laboratory. Here, I build production-grade NPM packages, enterprise-scale web applications, and high-performance mobile solutions.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## 💎 Featured NPM Packages
|
|
11
|
-
|
|
12
|
-
### 📊 1. API Response Monitor
|
|
13
|
-
**Debug production API issues in seconds with request tracing and slow endpoint detection.**
|
|
14
|
-
|
|
15
|
-
[](https://www.npmjs.com/package/@sannuk792/api-response-monitor)
|
|
16
|
-
[](https://www.npmjs.com/package/@sannuk792/api-response-monitor)
|
|
17
|
-
|
|
18
|
-

|
|
19
|
-
|
|
20
|
-
### � Workflow Overview
|
|
21
|
-
```mermaid
|
|
22
|
-
graph LR
|
|
23
|
-
A[Request] --> B[Generate RequestID]
|
|
24
|
-
B --> C[Intercept Response]
|
|
25
|
-
C --> D[Calculate Metrics]
|
|
26
|
-
D --> E[Async Logging/Storage]
|
|
27
|
-
E --> F[Dashboard/Analytics]
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
- **Production Tracing**: Auto-generated `requestId` in every response.
|
|
31
|
-
- **Protocol Metadata**: Built-in SDK version, platform, and service tagging for microservices.
|
|
32
|
-
- **Hardened Stability**: Verified with a **14-point stress test** (100 req/sec, circular ref protection, middleware isolation).
|
|
33
|
-
- **Advanced Monitoring**: Built-in slow endpoint detection & health metrics.
|
|
34
|
-
- **Fail-Safe Design**: Monitoring logic never blocks or crashes your API.
|
|
35
|
-
- **Non-Blocking**: Non-allocation fast paths with ~0.2ms overhead.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### ⛑️ Maintained actively.
|
|
39
|
-
**Bug fixes usually within 24–48 hours.**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
**[View on NPM](https://www.npmjs.com/package/@sannuk792/api-response-monitor)** | **[Source Code](https://github.com/sannuk79/ApiMonitor)**
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
### 🛡️ 2. Payload Guard
|
|
47
|
-
**Lightweight, zero-dependency shape-based filtering & sanitization.**
|
|
48
|
-
|
|
49
|
-
[](https://www.npmjs.com/package/payload-guard-filter)
|
|
50
|
-
|
|
51
|
-

|
|
52
|
-
|
|
53
|
-
### �️ Workflow Overview
|
|
54
|
-
```mermaid
|
|
55
|
-
graph LR
|
|
56
|
-
A[Request] --> B(Gatekeeper)
|
|
57
|
-
B --> C{Shape Check}
|
|
58
|
-
C -- Valid --> D[Redact & Clean]
|
|
59
|
-
C -- Invalid --> E[Strict Error / Fail Safe]
|
|
60
|
-
D --> F[Secure Response]
|
|
61
|
-
E --> F
|
|
62
|
-
F --> G((Metrics))
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
- **Shape-based Filtering**: Define what you want, auto-remove everything else.
|
|
66
|
-
- **Sensitive Protection**: `password`, `token`, `secret` auto-redacted.
|
|
67
|
-
- **High Performance**: Optimized schema compilation for sub-millisecond execution.
|
|
68
|
-
|
|
69
|
-
**[View on NPM](https://www.npmjs.com/package/payload-guard-filter)**
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
### 🔍 3. Flow Debugger
|
|
74
|
-
**Production-safe request tracing with root cause detection and live analytics dashboard.**
|
|
75
|
-
|
|
76
|
-
[](https://www.npmjs.com/package/flow-debugger)
|
|
77
|
-
[](https://github.com/sannuk79/debugerpackages)
|
|
78
|
-
|
|
79
|
-

|
|
80
|
-
|
|
81
|
-
### 🔄 Workflow Overview
|
|
82
|
-
```mermaid
|
|
83
|
-
graph LR
|
|
84
|
-
A[Request] --> B[Generate TraceID]
|
|
85
|
-
B --> C[Step-by-Step Tracking]
|
|
86
|
-
C --> D[Auto-Classify: INFO/WARN/ERROR/CRITICAL]
|
|
87
|
-
D --> E[Root Cause Detection]
|
|
88
|
-
E --> F[Analytics Dashboard]
|
|
89
|
-
F --> G[Search & Filter]
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
**Key Features:**
|
|
93
|
-
- **Auto-Instrumentation**: MongoDB, MySQL, PostgreSQL, Redis, Fetch, Axios — zero code changes
|
|
94
|
-
- **External API Tracing**: Stripe, Razorpay, SendGrid, Twilio auto-tagged
|
|
95
|
-
- **Root Cause Detection**: Timeout → Failure → Slow bottleneck algorithm
|
|
96
|
-
- **Error Stack Preview**: Shows `errorFile:line` in dashboard (e.g., `auth.service.ts:42`)
|
|
97
|
-
- **Payload Size Detection**: Warns on large payloads (>1MB) slowing requests
|
|
98
|
-
- **Environment Tagging**: Filter traces by dev/staging/production
|
|
99
|
-
- **Trace Search**: Search by traceId, endpoint, error message
|
|
100
|
-
- **Live Dashboard**: Real-time analytics at `/__debugger/dashboard`
|
|
101
|
-
- **Production-Safe**: Never blocks requests, all try/catch wrapped
|
|
102
|
-
|
|
103
|
-
**Performance:**
|
|
104
|
-
- **Load Tested**: 56,000 requests in 10s (100 concurrent connections)
|
|
105
|
-
- **Throughput**: 5,600 req/sec
|
|
106
|
-
- **Overhead**: <1ms per request
|
|
107
|
-
|
|
108
|
-
**[View on NPM](https://www.npmjs.com/package/flow-debugger)** | **[Source Code](https://github.com/sannuk79/debugerpackages)**
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## 📂 Project Catalog
|
|
113
|
-
|
|
114
|
-
A selection of production-grade applications and experimental prototypes.
|
|
115
|
-
|
|
116
|
-
| Project | Category | Description | Tech Stack |
|
|
117
|
-
|:---|:---|:---|:---|
|
|
118
|
-
| **DRIVERRUNNER** | Mobile | Complete Ride Sharing Platform with real-time tracking & payments. | Node, Mongo, RN, Socket.IO |
|
|
119
|
-
| **SHOPMIND AI** | Web | AI-powered price comparison with Rust-accelerated scraping. | Next.js 15, FastAPI, Rust |
|
|
120
|
-
| **URBANCRUISE LMS** | Web | Enterprise Lead Management System with real-time visualization. | Next.js, Express, MySQL |
|
|
121
|
-
| **TASKVISTA** | Web | Team Management Dashboard for developer communities. | React, Kendo UI, Tailwind |
|
|
122
|
-
| **BIOMETRIC AUTH** | Tools | WebAuthn system for passwordless fingerprint login. | WebAuthn, React 19, Security |
|
|
123
|
-
| **API MONITOR** | Tools | The official NPM package for API latency and health tracking. | NPM, Node.js, Metrics |
|
|
124
|
-
|
|
125
|
-
### ✨ Project Deep Dives
|
|
126
|
-
|
|
127
|
-
#### 🚕 [DriverRunner](#)
|
|
128
|
-
A comprehensive ride-hailing solution featuring 3 separate apps. Includes OTP-based authentication, real-time driver tracking (React Native Maps), and live booking systems via Socket.IO.
|
|
129
|
-
|
|
130
|
-
#### 🤖 [ShopMind AI](https://shopmind-ai.vercel.app/)
|
|
131
|
-
Intelligent price comparison platform. Uses Rust-accelerated scraping engines for speed and WebAuthn for biometric fingerprint login.
|
|
132
|
-
|
|
133
|
-
#### 📊 [UrbanCruise LMS](https://lms-leadmangsystem.vercel.app/)
|
|
134
|
-
Enterprise-grade lead tracking system. Handles multi-source collection (Meta, Google Ads) with real-time dashboards using Recharts and role-based access control.
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## ⚡ Performance Benchmarks
|
|
139
|
-
|
|
140
|
-
### 🛡️ Payload Guard (Production Scale)
|
|
141
|
-
| Benchmark | ops/sec | avg (ms) |
|
|
142
|
-
|-----------|---------|----------|
|
|
143
|
-
| **Small payload** | 449,365 | **0.0022ms** |
|
|
144
|
-
| **Medium payload** | 7,791 | **0.1284ms** |
|
|
145
|
-
| **Large payload** | 246 | **4.0724ms** |
|
|
146
|
-
|
|
147
|
-
### 📊 API Monitor (Middleware Overhead)
|
|
148
|
-
| Metric | Full Mode | Minimal Mode |
|
|
149
|
-
|-----------|---------|----------|
|
|
150
|
-
| **Latency** | ~0.18ms | **<0.05ms** |
|
|
151
|
-
| **Throughput** | 50k+ RPM | 100k+ RPM |
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## 🛠️ Combined Usage
|
|
156
|
-
|
|
157
|
-
Build a hardened, monitored, and debuggable API:
|
|
158
|
-
```javascript
|
|
159
|
-
const { apiMonitor } = require('@sannuk792/api-response-monitor');
|
|
160
|
-
const { guard } = require('payload-guard-filter');
|
|
161
|
-
const { flowDebugger } = require('flow-debugger');
|
|
162
|
-
|
|
163
|
-
const debugger_ = flowDebugger({ environment: 'production' });
|
|
164
|
-
|
|
165
|
-
app.use(apiMonitor({ mode: 'minimal' })); // Global Monitoring
|
|
166
|
-
app.use(debugger_.middleware); // Request Tracing
|
|
167
|
-
|
|
168
|
-
app.post('/api/secure-data', (req, res) => {
|
|
169
|
-
const safeBody = userShape(req.body); // Precise Filtering
|
|
170
|
-
res.json(safeBody);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
// Dashboard: http://localhost:3000/__debugger/dashboard
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
<p align="center">
|
|
179
|
-
Connect with me on <strong>[Portfolio](https://sannu-portfolio.vercel.app/portfolio)</strong>
|
|
180
|
-
<br>
|
|
181
|
-
Made with ❤️ for High-Performance Systems
|
|
182
|
-
</p>
|