rapidtriage-browser-backend
v2.1.0
Published
Browser automation backend for RapidTriageME
Readme
🌐 RapidTriage Server
High-performance browser debugging server with Lighthouse integration
📋 Table of Contents
- Overview
- Features
- Prerequisites
- Quick Start
- Installation
- Configuration
- API Endpoints
- Chrome Extension
- Architecture
- Performance
- Security
- Troubleshooting
- Contributing
- Support
- License
🎯 Overview
RapidTriage Server is a powerful Node.js middleware that bridges Chrome extensions with AI-powered debugging tools. It provides real-time browser data collection, screenshot capture, and comprehensive auditing capabilities through Lighthouse integration.
How It Works
┌─────────────────┐ WebSocket ┌──────────────────┐ HTTP/WS ┌─────────────┐
│ Chrome Extension│ ◄────────────────► │ RapidTriage │ ◄────────────► │ MCP Server │
│ (DevTools) │ │ Server │ │ (AI Tools) │
└─────────────────┘ └──────────────────┘ └─────────────┘
↓ ↓ ↓
Collect Data Process & Store AI Analysis✨ Features
Core Capabilities
- 🔄 Real-time Data Streaming - WebSocket-based communication
- 📸 Screenshot Capture - Full-page and viewport screenshots
- 📊 Console Logging - Capture all browser console output
- 🌐 Network Monitoring - Track all HTTP requests and responses
- 🎯 DOM Inspection - Element selection and analysis
Lighthouse Integration
- ⚡ Performance Audits - Core Web Vitals, speed metrics
- ♿ Accessibility Testing - WCAG 2.1 compliance checks
- 🔍 SEO Analysis - Meta tags, structured data validation
- ✅ Best Practices - Security headers, HTTPS, modern standards
- 📱 PWA Audits - Progressive Web App compliance
Advanced Features
- 🔒 Token Authentication - Secure client connections
- 📈 Rate Limiting - Prevent abuse and overload
- 🔄 Auto-reconnection - Resilient connection handling
- 📝 Request Logging - Comprehensive debugging logs
- 🚀 High Performance - Optimized for low latency
📋 Prerequisites
- Node.js 18.0.0 or higher
- npm or yarn package manager
- Chrome/Chromium browser (for Lighthouse audits)
- RapidTriage Chrome Extension installed
🚀 Quick Start
# Start the server with npx (no installation needed)
npx @yarlisai/rapidtriage-server@latest
# Server will start on port 3025
# 🚀 RapidTriage Server running on http://localhost:3025Verify Installation
# Check server health
curl http://localhost:3025/health
# Response:
# {"status":"ok","version":"1.0.0","uptime":123}📦 Installation
Using npx (Recommended)
# Run without installation
npx @yarlisai/rapidtriage-server@latest
# Run with custom port
PORT=3000 npx @yarlisai/rapidtriage-server@latestGlobal Installation
# Install globally
npm install -g @yarlisai/rapidtriage-server
# Run from anywhere
rapidtriage-serverLocal Development
# Clone the repository
git clone https://github.com/YarlisAISolutions/rapidtriageME.git
cd rapidtriageME/rapidtriage-server
# Install dependencies
npm install
# Build the project
npm run build
# Start the server
npm startDocker Installation
FROM node:18-alpine
RUN npm install -g @yarlisai/rapidtriage-server
EXPOSE 3025
CMD ["rapidtriage-server"]# Build and run
docker build -t rapidtriage-server .
docker run -p 3025:3025 rapidtriage-server⚙️ Configuration
Environment Variables
# Server Configuration
PORT=3025 # Server port (default: 3025)
HOST=0.0.0.0 # Server host (default: localhost)
NODE_ENV=production # Environment (development/production)
# Security
AUTH_TOKEN=your-secret-token # Authentication token for clients
CORS_ORIGIN=http://localhost:3000 # Allowed CORS origins
# Performance
MAX_PAYLOAD_SIZE=50mb # Maximum request payload size
TIMEOUT=30000 # Request timeout in milliseconds
RATE_LIMIT=100 # Requests per minute per IP
# Lighthouse Configuration
CHROME_PATH=/path/to/chrome # Custom Chrome executable path
LIGHTHOUSE_PORT=9222 # Chrome debugging port
# Logging
LOG_LEVEL=info # Log level (error/warn/info/debug)
LOG_FILE=/var/log/rapidtriage.log # Log file pathConfiguration File
Create a .rapidtriagerc file:
{
"server": {
"port": 3025,
"host": "localhost",
"cors": {
"origin": "*",
"credentials": true
}
},
"security": {
"authToken": "your-secret-token",
"rateLimit": {
"windowMs": 60000,
"max": 100
}
},
"lighthouse": {
"chromePath": null,
"port": 9222,
"logLevel": "error"
},
"logging": {
"level": "info",
"file": "./logs/server.log"
}
}🔌 API Endpoints
Health Check
GET /healthResponse:
{
"status": "ok",
"version": "1.0.0",
"uptime": 3600,
"connections": 2
}WebSocket Connection
const ws = new WebSocket('ws://localhost:3025');
ws.on('open', () => {
ws.send(JSON.stringify({
type: 'auth',
token: 'your-auth-token'
}));
});
ws.on('message', (data) => {
const message = JSON.parse(data);
console.log('Received:', message);
});REST API
Get Console Logs
GET /api/console
Authorization: Bearer your-tokenGet Network Logs
GET /api/network
Authorization: Bearer your-tokenCapture Screenshot
POST /api/screenshot
Authorization: Bearer your-token
Content-Type: application/json
{
"fullPage": true,
"quality": 90
}Run Lighthouse Audit
POST /api/audit
Authorization: Bearer your-token
Content-Type: application/json
{
"url": "https://example.com",
"categories": ["performance", "accessibility", "seo"]
}🧩 Chrome Extension
The RapidTriage Chrome Extension is required for browser data collection.
Installation
Download the extension:
wget https://github.com/YarlisAISolutions/rapidtriage-extension/releases/latest/download/rapidtriage-extension.zipExtract and load in Chrome:
- Navigate to
chrome://extensions/ - Enable "Developer mode"
- Click "Load unpacked"
- Select the extracted folder
- Navigate to
Open Chrome DevTools (F12)
Navigate to the "RapidTriage" panel
The extension will auto-connect to the server
Extension Features
- Auto-connect - Automatically connects to local server
- Data Collection - Captures console, network, and DOM data
- Screenshot Tool - Built-in screenshot capture
- Element Inspector - Select and inspect DOM elements
- Export Data - Export collected data as JSON/HAR
🏗️ Architecture
Component Overview
┌─────────────────────────────────────────────────┐
│ RapidTriage Server │
├─────────────────────────────────────────────────┤
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Express │ │ WebSocket│ │Lighthouse│ │
│ │ Server │ │ Server │ │ Runner │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ CORS │ │ Auth │ │ Rate │ │
│ │Middleware│ │Middleware│ │ Limiter │ │
│ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────┘Data Flow
- Chrome Extension collects browser data
- WebSocket transmits data to server
- Server processes and stores data
- MCP Server queries data via HTTP API
- AI Assistant analyzes and provides insights
⚡ Performance
Benchmarks
| Metric | Value | Notes | |--------|-------|-------| | Startup Time | < 2s | Cold start | | Memory Usage | ~50MB | Idle state | | Request Latency | < 10ms | Local network | | WebSocket Throughput | 10K msg/s | Per connection | | Concurrent Connections | 1000+ | With 4GB RAM |
Optimization Tips
- Use connection pooling for database connections
- Enable gzip compression for large payloads
- Implement caching for frequently accessed data
- Use PM2 for production deployment
- Configure nginx as reverse proxy
🔒 Security
Best Practices
- ✅ Token Authentication - Always use auth tokens in production
- ✅ HTTPS Only - Use TLS certificates for production
- ✅ Rate Limiting - Prevent abuse and DDoS attacks
- ✅ CORS Configuration - Restrict origins in production
- ✅ Input Validation - Sanitize all user inputs
- ✅ Security Headers - Implement CSP, HSTS, etc.
Production Setup
# nginx.conf
server {
listen 443 ssl http2;
server_name api.rapidtriage.me;
ssl_certificate /etc/ssl/certs/rapidtriage.crt;
ssl_certificate_key /etc/ssl/private/rapidtriage.key;
location / {
proxy_pass http://localhost:3025;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}🔍 Troubleshooting
Common Issues
Port Already in Use
# Find process using port 3025
lsof -i :3025
# Kill the process
kill -9 <PID>
# Or use a different port
PORT=3000 npx @yarlisai/rapidtriage-server@latestChrome Not Found
# Install Chrome
# macOS
brew install --cask google-chrome
# Ubuntu/Debian
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
apt-get update
apt-get install google-chrome-stable
# Set Chrome path
export CHROME_PATH="/usr/bin/google-chrome"WebSocket Connection Failed
- Check firewall settings
- Verify CORS configuration
- Ensure server is running
- Check browser console for errors
Debug Mode
# Enable debug logging
DEBUG=* npx @yarlisai/rapidtriage-server@latest
# Or set log level
LOG_LEVEL=debug npx @yarlisai/rapidtriage-server@latestLogs Location
- macOS/Linux:
~/.rapidtriage/logs/ - Windows:
%APPDATA%\rapidtriage\logs\ - Docker:
/var/log/rapidtriage/
🤝 Contributing
We welcome contributions! Please see our Contributing Guide.
Development Workflow
# Fork and clone the repo
git clone https://github.com/YOUR_USERNAME/rapidtriageME.git
cd rapidtriageME/rapidtriage-server
# Create a feature branch
git checkout -b feature/amazing-feature
# Install dependencies
npm install
# Make your changes
# ...
# Run tests
npm test
# Build
npm run build
# Submit a pull requestCode Style
- Use TypeScript for all new code
- Follow ESLint configuration
- Write tests for new features
- Update documentation
💬 Support
- 📧 Email: [email protected]
- 💬 Discord: Join our community
- 🐛 Issues: GitHub Issues
- 📖 Docs: rapidtriage.me/docs
- 🎥 YouTube: Video Tutorials
📄 License
MIT © YarlisAISolutions
