How reneilwekeoagile061/cybernova-insight-engine works
Purpose and Runtime Topology
CyberNova is a local full-stack analytics dashboard for Southern Africa sales and cybersecurity intelligence. A React/Vite single-page application consumes a Flask REST API; the API serves authenticated analytics and Random Forest predictions backed by packaged model artifacts and sample data. Primary runtime entry points are src/main.jsx (browser UI) and submission_package/app.py (Flask server).
Frontend Composition and Routing
src/App.jsx is the application shell: it selects login versus authenticated workspace and exposes role-appropriate modules. src/main.jsx mounts the React tree, while src/styles.css provides shared presentation. This is a client-side dashboard rather than a separate web-server-rendered application.
Authentication and Access Boundary
src/contexts/AuthContext.jsx owns client authentication state and session lifecycle. src/components/Login.jsx initiates sign-in against Flask, which establishes session cookies. API calls use credentials, and protected dashboard endpoints reject unauthenticated clients with HTTP 401. Roles—Sales and Security—govern which tabs and intelligence views are available.
API Integration Layer
src/services/api.js centralizes Axios-based communication with the configurable /api base URL and session-cookie behavior. This is the frontend/backend boundary: components request health, analytics, simulation, and prediction data through this service rather than directly loading model files or CSV data. The Flask API implementation is submission_package/app.py.
Analytics Dashboard Modules
The authenticated UI is decomposed by decision domain:
• Core KPIs, trends, model evaluation, feature importance, and prioritized opportunities: src/components/Dashboard.jsx.
• Sales regional demand and opportunity analysis: src/components/RegionalDashboard.jsx.
• Campaign tracking and performance measures: src/components/CampaignPerformance.jsx.
• Threat-oriented analytics and security signals: src/components/ThreatIntelligence.jsx.
• Model input and scoring interface for both roles: src/components/PredictionWorkbench.jsx.
Trend shaping or presentation logic is isolated in src/utils/TrendUtils.js, keeping dashboard components focused on orchestration and rendering.
ML and Data Serving Pipeline
The backend loads and applies the persisted Random Forest model in submission_package/rf_model.pkl, with feature transformation from submission_package/scaler.pkl. It uses submission_package/cybernova_sample_data.csv as packaged source data for analytics and demo behavior. Flask therefore forms the trust and compute boundary: the browser receives REST responses and prediction outputs, never direct model execution.
Operations and External Dependencies
Frontend execution is Vite/Node-based (package.json, vite.config.js); backend dependencies are defined in submission_package/requirements.txt for Python/Flask and ML/data libraries. The API supports health/status reporting, response caching, and optional simulated/live-streaming behavior. Deployment configuration centers on VITE_API_BASE_URL in .env.example; Flask session signing, demo-password overrides, and cache TTL are backend environment-controlled.
Main entry points: App.jsx Application shell · api.js API service · app.py Flask REST API · Dashboard.jsx Core dashboard
Components 18
React/Vite frontend
- React entry
src/main.jsx - Application shell · Selects login or role-appropriate workspace.
src/App.jsx - Auth context
src/contexts/AuthContext.jsx - Login
src/components/Login.jsx - API service · Centralizes credentialed requests to the configurable API base URL.
src/services/api.js - Core dashboard · KPIs, trends, evaluation, importance, and opportunities.
src/components/Dashboard.jsx - Regional dashboard
src/components/RegionalDashboard.jsx - Campaign performance
src/components/CampaignPerformance.jsx - Threat intelligence
src/components/ThreatIntelligence.jsx - Prediction workbench
src/components/PredictionWorkbench.jsx - Trend utilities
src/utils/TrendUtils.js - Vite/Node runtime
package.json
Flask API
- Flask REST API · Enforces session access, serves analytics, simulation, health, and predictions.
submission_package/app.py - Python dependencies
submission_package/requirements.txt
ML & packaged data
- Random Forest model
submission_package/rf_model.pkl - Feature scaler
submission_package/scaler.pkl - Sample data
submission_package/cybernova_sample_data.csv
Other components
- Browser client
Connections 23
- Browser client → React entry: loads SPA
- Vite/Node runtime → React entry: builds and runs
- React entry → Application shell: mounts
- Application shell → Auth context: uses session state
- Application shell → Login: unauthenticated view
- Application shell → Core dashboard: Sales workspace
- Application shell → Regional dashboard: Sales workspace
- Application shell → Campaign performance: Sales workspace
- Application shell → Threat intelligence: Security workspace
- Application shell → Prediction workbench: role-enabled scoring
- Login → Auth context: sign-in lifecycle
- Auth context → API service: credentialed requests
- Core dashboard → API service: analytics requests
- Regional dashboard → API service: demand data
- Campaign performance → API service: campaign data
- Threat intelligence → API service: security signals
- Prediction workbench → API service: prediction requests
- Core dashboard → Trend utilities: shapes trends
- API service → Flask REST API: REST with session cookies
- Python dependencies → Flask REST API: provides Flask and ML libraries
- Flask REST API → Random Forest model: loads for scoring
- Flask REST API → Feature scaler: transforms features
- Flask REST API → Sample data: serves analytics and demos