# mukta01/evnet_sentinel architecture

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

- Interactive diagram: https://gitdiagram.com/mukta01/evnet_sentinel
- Repository: https://github.com/mukta01/evnet_sentinel

## Overview

#### Purpose and Entry Points
EVNet Sentinel is an EV charging-network intrusion-detection research and serving system. It reproduces CICEVSE2024-based static classifiers and adaptive online detection, then exposes results to a Next.js dashboard. Main service entry points are `src/api/main.py` and `backend/app/main.py`; the browser application begins at `frontend/app/page.tsx` and includes `frontend/app/dashboard/page.tsx`.

#### Data Acquisition and Preparation
The restricted CICEVSE2024 dataset is retrieved locally through environment-provided access, kept out of version control, and split between raw and processed stores. Central preparation logic loads and transforms source traffic into model-ready features, providing a leakage-control boundary before training or inference.
- `data/raw/`
- `data/processed/`
- `src/data_prep/load_data.py`
- `src/data_prep/preprocess.py`

#### Offline Model Training
Model implementations are separated by algorithm but share the processed-data contract and serialized-artifact destination. Static multiclass detection includes SVM, random forest, logistic regression, and decision-tree paths; their training products are intended for later API/model-registry consumption.
- `src/models/svm/train_svm.py`
- `src/models/random_forest/train_rf.py`
- `src/models/log_reg/train_logreg.py`
- `saved_models/`

#### Adaptive Streaming Detection
The ARF + ADWIN subsystem is the online-learning branch, designed to process simulated traffic streams and detect concept drift rather than only score a fixed test set. Drift-related output is persisted separately, establishing a boundary between adaptive-state events and standard model predictions.
- `src/models/arfadwin/train_arfadwin.py`
- `src/models/arfadwin/evaluate_arfadwin.py`
- `predictions/arf_adwin_drift_events.json`
- `saved_models/arf_adwin.pkl`

#### Evaluation and Output Contracts
A unified evaluation layer produces comparable metrics for models, while prediction files and serialized models are shared integration artifacts. Existing reports and plots are offline evidence, not runtime dependencies. The system’s central exchange contract is: processed feature data → trained model → prediction/drift output → API/dashboard.
- `src/evaluation/evaluate_model.py`
- `predictions/`
- `evaluation_results/`
- `saved_models/rf_model_multiclass.pkl`

#### Backend Serving Boundary
FastAPI provides the service boundary between Python ML artifacts and clients. The repository contains both a project-level API implementation and a `backend/app` service package with configuration, implying deployment should select and consolidate the authoritative entry point rather than treat both as independent ML pipelines. Docker is the declared deployment runtime; environment files hold deployment and dataset secrets.
- `src/api/main.py`
- `backend/app/main.py`
- `backend/app/config.py`
- `Dockerfile`

#### Dashboard and Client Integration
The frontend is a Next.js/React application with landing, documentation, and dashboard routes. It is the consumer of REST/WebSocket detection results and renders cybersecurity-focused visualizations; it does not own model execution. Dashboard-specific UX is isolated from reusable presentation components.
- `frontend/app/dashboard/page.tsx`
- `frontend/app/page.tsx`
- `frontend/app/layout.tsx`
- `frontend/components/ThreatAccordion.tsx`

#### Infrastructure and External Dependencies
Material runtimes are Python/FastAPI for ML serving and TypeScript/Next.js for the client, containerized via Docker. External dependencies include the access-restricted CICEVSE2024 dataset hosted through a team-provided Google Drive URL, and the browser-to-backend REST/WebSocket channel. Project documentation defines the intended architecture and setup boundary.
- `Dockerfile`
- `requirements.txt`
- `frontend/package.json`
- `docs/ARCHITECTURE.md`

