- Overview
- Features
- Architecture
- Tech Stack
- Getting Started
- API Documentation
- System Design
- Performance Analysis
- Screenshots
- Demo
- Contributors
Sentinel is an intelligent alert management system designed for MoveInSync fleet operations. It automatically escalates, de-escalates, and closes alerts based on dynamic, configurable rules, providing real-time visibility through a comprehensive dashboard.
MoveInSync operates multiple fleet-monitoring modules (Safety, Compliance, Feedback) that generate alerts like overspeeding, expiring documents, or poor driver feedback. These alerts currently require manual review, creating operational bottlenecks. Sentinel solves this by:
- Automating alert escalation based on configurable rules
- Auto-closing alerts when conditions are met
- Providing real-time dashboards for monitoring
- Tracking complete alert lifecycle history
- β Unified API for ingesting alerts from multiple sources
- β
Normalized storage format:
{alertId, sourceType, severity, timestamp, status, metadata} - β
State transitions:
OPEN β ESCALATED β AUTO-CLOSED β RESOLVED
- β Configurable DSL-like rule system
- β Dynamic rule evaluation without hardcoding
- β Support for time-window based conditions
- β
Example rules:
- Overspeed: Escalate if 3+ events within 60 minutes
- Compliance: Auto-close when document renewed
- Feedback: Escalate if 2+ negative feedbacks in 24 hours
- β Periodic worker (cron-based) scanning alerts
- β Idempotent operations (safe to re-run)
- β Automatic state transitions based on conditions
- β Audit trail of all auto-closure events
- β Real-time severity and status distribution
- β Top 5 drivers with most alerts
- β Recent alert lifecycle events
- β Auto-closed alerts transparency
- β 7-day trend analysis charts
- β Alert drill-down with full history
- β JWT-based authentication
- β Role-based access control (User, Operator, Admin)
- β Secure password hashing (bcrypt)
- β Protected API routes
- β Caching: In-memory caching for dashboard data (node-cache)
- β Error Handling: Comprehensive error recovery procedures
- β Logging: Winston logger with structured logging
- β Monitoring: System health endpoints and statistics
- β Security: Helmet, CORS, rate limiting
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND (React + Vite) β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β βDashboard β β Alerts β β Rules β β Auth β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β HTTP/REST API
ββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββ
β BACKEND (Node.js + Express) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β API Routes & Controllers β β
β β β’ Auth β’ Alerts β’ Dashboard β’ Rules β β
β ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ β
β β Services Layer β β
β β β’ Rule Engine β’ Background Jobs β β
β β β’ Cache Manager β’ Logger β β
β ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ β
β β Middleware β β
β β β’ Authentication β’ Error Handler β’ Validation β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββ
β MongoDB Database β
β β’ Users Collection β’ Alerts Collection β
β β’ Rules Collection β’ AlertHistory Collection β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - ODM for MongoDB
- JWT - Authentication
- bcryptjs - Password hashing
- node-cron - Background jobs
- Winston - Logging
- node-cache - In-memory caching
- Helmet - Security headers
- express-rate-limit - Rate limiting
- React 19 - UI framework
- Vite - Build tool
- React Router - Routing
- Axios - HTTP client
- Recharts - Data visualization
- Tailwind CSS - Styling
- Lucide React - Icons
- React Hot Toast - Notifications
- date-fns - Date formatting
- Node.js >= 16.x
- MongoDB >= 5.x
- npm or yarngit clone https://github.com/manirht/Sentinel.git
cd Sentinelcd backend
npm install
# Create .env file
cp .env.example .env
# Update .env with your MongoDB URI
# MONGODB_URI=mongodb://localhost:27017/sentinel
# Seed database with sample data
node seed.js
# Start backend server
npm run dev
# Server runs on http://localhost:5000cd frontend
npm install
# Start frontend development server
npm run dev
# Frontend runs on http://localhost:5173Admin User:
Email: admin@sentinel.com
Password: admin123
Operator User:
Email: operator@sentinel.com
Password: operator123
POST /api/auth/register
POST /api/auth/login
GET /api/auth/me
PUT /api/auth/profileGET /api/alerts # Get all alerts with filters
POST /api/alerts # Create new alert
GET /api/alerts/:id # Get single alert
PUT /api/alerts/:id # Update alert
PUT /api/alerts/:id/resolve # Resolve alert
DELETE /api/alerts/:id # Delete alert (Admin only)GET /api/dashboard/overview # Get severity and status counts
GET /api/dashboard/top-offenders # Get top 5 drivers with most alerts
GET /api/dashboard/recent-events # Get recent alert lifecycle events
GET /api/dashboard/auto-closed # Get recently auto-closed alerts
GET /api/dashboard/trends # Get 7-day alert trends
GET /api/dashboard/by-source # Get alerts grouped by source typeGET /api/rules # Get all rules
POST /api/rules # Create rule (Admin only)
GET /api/rules/:id # Get single rule
PUT /api/rules/:id # Update rule (Admin only)
DELETE /api/rules/:id # Delete rule (Admin only)
PATCH /api/rules/:id/toggle # Toggle rule enabled/disabled (Admin only)POST /api/alerts
{
"sourceType": "overspeed",
"severity": "WARNING",
"metadata": {
"driverId": "DRV001",
"driverName": "John Doe",
"vehicleNumber": "MH-01-AB-1234",
"speed": 85,
"speedLimit": 60,
"location": "Highway NH-48"
}
}POST /api/rules
{
"ruleId": "RULE_OVERSPEED_001",
"sourceType": "overspeed",
"name": "Overspeed Escalation Rule",
"description": "Escalate to Critical if 3 overspeed events within 1 hour",
"enabled": true,
"priority": 10,
"conditions": {
"escalate_if_count": 3,
"window_mins": 60,
"auto_close_after_mins": 1440
},
"actions": {
"escalate_to_severity": "CRITICAL",
"notify": true,
"notificationChannels": ["email", "sms"]
}
}- Create Alert: O(log n) - Indexed insertion
- Find Alert by ID: O(log n) - Index lookup
- Filter Alerts: O(log n + k) - Index scan + result set
- Update Alert: O(log n) - Index lookup + update
- Evaluate Single Alert: O(a) where a = alerts in time window
- Batch Processing: O(n Γ a) where n = alerts to process
- Rule Lookup: O(1) - Hash map lookup
- Overview Stats: O(n) - Full collection scan with aggregation
- Top Offenders: O(n log n) - Sort operation
- Trends: O(n) - Time-based aggregation
- Cache Hit: O(1) - In-memory lookup
- Per Alert Document: O(1) - Fixed size
- Alert History: O(h) where h = history entries
- Cache Storage: O(k) where k = cached items
- Rule Storage: O(r) where r = number of rules
// Alert Collection
{ alertId: 1 } // Unique
{ status: 1, timestamp: -1 } // Compound
{ 'metadata.driverId': 1, status: 1 } // Compound
{ sourceType: 1, status: 1, timestamp: -1 } // Compound
{ severity: 1, status: 1 } // Compound
{ expiresAt: 1 } // TTL Index
// User Collection
{ email: 1 } // Unique
// Rule Collection
{ ruleId: 1 } // Unique
{ sourceType: 1, enabled: 1 } // Compound
// AlertHistory Collection
{ alertId: 1, timestamp: -1 } // Compound- Choice: In-memory caching (node-cache)
- Pros: Fast access O(1), No external dependencies
- Cons: Data loss on restart, Not distributed
- Production Alternative: Redis for distributed caching
- Choice: node-cron (in-process)
- Pros: Simple setup, No external dependencies
- Cons: Single instance only
- Production Alternative: Bull queue with Redis
- Choice: In-memory rule storage with DB sync
- Pros: Fast evaluation, Reduced DB calls
- Cons: Rules reload on server restart
- Mitigation: Periodic rule reload (every 5 minutes)
- Choice: MongoDB (NoSQL)
- Pros: Flexible schema, Fast reads, Horizontal scaling
- Cons: No complex joins
- Justification: Alert metadata varies by source type
Demo Scenarios:
-
Rule-based Escalation
- Create 3 overspeed alerts for same driver within 1 hour
- System automatically escalates to CRITICAL
-
Auto-Close
- Post compliance alert
- Update document status to valid
- System auto-closes the alert
-
Dashboard Analytics
- Real-time severity distribution
- Top offenders leaderboard
- 7-day trend visualization
- Global error middleware catches all exceptions
- Meaningful error messages for debugging
- Mongoose validation errors formatted
- JWT errors handled gracefully
- 404 handler for unknown routes
// Winston Logger Configuration
- error.log: Only errors
- combined.log: All logs
- Console: Development mode
- Structured JSON loggingGET /health # Server health check
GET /api/monitoring/stats # Cache & job statistics# Server
PORT=5000
NODE_ENV=production
# Database
MONGODB_URI=mongodb://localhost:27017/sentinel
# JWT
JWT_SECRET=your_secure_secret_key
JWT_EXPIRE=7d
# Jobs
AUTO_CLOSE_JOB_INTERVAL=*/5 * * * *
RULE_EVALUATION_INTERVAL=*/2 * * * *
# Cache
CACHE_TTL=300
# Alerts
ALERT_EXPIRY_DAYS=30# Backend
cd backend
npm run build # If using TypeScript
npm start
# Frontend
cd frontend
npm run build
# Serve dist folder with nginx or similar- Database Indexing: Strategic indexes for common queries
- Caching: Dashboard data cached for 1-5 minutes
- Batch Processing: Alerts processed in batches of 100
- Connection Pooling: MongoDB connection pool (min: 5, max: 10)
- Compression: Response compression middleware
- Rate Limiting: 100 requests per 15 minutes per IP
- Authentication: JWT with httpOnly cookies option
- Password Hashing: bcrypt with salt rounds = 10
- Helmet: Security headers
- CORS: Configured for specific origins
- Rate Limiting: Prevents brute force attacks
- Input Validation: express-validator for all inputs
- SQL Injection: Mongoose parameterized queries
# Backend tests (if implemented)
cd backend
npm test
# Frontend tests (if implemented)
cd frontend
npm testSentinel/
βββ backend/
β βββ config/
β β βββ database.js
β βββ controllers/
β β βββ alertController.js
β β βββ authController.js
β β βββ dashboardController.js
β β βββ ruleController.js
β βββ middleware/
β β βββ auth.js
β β βββ errorHandler.js
β β βββ validator.js
β βββ models/
β β βββ Alert.js
β β βββ AlertHistory.js
β β βββ Rule.js
β β βββ User.js
β βββ routes/
β β βββ alertRoutes.js
β β βββ authRoutes.js
β β βββ dashboardRoutes.js
β β βββ ruleRoutes.js
β βββ services/
β β βββ backgroundJobs.js
β β βββ ruleEngine.js
β βββ utils/
β β βββ cache.js
β β βββ logger.js
β βββ .env
β βββ package.json
β βββ seed.js
β βββ server.js
β
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Layout.jsx
β β β βββ Navbar.jsx
β β β βββ PrivateRoute.jsx
β β βββ context/
β β β βββ AuthContext.jsx
β β βββ pages/
β β β βββ Alerts.jsx
β β β βββ Dashboard.jsx
β β β βββ Login.jsx
β β β βββ Register.jsx
β β β βββ Rules.jsx
β β βββ services/
β β β βββ alertService.js
β β β βββ api.js
β β β βββ authService.js
β β β βββ dashboardService.js
β β β βββ ruleService.js
β β βββ App.jsx
β β βββ index.css
β β βββ main.jsx
β βββ index.html
β βββ package.json
β βββ postcss.config.js
β βββ tailwind.config.js
β βββ vite.config.js
β
βββ README.md
- Name - Mani Rohit
- Email: manirohit221004@gmail.com
- GitHub: @manirht
This project is licensed under the MIT License.
- MoveInSync for the problem statement
- MERN Stack community
- Open source contributors
Built with β€οΈ using MERN Stack





