Skip to content

Latest commit

Β 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PerfSight

Performance Monitoring Platform - A comprehensive full-stack application for real-time performance monitoring, regression detection, and Git-tracked baseline management.

πŸš€ Features

Backend Features

  • Real-time Metrics Ingestion - Collect latency, throughput, and performance data
  • Regression Detection - Hybrid z-score + baseline comparison algorithms
  • Git-Tracked Baselines - Version-controlled per-user performance baselines stored as JSON
  • Unix Perf Integration - CPU cycles, cache misses, instruction counts
  • Automated Analysis Worker - Background processing every 60 seconds
  • Comprehensive Reports - Aggregated analysis with actionable insights
  • Secure Authentication - JWT-based auth with HTTP-only cookies
  • Rate Limiting - DDoS protection with express-rate-limit
  • Input Validation - Joi schemas for all API endpoints
  • Security Headers - Helmet middleware for production-ready security

Frontend Features

  • Modern Landing Page - Beautiful gradient hero with feature showcase
  • System Dashboard - Real-time overview of all monitored services
  • Service Details - Deep dive into individual service performance
  • Interactive Charts - Recharts-powered latency and performance visualizations
  • Regression Alerts - Critical and warning-level performance notifications
  • Reports & Baselines - Browse historical data and Git baselines
  • Skeleton Loading - Smooth UX with animated loading states
  • Performance Optimized - React.memo, useMemo, custom hooks
  • Responsive Design - Mobile, tablet, and desktop support
  • Redux State Management - Centralized auth and API state

πŸ“‹ Prerequisites

  • Node.js v18+ (recommended: v20+)
  • MongoDB v5+ (local or Atlas)
  • Git (for baseline management)
  • npm or yarn

πŸ› οΈ Installation

1. Clone the Repository

git clone https://github.com/yourusername/perfsight.git
cd PerfSight

2. Backend Setup

cd backend
npm install

Create a .env file in the backend directory:

NODE_ENV=development
PORT=5000
MONGO_URI=mongodb://localhost:27017/perfsight
JWT_SECRET=your_jwt_secret_key_here

# MongoDB TTL retention (days). Default: 30
DATA_RETENTION_DAYS=30

For MongoDB Atlas:

MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/perfsight?retryWrites=true&w=majority

3. Frontend Setup

cd ../frontend
npm install

πŸš€ Running the Application

Development Mode

Terminal 1 - Backend Server:

cd backend
npm run dev

Server runs on: http://localhost:5000

Terminal 2 - Analysis Worker (Optional):

cd backend
npm run worker

Terminal 3 - Frontend Dev Server:

cd frontend
npm run dev

Frontend runs on: http://localhost:3000

Production Build

Build Frontend:

cd frontend
npm run build

Run Production Server:

cd backend
NODE_ENV=production npm start

App runs on: http://localhost:5000 (serves both API and frontend)

πŸ“ Project Structure

PerfSight/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── db.js              # MongoDB connection
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”‚   β”œβ”€β”€ authMiddleware.js  # JWT authentication
β”‚   β”‚   β”‚   └── errorMiddleware.js # Error handling
β”‚   β”‚   β”œβ”€β”€ modules/
β”‚   β”‚   β”‚   β”œβ”€β”€ users/             # User authentication
β”‚   β”‚   β”‚   β”œβ”€β”€ metrics/           # Metric ingestion
β”‚   β”‚   β”‚   β”œβ”€β”€ analysis/          # Rolling window analysis
β”‚   β”‚   β”‚   β”œβ”€β”€ regression/        # Regression detection
β”‚   β”‚   β”‚   β”œβ”€β”€ baseline/          # Git baseline management
β”‚   β”‚   β”‚   β”œβ”€β”€ perf/              # Unix perf metrics
β”‚   β”‚   β”‚   β”œβ”€β”€ report/            # Aggregated reports
β”‚   β”‚   β”‚   └── dashboard/         # Dashboard API
β”‚   β”‚   β”œβ”€β”€ workers/
β”‚   β”‚   β”‚   └── analysis.worker.js # Background analysis
β”‚   β”‚   β”œβ”€β”€ app.js                 # Express app config
β”‚   β”‚   └── server.js              # Server entry point
β”‚   β”œβ”€β”€ .env.example
β”‚   β”œβ”€β”€ package.json
β”‚   └── server.js                  # Main entry point
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── axiosClient.js     # Axios configuration
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/         # ServiceCard, LoadingState
β”‚   β”‚   β”‚   β”œβ”€β”€ service/           # SummaryCard, PerfMetricsCard
β”‚   β”‚   β”‚   β”œβ”€β”€ charts/            # LatencyChart, RangeSelector
β”‚   β”‚   β”‚   β”œβ”€β”€ alerts/            # AlertBanner, SeverityBadge
β”‚   β”‚   β”‚   β”œβ”€β”€ reports/           # ReportTable
β”‚   β”‚   β”‚   β”œβ”€β”€ baselines/         # BaselineCard, BaselineList
β”‚   β”‚   β”‚   β”œβ”€β”€ skeletons/         # Loading skeletons
β”‚   β”‚   β”‚   └── layout/            # Header, Sidebar, DashboardLayout
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   β”œβ”€β”€ api/               # Custom data-fetching hooks
β”‚   β”‚   β”‚   └── useScrollToTop.js  # Navigation scroll utility
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx      # System overview
β”‚   β”‚   β”‚   β”œβ”€β”€ ServiceDetails.jsx # Service deep dive
β”‚   β”‚   β”‚   β”œβ”€β”€ Reports.jsx        # Reports browser
β”‚   β”‚   β”‚   β”œβ”€β”€ Baselines.jsx      # Git baselines
β”‚   β”‚   β”‚   └── Perf.jsx           # Perf metrics
β”‚   β”‚   β”œβ”€β”€ screens/
β”‚   β”‚   β”‚   β”œβ”€β”€ HomeScreen.jsx     # Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginScreen.jsx    # Authentication
β”‚   β”‚   β”‚   └── RegisterScreen.jsx # User registration
β”‚   β”‚   β”œβ”€β”€ slices/
β”‚   β”‚   β”‚   β”œβ”€β”€ authSlice.js       # Auth state
β”‚   β”‚   β”‚   └── apiSlice.js        # RTK Query
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ main.jsx
β”‚   β”‚   └── store.js               # Redux store
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── package.json
β”‚
β”œβ”€β”€ baselines/                     # Per-user baselines: <userId>/<service>.json
β”‚   └── README.md                  # Baseline docs
β”‚
└── README.md                      # This file

