A comprehensive full-stack machine learning application for real estate price prediction and analysis. This application combines modern web technologies with powerful ML capabilities to provide intelligent insights into property markets.
Core Functionality
- π Interactive ML Dashboard with 7 chart types (bar, scatter, pie, line, radar, composed, radial)
- π― Property Price Predictions with 4 ML models and uncertainty quantification
- π Advanced Visualizations (zoom, brush, gradients, synchronized charts)
- π Drag-and-drop data upload with validation
- β‘ Real-time updates and live predictions
Security & Infrastructure
- π JWT Authentication (512-bit entropy) + API key support
- π‘οΈ Sandboxed Python execution with resource limits
- π¨ Security scoring system (95/100) with startup validation
- ποΈ MongoDB with auto-reconnection and health monitoring
- π Real-time security event logging and performance metrics
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β React App β β Express API β β File System β
β (Port 3000) βββββΊβ (Port 5000) βββββΊβ CSV/JSON Data β
β β β β β β
β β’ TypeScript β β β’ REST APIs β β β’ Property Data β
β β’ Modern CSS β β β’ ML Services β β β’ ML Models β
β β’ Recharts β β β’ Security Layerβ β β’ Datasets β
β β’ Health UI β β β’ Health Monitorβ β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
βπ Secure Python β βββββββββββββββββββ
β Environment βββββΊβπ MongoDB Atlas β
β β’ scikit-learn β β β’ Auto-Reconnectβ
β β’ Sandboxed β β β’ Health Checks β
β β’ Resource Limitβ β β’ Performance β
βββββββββββββββββββ βββββββββββββββββββ
Frontend: React 19, TypeScript, Recharts, Modern CSS (glassmorphism), React Router, Axios
Backend: Node.js, Express.js, MongoDB, JWT, Multer, CORS, Security Middleware
Machine Learning: Python, scikit-learn, pandas, numpy (Random Forest, Linear Regression, Neural Networks, Gradient Boosting)
- Node.js (v16 or higher)
- Python (v3.8 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn
git clone https://github.com/EPW80/ml-insights-hub.git
cd ml-insights-hub# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install Python dependencies
pip install -r server/requirements.txtcd server
# Install Node.js dependencies
npm install
# π IMPORTANT: Generate secure JWT secret
npm run generate-jwt-secret
# β
Verify security configuration
npm run security:audit
# π§ͺ Test secure Python bridge
npm run security:test-python
# ποΈ Test database connection
npm run db:test
# π Monitor database health
npm run db:healthcd ../client
# Install Node.js dependencies
npm install# From project root
./start.sh# Terminal 1: Start Frontend
cd client
npm start
# Terminal 2: Start Backend
cd server
npm start
# Make sure Python virtual environment is activated
source venv/bin/activateThe application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
Configure your MongoDB connection:
# Copy environment template
cp server/.env.example server/.env
# Edit .env file with your MongoDB URI
MONGODB_URI=mongodb://localhost:27017/ml-insights-hub
# Test database connection
cd server
npm run db:testBefore running the application, you must configure a secure JWT secret:
# Generate secure JWT secret
cd server
npm run generate-jwt-secret --update-env
# Verify security configuration
npm run security-audit- π Automatic security validation on server startup
- π‘οΈ Rate limiting for API endpoints
- π JWT authentication with secure secret generation
- π Input validation and sanitization
- π« CORS protection with configurable origins
- β‘ Security headers via Helmet.js
# Security commands
npm run check-security # Check JWT secret strength
npm run security:audit # Full security audit
npm run security:test-python # Test secure Python execution
npm run preproduction # Pre-production security check
# Database commands
npm run db:test # Test database connection
npm run db:health # Monitor database health (15-second test)
npm run db:stats # Display database statisticsThe application provides real-time health monitoring:
# Database health status
GET /api/health/database
# Detailed database statistics
GET /api/health/database/stats
# Database performance metrics
GET /api/health/database/performance
# Force database reconnection (admin)
POST /api/health/database/reconnectFor detailed security information, check the built-in security audit: npm run security:audit
cd server
npm run dev
source venv/bin/activate
## π Project Structure
ml-insights-hub/ βββ client/ # React Frontend (TypeScript) β βββ src/ β β βββ components/ # UI Components (Charts, Forms, Dashboard) β β βββ services/ # API & Data Services β β βββ hooks/ # Custom React Hooks β βββ public/ # Static Assets β βββ server/ # Node.js Backend β βββ routes/ # API Routes & Endpoints β βββ middleware/ # Security & Validation (JWT, Rate Limiting) β βββ ml-services/ # ML Algorithm Services β βββ python-scripts/ # Sandboxed Python ML Execution β βββ scripts/ # Automation & Testing Tools β βββ uploads/ # File Upload Directory β βββ venv/ # Python Virtual Environment
### Key Features by Component
**Frontend** (`/client/src/components/`)
- π Interactive Charts: 7 chart types with zoom, brush, gradients
- π― ML Predictions: Multi-model support with uncertainty quantification
- π Data Upload: Drag-and-drop with validation
- π« Advanced Visualizations: Radar, composed, radial, area charts
**Backend** (`/server/`)
- π€ ML Services: Random Forest, Linear Regression, Neural Networks, Gradient Boosting
- π‘οΈ Security: JWT auth, rate limiting, input sanitization, sandboxed Python
- π Health Monitoring: Real-time database & system health checks
- π§ API Endpoints: Predictions, data management, model training
```bash
npm run check-security
- β JWT secret is 256+ bits (64+ hex characters)
- β Rate limiting is enabled
- β Input validation is active
- β MongoDB injection protection enabled
- β Security headers configured
- β HTTPS enabled in production
Create a .env file in the server/ directory:
# Server Configuration
PORT=5000
NODE_ENV=development
# Database
MONGODB_URI=mongodb://localhost:27017/ml-insights-hub
# JWT Authentication (CRITICAL - Generate secure secret!)
# Use: npm run generate-jwt-secret
JWT_SECRET=GENERATE_SECURE_SECRET_FOR_PRODUCTION_USE_CRYPTO_RANDOM_BYTES_64_HEX
JWT_EXPIRE=7d
# Python
PYTHON_PATH=../venv/bin/python
# File Upload
UPLOAD_PATH=./uploads
MAX_FILE_SIZE=10485760 # 10MB- Random Forest - Ensemble method for robust predictions
- Linear Regression - Simple linear relationship modeling
- Neural Network - Deep learning for complex patterns
- Gradient Boosting - Advanced ensemble technique
- Bootstrap Sampling - Statistical confidence intervals
- Bayesian Approaches - Probabilistic uncertainty estimation
- Ensemble Variance - Model agreement analysis
POST /api/ml/predict- Make property price predictions{ "bedrooms": 3, "bathrooms": 2, "sqft": 2000, "year_built": 2010, "lot_size": 8000, "school_rating": 8, "crime_rate": 2.5, "walkability_score": 75 }
POST /api/data/upload- Upload property dataset filesGET /api/data/properties- Retrieve property data for visualizationPOST /api/data/validate- Validate uploaded data format
GET /api/health/database- Database health statusGET /api/health/database/stats- Database connection statisticsGET /api/health/database/performance- Database performance metricsPOST /api/health/database/reconnect- Force database reconnection
π Dashboard: Real-time analytics, 7 chart types, prediction metrics, model performance
π― Predictions: Multi-model selection, property inputs, uncertainty quantification, instant results
π Visualizations: Price distribution, correlation charts, property breakdowns, trend analysis
π Data Upload: Drag-and-drop, CSV/JSON/Excel support, real-time validation
cd client
npm testcd server
# Test all functionality
npm test
# Test specific components
npm run security:test-python # Test secure Python execution
npm run db:test # Test database connection
npm run db:health # Test database health monitoring
npm run security:audit # Test security configurationsource venv/bin/activate
python -c "import pandas, numpy, sklearn; print('All ML packages installed successfully!')"# Build frontend for production
cd client
npm run build
# The build folder will contain optimized production filesBefore deploying to production, ensure:
-
Security Configuration:
npm run security:audit # Should score 95/100 or higher npm run preproduction # Run pre-production checks
-
Database Configuration:
npm run db:test # Verify database connection npm run db:health # Confirm health monitoring
-
Environment Setup:
- Set
NODE_ENV=production - Configure secure JWT secret
- Set up MongoDB connection (local or Atlas)
- Configure HTTPS
- Set appropriate file upload limits
- Set
-
Monitoring Setup:
- Health endpoints:
/api/health/database - Error logging and monitoring
- Performance metrics collection
- Health endpoints:
π Security: 95/100 score, sandboxed Python, JWT (512-bit), input validation, real-time monitoring
ποΈ Database: Auto-reconnect (5sβ80s), 30s health checks, connection pool (2-10), graceful shutdown
π Monitoring: /api/health/* endpoints, performance metrics, admin tools
π οΈ Commands: npm run db:test, npm run db:health, npm run security:audit, npm run security:test-python
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the ISC License.
- Erik Williams - Project Creator - @EPW80
- React team for the excellent frontend framework
- scikit-learn team for powerful ML capabilities
- Recharts team for beautiful data visualization
- Open-source community for inspiration and tools
For support and questions:
- π§ Email: erikpw009@gmail.com
- π Issues: GitHub Issues
- π Documentation: Project Wiki
Empowering data-driven property decisions with Machine Learning
π Enterprise Security | ποΈ Robust Database | π Health Monitoring
Production-ready with 95/100 security score and bulletproof infrastructure