π Interactive Demo (Recommended): https://secure-access-ui.vercel.app
π Admin Dashboard: https://secure-access-ashy.vercel.app
βοΈ Backend API: https://secure-access-v2ta.onrender.com
SecureAccess is a production-deployed authentication system that goes beyond JWT-based login by integrating real-time behavioral anomaly detection.
Instead of trusting every successful login, the system evaluates user behavior (IP, device, time) using a machine learning microservice and flags suspicious activity instantly.
This project simulates how modern identity systems detect compromised accounts β not just authenticate users.
- Open the interactive demo
- Click any scenario (e.g. 3AM login or Foreign IP)
- Watch the system flag anomalies in real time
- Open the admin dashboard to see logged events
β οΈ First request may take ~30-60s (Render free tier cold start)
- π JWT Authentication (Access + Refresh Tokens)
- π‘οΈ Role-Based Access Control (RBAC)
- π Login Event Tracking & Session Management
- π§ AI-Based Anomaly Detection (Isolation Forest)
- β‘ Non-blocking architecture β ML scoring never delays authentication
- π Admin Dashboard with real-time monitoring
- βοΈ Fully deployed multi-service architecture
ββββββββββββββββ
β Frontend β (React - Vercel)
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββββββ
β Node.js Backend β (Render)
β Auth + Sessions β
ββββββββ¬ββββββββββββ
β
βββββββββΌβββββββββ
β PostgreSQL DB β (Render)
β Users / Events β
βββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββββ
β Python ML Service β (Flask - Render)
β Isolation Forest β
βββββββββββββββββββββ
This architecture ensures authentication remains fast while anomaly detection runs asynchronously β similar to production-grade systems.
- User submits login credentials
- Backend validates and compares hashed password (bcrypt)
- JWT tokens are generated:
- Access Token β 15 min lifetime
- Refresh Token β 7 day lifetime
- Login event is stored in database
- Backend asynchronously sends data to ML service
- ML service evaluates anomaly score
- Suspicious logins are flagged in database
- Session stored β tokens returned
β‘ Note: Anomaly detection is non-blocking to avoid login delays.
| Property | Detail |
|---|---|
| Model | Isolation Forest (Unsupervised) |
| Training Data | Synthetic login behavior data |
| Features | hour_of_day, ip_changed, new_device, login_frequency_today |
Why Isolation Forest?
- No labeled attack data required
- Efficient for anomaly detection
- Works well for behavioral deviations
The model learns normal login behavior patterns and flags deviations without requiring labeled attack data.
Tables: users Β· sessions Β· login_events
Key Design Decisions:
ON DELETE CASCADEβ prevents orphan recordsflaggedcolumn β marks anomalous logins- Session storage β enables refresh token revocation
- π Total users, logins, and flagged events
- π¨ Highlighted suspicious logins
- π§Ύ Active session tracking
- π Admin-only access
| Layer | Technology |
|---|---|
| Backend | Node.js, Express |
| Database | PostgreSQL |
| Auth | JWT, bcrypt |
| ML Service | Python, Flask, scikit-learn |
| Frontend | React |
| Deployment | Render, Vercel |
| Service | Platform |
|---|---|
| Frontend | Vercel |
| Backend + Python Service | Render |
| Database | Render PostgreSQL |
β οΈ Render free tier may sleep after inactivity (30β60s cold start on first request).
- β Authentication flows (valid/invalid credentials)
- β RBAC protection
- β Admin endpoints
- β Anomaly detection scenarios
- β Rapid login attempts
- β Deployment behavior (cold starts, logs)
- Issue: Python 3.14 broke dependencies
- Fix: Pinned to
python-3.11.9
- Issue:
http.requestcomplexity - Fix: Switched to Axios for cleaner integration
- Issue: Flask not exposed correctly
- Fix: Bound to
0.0.0.0with dynamicPORT
- Issue:
/analyzevs/analyseinconsistency - Fix: Standardized endpoint naming
- Issue: Axios not installed
- Fix: Added to
package.json
- Same error message for invalid email/password β prevents user enumeration
- Short-lived access tokens β reduces attack window
- Refresh tokens stored server-side β revocable
- Role-based route protection
- Uses synthetic training data
- Global model (not per-user)
- Basic IP/device detection heuristics
- OAuth (Google login)
- Per-user anomaly models
- Redis for behavioral tracking
- Refresh token rotation
- Real-world dataset integration
Modern authentication systems donβt stop at login β they continuously evaluate user behavior.
This project was built to:
- Understand real-world IAM systems
- Explore security beyond JWT
- Implement behavior-based anomaly detection
- Experience production deployment challenges
Proneil Sengupta β Backend & AI Systems Enthusiast
If you found this interesting, feel free to β the repo!