πŸ”Œ API Endpoints

Authentication

  • POST /api/users - Register new user
  • POST /api/users/auth - Login user
  • POST /api/users/logout - Logout user
  • GET /api/users/profile - Get user profile (protected)
  • PUT /api/users/profile - Update user profile (protected)

Metrics

  • POST /api/metrics - Ingest metric (protected)
  • GET /api/metrics/recent?service=:service - Get recent metrics (protected)
  • GET /api/metrics/timeseries - Get latency timeseries (protected)
  • GET /api/metrics/endpoint-summary - Get endpoint summary (protected)
  • GET /api/metrics/overview - Get system overview (protected)

Baselines

  • GET /api/baselines - Get current user's baseline services (protected)
  • GET /api/baselines/:service - Get current user's baseline for service (protected)
  • POST /api/baselines/:service - Update current user's baseline (protected)

Performance Metrics

  • POST /api/perf - Ingest perf metric (protected)
  • GET /api/perf/timeseries - Get perf timeseries (protected)

Reports

  • POST /api/reports/:service - Create report (protected)
  • GET /api/reports/:service - Get reports for service (protected)

Dashboard

  • GET /api/dashboard/overview/:service - Get service overview (protected)
  • GET /api/dashboard/system-health - Get system health (protected)
  • GET /api/dashboard/latency-chart/:service - Get latency chart data (protected)

πŸ§ͺ Testing

Test Metric Ingestion

curl -X POST http://localhost:5000/api/metrics \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "service": "api-gateway",
    "endpoint": "/users",
    "method": "GET",
    "latency": 45.3,
    "statusCode": 200
  }'

Test Perf Metric Ingestion

curl -X POST http://localhost:5000/api/perf \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "service": "api-gateway",
    "cpuCycles": 1234567890,
    "cacheMisses": 12345,
    "instructions": 9876543210
  }'

πŸ” Security Features

  1. JWT Authentication - Secure token-based authentication
  2. HTTP-Only Cookies - Prevents XSS attacks
  3. Rate Limiting - 20 requests per 15 minutes on auth routes
  4. Helmet.js - Security headers (CSP, HSTS, etc.)
  5. CORS - Configured for development and production
  6. Input Validation - Joi schemas prevent NoSQL injection
  7. Password Hashing - bcrypt with salt rounds

🎨 Frontend Technologies

  • React 19 - Latest React with concurrent features
  • Vite 6.3.5 - Lightning-fast build tool
  • Redux Toolkit - State management
  • React Router v6 - Client-side routing
  • Bootstrap 5 - Responsive UI framework
  • Recharts - Interactive charts
  • Axios - HTTP client
  • React Toastify - Toast notifications

πŸ› οΈ Backend Technologies

  • Node.js - JavaScript runtime
  • Express 4.18 - Web framework
  • MongoDB - NoSQL database
  • Mongoose 7.1 - ODM for MongoDB
  • JWT - JSON Web Tokens
  • Joi - Schema validation
  • Helmet - Security middleware
  • bcryptjs - Password hashing

πŸ“Š Performance Optimizations

Frontend

  • React.memo for expensive components
  • useMemo for derived computations
  • Custom hooks for data fetching
  • Skeleton loading states
  • Code splitting ready
  • Optimized bundle size

Backend

  • Background workers for analysis
  • Indexed MongoDB queries
  • Rate limiting
  • Request size limits (10kb)
  • Connection pooling

πŸ› Known Issues

  1. Bundle size warning (>500KB) - Consider implementing code splitting for production
  2. Worker runs independently - Ensure MongoDB is running before starting worker
  3. Baseline directory must exist - Create baselines/ folder if missing

πŸ”„ Workflow

  1. Metric Collection - Services send metrics via POST /api/metrics
  2. Analysis Worker - Runs every 60s, computes rolling window analysis
  3. Regression Detection - Hybrid z-score + baseline comparison
  4. Report Generation - Aggregates analysis, baselines, regressions, perf data
  5. Dashboard Display - Frontend visualizes data with charts and alerts
  6. Baseline Management - Commit per-user baselines (baselines/<userId>/<service>.json) to Git for version control

πŸ“ Environment Variables

Backend (.env)

NODE_ENV=development|production
PORT=5000
MONGO_URI=mongodb://localhost:27017/perfsight
JWT_SECRET=your_secret_key

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.

πŸ‘¨β€πŸ’» Author

Shubham

πŸ™ Acknowledgments

  • Express.js team for the robust web framework
  • React team for the amazing UI library
  • MongoDB team for the flexible database
  • All open-source contributors

Built with ❀️ for performance monitoring

About

PerfSight - Performance Monitoring Platform - A comprehensive full-stack application for real-time performance monitoring, regression detection, and Git-tracked baseline management.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages