# reneilwekeoagile061/cybernova-insight-engine architecture

> Architecture diagram of the GitHub repository reneilwekeoagile061/cybernova-insight-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/reneilwekeoagile061/cybernova-insight-engine
- Repository: https://github.com/reneilwekeoagile061/cybernova-insight-engine

## Overview

#### 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: [`src/App.jsx`](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/App.jsx) (Application shell), [`src/services/api.js`](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/services/api.js) (API service), [`submission_package/app.py`](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/app.py) (Flask REST API), [`src/components/Dashboard.jsx`](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/Dashboard.jsx) (Core dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React/Vite frontend"]
  node_main["React entry<br/>React bootstrap<br/>[main.jsx]"]
  node_app["Application shell<br/>React shell<br/>[App.jsx]"]
  node_auth["Auth context<br/>client session state<br/>[AuthContext.jsx]"]
  node_login["Login<br/>sign-in UI<br/>[Login.jsx]"]
  node_api["API service<br/>Axios client<br/>[api.js]"]
  node_dashboard["Core dashboard<br/>analytics UI<br/>[Dashboard.jsx]"]
  node_regional["Regional dashboard<br/>sales analytics UI"]
  node_campaign["Campaign performance<br/>campaign analytics UI"]
  node_threats["Threat intelligence<br/>security analytics UI"]
  node_workbench["Prediction workbench<br/>prediction UI"]
  node_trends["Trend utilities<br/>presentation logic<br/>[TrendUtils.js]"]
  node_frontend_runtime["Vite/Node runtime<br/>frontend tooling<br/>[package.json]"]
end

subgraph group_backend["Flask API"]
  node_flask{{"Flask REST API<br/>authenticated analytics API<br/>[app.py]"}}
  node_backend_runtime["Python dependencies<br/>backend dependencies<br/>[requirements.txt]"]
end

subgraph group_artifacts["ML &amp; packaged data"]
  node_model[("Random Forest model<br/>persisted model<br/>[rf_model.pkl]")]
  node_scaler[("Feature scaler<br/>model transformer<br/>[scaler.pkl]")]
  node_sample_data[("Sample data<br/>analytics dataset")]
end

node_browser(("Browser client<br/>runtime"))

node_browser -->|"loads SPA"| node_main
node_frontend_runtime -->|"builds and runs"| node_main
node_main -->|"mounts"| node_app
node_app -->|"uses session state"| node_auth
node_app -->|"unauthenticated view"| node_login
node_app -->|"Sales workspace"| node_dashboard
node_app -->|"Sales workspace"| node_regional
node_app -->|"Sales workspace"| node_campaign
node_app -->|"Security workspace"| node_threats
node_app -->|"role-enabled scoring"| node_workbench
node_login -->|"sign-in lifecycle"| node_auth
node_auth -->|"credentialed requests"| node_api
node_dashboard -->|"analytics requests"| node_api
node_regional -->|"demand data"| node_api
node_campaign -->|"campaign data"| node_api
node_threats -->|"security signals"| node_api
node_workbench -->|"prediction requests"| node_api
node_dashboard -->|"shapes trends"| node_trends
node_api -->|"REST with session cookies"| node_flask
node_backend_runtime -->|"provides Flask and ML libraries"| node_flask
node_flask -->|"loads for scoring"| node_model
node_flask -->|"transforms features"| node_scaler
node_flask -->|"serves analytics and demos"| node_sample_data

click node_main "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/main.jsx"
click node_app "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/App.jsx"
click node_auth "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/contexts/AuthContext.jsx"
click node_login "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/Login.jsx"
click node_api "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/services/api.js"
click node_dashboard "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/Dashboard.jsx"
click node_regional "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/RegionalDashboard.jsx"
click node_campaign "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/CampaignPerformance.jsx"
click node_threats "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/ThreatIntelligence.jsx"
click node_workbench "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/PredictionWorkbench.jsx"
click node_trends "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/utils/TrendUtils.js"
click node_flask "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/app.py"
click node_model "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/rf_model.pkl"
click node_scaler "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/scaler.pkl"
click node_sample_data "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/cybernova_sample_data.csv"
click node_frontend_runtime "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/package.json"
click node_backend_runtime "https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/requirements.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_app,node_auth,node_login,node_api,node_dashboard,node_regional,node_campaign,node_threats,node_workbench,node_trends,node_frontend_runtime toneBlue
class node_flask,node_backend_runtime toneAmber
class node_model,node_scaler,node_sample_data toneMint
class node_browser toneNeutral
```

## Components

### React/Vite frontend

- [React entry](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/main.jsx): React bootstrap · `src/main.jsx`
- [Application shell](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/App.jsx): React shell · Selects login or role-appropriate workspace. · `src/App.jsx`
- [Auth context](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/contexts/AuthContext.jsx): client session state · `src/contexts/AuthContext.jsx`
- [Login](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/Login.jsx): sign-in UI · `src/components/Login.jsx`
- [API service](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/services/api.js): Axios client · Centralizes credentialed requests to the configurable API base URL. · `src/services/api.js`
- [Core dashboard](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/Dashboard.jsx): analytics UI · KPIs, trends, evaluation, importance, and opportunities. · `src/components/Dashboard.jsx`
- [Regional dashboard](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/RegionalDashboard.jsx): sales analytics UI · `src/components/RegionalDashboard.jsx`
- [Campaign performance](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/CampaignPerformance.jsx): campaign analytics UI · `src/components/CampaignPerformance.jsx`
- [Threat intelligence](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/ThreatIntelligence.jsx): security analytics UI · `src/components/ThreatIntelligence.jsx`
- [Prediction workbench](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/components/PredictionWorkbench.jsx): prediction UI · `src/components/PredictionWorkbench.jsx`
- [Trend utilities](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/src/utils/TrendUtils.js): presentation logic · `src/utils/TrendUtils.js`
- [Vite/Node runtime](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/package.json): frontend tooling · `package.json`

### Flask API

- [Flask REST API](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/app.py): authenticated analytics API · Enforces session access, serves analytics, simulation, health, and predictions. · `submission_package/app.py`
- [Python dependencies](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/requirements.txt): backend dependencies · `submission_package/requirements.txt`

### ML & packaged data

- [Random Forest model](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/rf_model.pkl): persisted model · `submission_package/rf_model.pkl`
- [Feature scaler](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/scaler.pkl): model transformer · `submission_package/scaler.pkl`
- [Sample data](https://github.com/reneilwekeoagile061/cybernova-insight-engine/blob/main/submission_package/cybernova_sample_data.csv): analytics dataset · `submission_package/cybernova_sample_data.csv`

### Other components

- **Browser client**: runtime

## Connections

- 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
