flow-debugger 1.0.0
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/PORTFOLIO_README_SECTION.md +177 -0
- package/README.md +251 -0
- package/dashboard/app.js +339 -0
- package/dashboard/index.html +168 -0
- package/dashboard/style.css +846 -0
- package/dist/cjs/core/Analytics.js +174 -0
- package/dist/cjs/core/Analytics.js.map +1 -0
- package/dist/cjs/core/Classifier.js +66 -0
- package/dist/cjs/core/Classifier.js.map +1 -0
- package/dist/cjs/core/HealthMonitor.js +79 -0
- package/dist/cjs/core/HealthMonitor.js.map +1 -0
- package/dist/cjs/core/RootCause.js +89 -0
- package/dist/cjs/core/RootCause.js.map +1 -0
- package/dist/cjs/core/Sampler.js +34 -0
- package/dist/cjs/core/Sampler.js.map +1 -0
- package/dist/cjs/core/Timeline.js +90 -0
- package/dist/cjs/core/Timeline.js.map +1 -0
- package/dist/cjs/core/TraceEngine.js +222 -0
- package/dist/cjs/core/TraceEngine.js.map +1 -0
- package/dist/cjs/core/types.js +21 -0
- package/dist/cjs/core/types.js.map +1 -0
- package/dist/cjs/index.js +46 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/integrations/axios.js +136 -0
- package/dist/cjs/integrations/axios.js.map +1 -0
- package/dist/cjs/integrations/fetch.js +153 -0
- package/dist/cjs/integrations/fetch.js.map +1 -0
- package/dist/cjs/integrations/mongo.js +111 -0
- package/dist/cjs/integrations/mongo.js.map +1 -0
- package/dist/cjs/integrations/mysql.js +212 -0
- package/dist/cjs/integrations/mysql.js.map +1 -0
- package/dist/cjs/integrations/postgres.js +182 -0
- package/dist/cjs/integrations/postgres.js.map +1 -0
- package/dist/cjs/integrations/redis.js +105 -0
- package/dist/cjs/integrations/redis.js.map +1 -0
- package/dist/cjs/middleware/express.js +255 -0
- package/dist/cjs/middleware/express.js.map +1 -0
- package/dist/esm/core/Analytics.js +170 -0
- package/dist/esm/core/Analytics.js.map +1 -0
- package/dist/esm/core/Classifier.js +61 -0
- package/dist/esm/core/Classifier.js.map +1 -0
- package/dist/esm/core/HealthMonitor.js +75 -0
- package/dist/esm/core/HealthMonitor.js.map +1 -0
- package/dist/esm/core/RootCause.js +86 -0
- package/dist/esm/core/RootCause.js.map +1 -0
- package/dist/esm/core/Sampler.js +30 -0
- package/dist/esm/core/Sampler.js.map +1 -0
- package/dist/esm/core/Timeline.js +86 -0
- package/dist/esm/core/Timeline.js.map +1 -0
- package/dist/esm/core/TraceEngine.js +217 -0
- package/dist/esm/core/TraceEngine.js.map +1 -0
- package/dist/esm/core/types.js +18 -0
- package/dist/esm/core/types.js.map +1 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/integrations/axios.js +133 -0
- package/dist/esm/integrations/axios.js.map +1 -0
- package/dist/esm/integrations/fetch.js +149 -0
- package/dist/esm/integrations/fetch.js.map +1 -0
- package/dist/esm/integrations/mongo.js +107 -0
- package/dist/esm/integrations/mongo.js.map +1 -0
- package/dist/esm/integrations/mysql.js +209 -0
- package/dist/esm/integrations/mysql.js.map +1 -0
- package/dist/esm/integrations/postgres.js +179 -0
- package/dist/esm/integrations/postgres.js.map +1 -0
- package/dist/esm/integrations/redis.js +102 -0
- package/dist/esm/integrations/redis.js.map +1 -0
- package/dist/esm/middleware/express.js +219 -0
- package/dist/esm/middleware/express.js.map +1 -0
- package/dist/types/core/Analytics.d.ts +35 -0
- package/dist/types/core/Analytics.d.ts.map +1 -0
- package/dist/types/core/Classifier.d.ts +21 -0
- package/dist/types/core/Classifier.d.ts.map +1 -0
- package/dist/types/core/HealthMonitor.d.ts +14 -0
- package/dist/types/core/HealthMonitor.d.ts.map +1 -0
- package/dist/types/core/RootCause.d.ts +12 -0
- package/dist/types/core/RootCause.d.ts.map +1 -0
- package/dist/types/core/Sampler.d.ts +13 -0
- package/dist/types/core/Sampler.d.ts.map +1 -0
- package/dist/types/core/Timeline.d.ts +22 -0
- package/dist/types/core/Timeline.d.ts.map +1 -0
- package/dist/types/core/TraceEngine.d.ts +47 -0
- package/dist/types/core/TraceEngine.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +118 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/integrations/axios.d.ts +22 -0
- package/dist/types/integrations/axios.d.ts.map +1 -0
- package/dist/types/integrations/fetch.d.ts +25 -0
- package/dist/types/integrations/fetch.d.ts.map +1 -0
- package/dist/types/integrations/mongo.d.ts +26 -0
- package/dist/types/integrations/mongo.d.ts.map +1 -0
- package/dist/types/integrations/mysql.d.ts +20 -0
- package/dist/types/integrations/mysql.d.ts.map +1 -0
- package/dist/types/integrations/postgres.d.ts +20 -0
- package/dist/types/integrations/postgres.d.ts.map +1 -0
- package/dist/types/integrations/redis.d.ts +20 -0
- package/dist/types/integrations/redis.d.ts.map +1 -0
- package/dist/types/middleware/express.d.ts +39 -0
- package/dist/types/middleware/express.d.ts.map +1 -0
- package/example/server.ts +234 -0
- package/jest.config.js +8 -0
- package/package.json +110 -0
- package/portfolio-repo/APIRESPONSE DASH.png +0 -0
- package/portfolio-repo/PAYLOAD.png +0 -0
- package/portfolio-repo/README.md +182 -0
- package/src/core/Analytics.ts +209 -0
- package/src/core/Classifier.ts +82 -0
- package/src/core/HealthMonitor.ts +92 -0
- package/src/core/RootCause.ts +105 -0
- package/src/core/Sampler.ts +35 -0
- package/src/core/Timeline.ts +108 -0
- package/src/core/TraceEngine.ts +266 -0
- package/src/core/types.ts +170 -0
- package/src/index.ts +42 -0
- package/src/integrations/axios.ts +164 -0
- package/src/integrations/fetch.ts +172 -0
- package/src/integrations/mongo.ts +130 -0
- package/src/integrations/mysql.ts +239 -0
- package/src/integrations/postgres.ts +217 -0
- package/src/integrations/redis.ts +122 -0
- package/src/middleware/express.ts +264 -0
- package/tests/Analytics.test.ts +136 -0
- package/tests/Classifier.test.ts +57 -0
- package/tests/RootCause.test.ts +69 -0
- package/tests/TraceEngine.test.ts +110 -0
- package/tsconfig.cjs.json +9 -0
- package/tsconfig.esm.json +9 -0
- package/tsconfig.json +31 -0
- package/tsconfig.types.json +8 -0
|
@@ -0,0 +1,234 @@
|
|
|
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
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "flow-debugger",
|
|
3
|
+
"version": "1.0.0",
|
|
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
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/cjs/index.js",
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"types": "./dist/types/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./express": {
|
|
15
|
+
"require": "./dist/cjs/middleware/express.js",
|
|
16
|
+
"import": "./dist/esm/middleware/express.js",
|
|
17
|
+
"types": "./dist/types/middleware/express.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./mongo": {
|
|
20
|
+
"require": "./dist/cjs/integrations/mongo.js",
|
|
21
|
+
"import": "./dist/esm/integrations/mongo.js",
|
|
22
|
+
"types": "./dist/types/integrations/mongo.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./mysql": {
|
|
25
|
+
"require": "./dist/cjs/integrations/mysql.js",
|
|
26
|
+
"import": "./dist/esm/integrations/mysql.js",
|
|
27
|
+
"types": "./dist/types/integrations/mysql.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./postgres": {
|
|
30
|
+
"require": "./dist/cjs/integrations/postgres.js",
|
|
31
|
+
"import": "./dist/esm/integrations/postgres.js",
|
|
32
|
+
"types": "./dist/types/integrations/postgres.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./redis": {
|
|
35
|
+
"require": "./dist/cjs/integrations/redis.js",
|
|
36
|
+
"import": "./dist/esm/integrations/redis.js",
|
|
37
|
+
"types": "./dist/types/integrations/redis.d.ts"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "npm run build:cjs && npm run build:esm && npm run build:types",
|
|
42
|
+
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
43
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
44
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
45
|
+
"dev": "ts-node example/server.ts",
|
|
46
|
+
"test": "jest --config jest.config.js",
|
|
47
|
+
"prepublishOnly": "npm run build"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"debugger",
|
|
51
|
+
"trace",
|
|
52
|
+
"flow",
|
|
53
|
+
"monitoring",
|
|
54
|
+
"performance",
|
|
55
|
+
"analytics",
|
|
56
|
+
"root-cause",
|
|
57
|
+
"express",
|
|
58
|
+
"mongodb",
|
|
59
|
+
"mysql",
|
|
60
|
+
"postgresql",
|
|
61
|
+
"redis",
|
|
62
|
+
"apm",
|
|
63
|
+
"observability"
|
|
64
|
+
],
|
|
65
|
+
"author": "",
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"express": "^4.0.0 || ^5.0.0",
|
|
69
|
+
"mongoose": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
70
|
+
"mysql2": "^2.0.0 || ^3.0.0",
|
|
71
|
+
"pg": "^8.0.0",
|
|
72
|
+
"redis": "^4.0.0",
|
|
73
|
+
"axios": "^0.27.0 || ^1.0.0"
|
|
74
|
+
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"express": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"mongoose": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"mysql2": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"pg": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"redis": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"axios": {
|
|
92
|
+
"optional": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"devDependencies": {
|
|
96
|
+
"@types/express": "^4.17.21",
|
|
97
|
+
"@types/jest": "^29.5.12",
|
|
98
|
+
"@types/node": "^20.11.19",
|
|
99
|
+
"@types/pg": "^8.10.9",
|
|
100
|
+
"express": "^4.18.2",
|
|
101
|
+
"jest": "^29.7.0",
|
|
102
|
+
"mongoose": "^8.1.0",
|
|
103
|
+
"mysql2": "^3.7.0",
|
|
104
|
+
"pg": "^8.11.3",
|
|
105
|
+
"ts-jest": "^29.1.2",
|
|
106
|
+
"ts-node": "^10.9.2",
|
|
107
|
+
"typescript": "^5.3.3",
|
|
108
|
+
"autocannon": "^7.15.0"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,182 @@
|
|
|
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>
|