Main entry points: [`src/api/main.py`](https://github.com/mukta01/evnet_sentinel/blob/main/src/api/main.py) (Project API), [`src/models/arfadwin/train_arfadwin.py`](https://github.com/mukta01/evnet_sentinel/blob/main/src/models/arfadwin/train_arfadwin.py) (ARF + ADWIN training), [`frontend/app/dashboard/page.tsx`](https://github.com/mukta01/evnet_sentinel/blob/main/frontend/app/dashboard/page.tsx) (Detection dashboard), [`src/data_prep/load_data.py`](https://github.com/mukta01/evnet_sentinel/blob/main/src/data_prep/load_data.py) (Data loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data Pipeline"]
  node_raw_data[("Restricted raw traffic<br/>dataset")]
  node_preprocessed_data[("Processed features<br/>feature dataset")]
  node_load_data["Data loader<br/>Python module<br/>[load_data.py]"]
  node_preprocess["Preprocessing<br/>Python module<br/>[preprocess.py]"]
end

subgraph group_ml["ML Training &amp; Evaluation"]
  node_static_trainers["Static classifiers<br/>training scripts<br/>[train_svm.py]"]
  node_rf_trainer["Random forest trainer<br/>training script<br/>[train_rf.py]"]
  node_logreg_trainer["Logistic regression trainer<br/>training script<br/>[train_logreg.py]"]
  node_adaptive_training["ARF + ADWIN training<br/>online training<br/>[train_arfadwin.py]"]
  node_adaptive_evaluation["ARF + ADWIN evaluation<br/>online evaluation"]
  node_model_artifacts[("Model registry artifacts<br/>serialized models")]
  node_drift_model["ARF + ADWIN model<br/>serialized model<br/>[arf_adwin.pkl]"]
  node_evaluation["Unified evaluation<br/>evaluation module<br/>[evaluate_model.py]"]
  node_predictions[("Prediction outputs<br/>output store")]
  node_drift_events["Drift events<br/>event output"]
end

subgraph group_serving["Serving"]
  node_fastapi_api{{"Project API<br/>FastAPI entry point<br/>[main.py]"}}
  node_backend_api{{"Backend service package<br/>FastAPI entry point<br/>[main.py]"}}
  node_container["Docker runtime<br/>deployment"]
end

subgraph group_client["Dashboard"]
  node_dashboard["Detection dashboard<br/>Next.js route<br/>[page.tsx]"]
  node_landing["Landing route<br/>Next.js route<br/>[page.tsx]"]
  node_threat_ui["Threat UI component<br/>React component"]
end

node_raw_data -->|"loads"| node_load_data
node_load_data -->|"source traffic"| node_preprocess
node_preprocess -->|"writes features"| node_preprocessed_data
node_preprocessed_data -->|"training features"| node_static_trainers
node_preprocessed_data -->|"training features"| node_rf_trainer
node_preprocessed_data -->|"training features"| node_logreg_trainer
node_preprocessed_data -->|"simulated stream"| node_adaptive_training
node_static_trainers -->|"serializes models"| node_model_artifacts
node_rf_trainer -->|"serializes model"| node_model_artifacts
node_logreg_trainer -->|"serializes model"| node_model_artifacts
node_adaptive_training -->|"serializes adaptive state"| node_drift_model
node_adaptive_training -->|"stream results"| node_adaptive_evaluation
node_adaptive_evaluation -->|"writes drift events"| node_drift_events
node_drift_events -->|"stored in"| node_predictions
node_model_artifacts -->|"evaluates"| node_evaluation
node_evaluation -->|"writes predictions"| node_predictions
node_model_artifacts -->|"loads models"| node_fastapi_api
node_preprocessed_data -->|"inference features"| node_fastapi_api
node_fastapi_api -->|"REST/WebSocket results"| node_dashboard
node_backend_api -.->|"alternative service entry point"| node_fastapi_api
node_landing -->|"navigates to"| node_dashboard
node_threat_ui -->|"renders within"| node_dashboard
node_container -->|"deploys"| node_fastapi_api

click node_load_data "https://github.com/mukta01/evnet_sentinel/blob/main/src/data_prep/load_data.py"
click node_preprocess "https://github.com/mukta01/evnet_sentinel/blob/main/src/data_prep/preprocess.py"
click node_static_trainers "https://github.com/mukta01/evnet_sentinel/blob/main/src/models/svm/train_svm.py"
click node_rf_trainer "https://github.com/mukta01/evnet_sentinel/blob/main/src/models/random_forest/train_rf.py"
click node_logreg_trainer "https://github.com/mukta01/evnet_sentinel/blob/main/src/models/log_reg/train_logreg.py"
click node_adaptive_training "https://github.com/mukta01/evnet_sentinel/blob/main/src/models/arfadwin/train_arfadwin.py"
click node_adaptive_evaluation "https://github.com/mukta01/evnet_sentinel/blob/main/src/models/arfadwin/evaluate_arfadwin.py"
click node_drift_model "https://github.com/mukta01/evnet_sentinel/blob/main/saved_models/arf_adwin.pkl"
click node_evaluation "https://github.com/mukta01/evnet_sentinel/blob/main/src/evaluation/evaluate_model.py"
click node_drift_events "https://github.com/mukta01/evnet_sentinel/blob/main/predictions/arf_adwin_drift_events.json"
click node_fastapi_api "https://github.com/mukta01/evnet_sentinel/blob/main/src/api/main.py"
click node_backend_api "https://github.com/mukta01/evnet_sentinel/blob/main/backend/app/main.py"
click node_dashboard "https://github.com/mukta01/evnet_sentinel/blob/main/frontend/app/dashboard/page.tsx"
click node_landing "https://github.com/mukta01/evnet_sentinel/blob/main/frontend/app/page.tsx"
click node_threat_ui "https://github.com/mukta01/evnet_sentinel/blob/main/frontend/components/ThreatAccordion.tsx"
click node_container "https://github.com/mukta01/evnet_sentinel/blob/main/Dockerfile"

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_raw_data,node_preprocessed_data,node_load_data,node_preprocess toneBlue
class node_static_trainers,node_rf_trainer,node_logreg_trainer,node_adaptive_training,node_adaptive_evaluation,node_model_artifacts,node_drift_model,node_evaluation,node_predictions,node_drift_events toneAmber
class node_fastapi_api,node_backend_api,node_container toneMint
class node_dashboard,node_landing,node_threat_ui toneRose
```

## Components

### Data Pipeline

- **Restricted raw traffic**: dataset · Locally retrieved CICEVSE2024 source data.
- **Processed features**: feature dataset · Leakage-controlled model input contract.
- [Data loader](https://github.com/mukta01/evnet_sentinel/blob/main/src/data_prep/load_data.py): Python module · `src/data_prep/load_data.py`
- [Preprocessing](https://github.com/mukta01/evnet_sentinel/blob/main/src/data_prep/preprocess.py): Python module · `src/data_prep/preprocess.py`

### ML Training & Evaluation

- [Static classifiers](https://github.com/mukta01/evnet_sentinel/blob/main/src/models/svm/train_svm.py): training scripts · SVM, random forest, and logistic-regression training paths. · `src/models/svm/train_svm.py`
- [Random forest trainer](https://github.com/mukta01/evnet_sentinel/blob/main/src/models/random_forest/train_rf.py): training script · `src/models/random_forest/train_rf.py`
- [Logistic regression trainer](https://github.com/mukta01/evnet_sentinel/blob/main/src/models/log_reg/train_logreg.py): training script · `src/models/log_reg/train_logreg.py`
- [ARF + ADWIN training](https://github.com/mukta01/evnet_sentinel/blob/main/src/models/arfadwin/train_arfadwin.py): online training · Processes simulated streams with adaptive state. · `src/models/arfadwin/train_arfadwin.py`
- [ARF + ADWIN evaluation](https://github.com/mukta01/evnet_sentinel/blob/main/src/models/arfadwin/evaluate_arfadwin.py): online evaluation · `src/models/arfadwin/evaluate_arfadwin.py`
- **Model registry artifacts**: serialized models · Shared destination for static and adaptive models.
- [ARF + ADWIN model](https://github.com/mukta01/evnet_sentinel/blob/main/saved_models/arf_adwin.pkl): serialized model · `saved_models/arf_adwin.pkl`
- [Unified evaluation](https://github.com/mukta01/evnet_sentinel/blob/main/src/evaluation/evaluate_model.py): evaluation module · Produces comparable model metrics. · `src/evaluation/evaluate_model.py`
- **Prediction outputs**: output store · Shared prediction and drift-result contract.
- [Drift events](https://github.com/mukta01/evnet_sentinel/blob/main/predictions/arf_adwin_drift_events.json): event output · `predictions/arf_adwin_drift_events.json`

### Serving

- [Project API](https://github.com/mukta01/evnet_sentinel/blob/main/src/api/main.py): FastAPI entry point · Candidate authoritative Python ML service. · `src/api/main.py`
- [Backend service package](https://github.com/mukta01/evnet_sentinel/blob/main/backend/app/main.py): FastAPI entry point · Alternative deployment entry point requiring consolidation. · `backend/app/main.py`
- [Docker runtime](https://github.com/mukta01/evnet_sentinel/blob/main/Dockerfile): deployment · Declared container deployment boundary. · `Dockerfile`

### Dashboard

- [Detection dashboard](https://github.com/mukta01/evnet_sentinel/blob/main/frontend/app/dashboard/page.tsx): Next.js route · Consumes REST/WebSocket detection results. · `frontend/app/dashboard/page.tsx`
- [Landing route](https://github.com/mukta01/evnet_sentinel/blob/main/frontend/app/page.tsx): Next.js route · `frontend/app/page.tsx`
- [Threat UI component](https://github.com/mukta01/evnet_sentinel/blob/main/frontend/components/ThreatAccordion.tsx): React component · `frontend/components/ThreatAccordion.tsx`

## Connections

- Restricted raw traffic → Data loader: loads
- Data loader → Preprocessing: source traffic
- Preprocessing → Processed features: writes features
- Processed features → Static classifiers: training features
- Processed features → Random forest trainer: training features
- Processed features → Logistic regression trainer: training features
- Processed features → ARF + ADWIN training: simulated stream
- Static classifiers → Model registry artifacts: serializes models
- Random forest trainer → Model registry artifacts: serializes model
- Logistic regression trainer → Model registry artifacts: serializes model
- ARF + ADWIN training → ARF + ADWIN model: serializes adaptive state
- ARF + ADWIN training → ARF + ADWIN evaluation: stream results
- ARF + ADWIN evaluation → Drift events: writes drift events
- Drift events → Prediction outputs: stored in
- Model registry artifacts → Unified evaluation: evaluates
- Unified evaluation → Prediction outputs: writes predictions
- Model registry artifacts → Project API: loads models
- Processed features → Project API: inference features
- Project API → Detection dashboard: REST/WebSocket results
- Backend service package → Project API: alternative service entry point
- Landing route → Detection dashboard: navigates to
- Threat UI component → Detection dashboard: renders within
- Docker runtime → Project API: deploys
