# karthik-valmiki/ml_project architecture

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

- Interactive diagram: https://gitdiagram.com/karthik-valmiki/ml_project
- Repository: https://github.com/karthik-valmiki/ml_project

## Overview

Pyanm is a network-flow and bot-intrusion detection platform. The user-facing workflow selects a holdout traffic scenario, submits its features for inference, and displays the classification, probabilities, and latency. The API also supports batch inference, health/navigation information, and dataset and model-review reports. The README describes the offline lifecycle from UNSW-NB15 preprocessing through validation and model selection; those notebook stages are documented capabilities, while their internal implementation was not sampled.

Main entry points: [`app/services/model_service.py`](https://github.com/karthik-valmiki/ml_project/blob/main/app/services/model_service.py) (Model service), [`app/api/predict.py`](https://github.com/karthik-valmiki/ml_project/blob/main/app/api/predict.py) (Prediction endpoints), [`app/main.py`](https://github.com/karthik-valmiki/ml_project/blob/main/app/main.py) (FastAPI application), [`frontend/js/app.js`](https://github.com/karthik-valmiki/ml_project/blob/main/frontend/js/app.js) (Dashboard interactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_frontend["Web dashboard<br/>[index.html]"]
  node_frontend_logic["Dashboard interactions<br/>[app.js]"]
end

subgraph group_api["API"]
  node_app["FastAPI application<br/>[main.py]"]
  node_system_api["System endpoints<br/>[system.py]"]
  node_reports_api["Review reports<br/>[reports.py]"]
  node_predict_api["Prediction endpoints<br/>[predict.py]"]
  node_prediction_schema["Prediction schemas<br/>[prediction.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_inference["Inference"]
  node_model_service["Model service<br/>[model_service.py]"]
end

subgraph group_artifacts["Data and Models"]
  node_model_artifacts["Trained models and scenarios"]
  node_cleaned_data["Cleaned data and summaries"]
end

subgraph group_lifecycle["ML Lifecycle"]
  node_preprocessing["Data engineering<br/>[EDA.ipynb]"]
  node_validation["Baseline validation"]
  node_advanced_models["PCA and ensembles"]
end

node_user(("Dashboard user"))

node_user -->|"uses"| node_frontend
node_frontend -->|"loads"| node_frontend_logic
node_frontend_logic -->|"submits flow"| node_predict_api
node_frontend_logic -->|"fetches scenarios"| node_predict_api
node_frontend_logic -->|"renders results"| node_frontend
node_app -->|"registers router"| node_system_api
node_app -->|"registers router"| node_reports_api
node_app -->|"registers router"| node_predict_api
node_app -->|"serves dashboard"| node_frontend
node_predict_api -->|"validates requests"| node_prediction_schema
node_predict_api -->|"requests inference"| node_model_service
node_reports_api -->|"reads summaries"| node_model_service
node_reports_api -->|"reads overview metadata"| node_cleaned_data
node_system_api -->|"reports model status"| node_model_service
node_system_api -->|"reads application settings"| node_config
node_model_service -->|"gets artifact directories"| node_config
node_model_service -->|"loads models and scenarios"| node_model_artifacts
node_model_service -->|"loads review summaries"| node_cleaned_data
node_preprocessing -->|"exports standardized features"| node_cleaned_data
node_validation -->|"reports baseline metrics"| node_cleaned_data
node_advanced_models -->|"produces champion model"| node_model_artifacts

click node_frontend "https://github.com/karthik-valmiki/ml_project/blob/main/frontend/index.html"
click node_frontend_logic "https://github.com/karthik-valmiki/ml_project/blob/main/frontend/js/app.js"
click node_app "https://github.com/karthik-valmiki/ml_project/blob/main/app/main.py"
click node_system_api "https://github.com/karthik-valmiki/ml_project/blob/main/app/api/system.py"
click node_reports_api "https://github.com/karthik-valmiki/ml_project/blob/main/app/api/reports.py"
click node_predict_api "https://github.com/karthik-valmiki/ml_project/blob/main/app/api/predict.py"
click node_prediction_schema "https://github.com/karthik-valmiki/ml_project/blob/main/app/schemas/prediction.py"
click node_config "https://github.com/karthik-valmiki/ml_project/blob/main/app/core/config.py"
click node_model_service "https://github.com/karthik-valmiki/ml_project/blob/main/app/services/model_service.py"
click node_model_artifacts "https://github.com/karthik-valmiki/ml_project/tree/main/models"
click node_cleaned_data "https://github.com/karthik-valmiki/ml_project/tree/main/Cleaned_DS"
click node_preprocessing "https://github.com/karthik-valmiki/ml_project/blob/main/EDA.ipynb"
click node_validation "https://github.com/karthik-valmiki/ml_project/blob/main/Model_Validation.ipynb"
click node_advanced_models "https://github.com/karthik-valmiki/ml_project/blob/main/Dimentionality_Reduction.ipynb"

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_frontend,node_frontend_logic,node_user toneBlue
class node_app,node_system_api,node_reports_api,node_predict_api,node_prediction_schema,node_config toneAmber
class node_model_service toneMint
class node_model_artifacts,node_cleaned_data toneRose
class node_preprocessing,node_validation,node_advanced_models toneIndigo
```

## Components

### Dashboard

- [Web dashboard](https://github.com/karthik-valmiki/ml_project/blob/main/frontend/index.html): `frontend/index.html`
- [Dashboard interactions](https://github.com/karthik-valmiki/ml_project/blob/main/frontend/js/app.js): `frontend/js/app.js`

### API

- [FastAPI application](https://github.com/karthik-valmiki/ml_project/blob/main/app/main.py): `app/main.py`
- [System endpoints](https://github.com/karthik-valmiki/ml_project/blob/main/app/api/system.py): `app/api/system.py`
- [Review reports](https://github.com/karthik-valmiki/ml_project/blob/main/app/api/reports.py): `app/api/reports.py`
- [Prediction endpoints](https://github.com/karthik-valmiki/ml_project/blob/main/app/api/predict.py): `app/api/predict.py`
- [Prediction schemas](https://github.com/karthik-valmiki/ml_project/blob/main/app/schemas/prediction.py): `app/schemas/prediction.py`
- [Runtime settings](https://github.com/karthik-valmiki/ml_project/blob/main/app/core/config.py): `app/core/config.py`

### Inference

- [Model service](https://github.com/karthik-valmiki/ml_project/blob/main/app/services/model_service.py): `app/services/model_service.py`

### Data and Models

- [Trained models and scenarios](https://github.com/karthik-valmiki/ml_project/tree/main/models): `models`
- [Cleaned data and summaries](https://github.com/karthik-valmiki/ml_project/tree/main/Cleaned_DS): `Cleaned_DS`

### ML Lifecycle

- [Data engineering](https://github.com/karthik-valmiki/ml_project/blob/main/EDA.ipynb): `EDA.ipynb`
- [Baseline validation](https://github.com/karthik-valmiki/ml_project/blob/main/Model_Validation.ipynb): `Model_Validation.ipynb`
- [PCA and ensembles](https://github.com/karthik-valmiki/ml_project/blob/main/Dimentionality_Reduction.ipynb): `Dimentionality_Reduction.ipynb`

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Web dashboard: uses (evidence: `README.md`)
- Web dashboard → Dashboard interactions: loads
- Dashboard interactions → Prediction endpoints: submits flow (evidence: `frontend/js/app.js`)
- Dashboard interactions → Prediction endpoints: fetches scenarios (evidence: `frontend/js/app.js`)
- Dashboard interactions → Web dashboard: renders results (evidence: `frontend/js/app.js`)
- FastAPI application → System endpoints: registers router (evidence: `app/main.py`)
- FastAPI application → Review reports: registers router (evidence: `app/main.py`)
- FastAPI application → Prediction endpoints: registers router (evidence: `app/main.py`)
- FastAPI application → Web dashboard: serves dashboard (evidence: `app/main.py`)
- Prediction endpoints → Prediction schemas: validates requests (evidence: `app/api/predict.py`)
- Prediction endpoints → Model service: requests inference (evidence: `app/api/predict.py`)
- Review reports → Model service: reads summaries (evidence: `app/api/reports.py`)
- Review reports → Cleaned data and summaries: reads overview metadata (evidence: `app/api/reports.py`)
- System endpoints → Model service: reports model status (evidence: `app/api/system.py`)
- System endpoints → Runtime settings: reads application settings (evidence: `app/api/system.py`)
- Model service → Runtime settings: gets artifact directories (evidence: `app/services/model_service.py`)
- Model service → Trained models and scenarios: loads models and scenarios (evidence: `app/services/model_service.py`)
- Model service → Cleaned data and summaries: loads review summaries (evidence: `app/services/model_service.py`)
- Data engineering → Cleaned data and summaries: exports standardized features (evidence: `README.md`)
- Baseline validation → Cleaned data and summaries: reports baseline metrics (evidence: `README.md`)
- PCA and ensembles → Trained models and scenarios: produces champion model (evidence: `README.md`)
