Skip to content

priyank5548/chakravyuh_ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βš”οΈ CHAKRAVYUH-AI

Border Defence & Surveillance Intelligence Dashboard

Version Status License Domain


React Python Flask YOLOv8 scikit-learn PyTorch PQC

A full-stack AI/ML surveillance intelligence system that simulates a multi-sensor border defence network using real cybersecurity datasets, trained machine learning models, and a Post-Quantum Cryptography signing layer.


πŸš€ Why This Matters

  • Simulates real-world border intelligence systems
  • Combines AI + Cybersecurity + Post-Quantum Cryptography
  • Demonstrates multi-layer threat detection pipeline
  • Shows how ML outputs can be secured against tampering

πŸ“Œ Table of Contents


🧠 Key Highlights

  • 3 ML models integrated in a real-time pipeline
  • 8 REST API endpoints powering full-stack system
  • 8,200+ dataset rows processed and merged
  • Post-quantum signature chain with key rotation
  • Full-stack architecture (React + Flask + ML pipeline)

πŸ”­ Overview

CHAKRAVYUH-AI v1.0 is a full-stack, dataset-driven border defence surveillance dashboard that integrates multiple AI/ML paradigms β€” supervised learning, unsupervised anomaly detection, and deep learning β€” into a unified real-time intelligence platform.

The system processes data from 5 real cybersecurity and IoT datasets, runs 3 AI/ML models simultaneously, and presents actionable threat intelligence through a military-grade React dashboard with 10 operational modules. All threat outputs, risk zones, sensor readings, and alert classifications are derived from real datasets. Most outputs are derived from real datasets, with fallback logic used when features are unavailable.

"Inspired by the ancient military formation β€” an inescapable, multi-layered defence system."


βœ… Problem Statement Fulfillment

# Objective Implementation Status
1 EDA on surveillance & sensor datasets ML pipeline generates full EDA dashboard from 5 merged real datasets βœ…
2 Build anomaly detection models Isolation Forest β€” 975 anomalies detected, 12% contamination βœ…
3 Classify using ML/DL techniques Random Forest (80.2% acc) + YOLOv8 deep learning βœ…
4 Predict high-risk zones 27 risk zones predicted from historical incident data βœ…
5 Alert prioritization to reduce false positives Weighted CRITICAL/HIGH/MEDIUM/LOW with action log βœ…
Challenge Solution
Large-Scale Monitoring 8,208 rows merged from 5 real datasets
Delayed Threat Detection YOLOv8 CCTV detection + dataset-driven sensor feed
False Alarms Isolation Forest anomaly filtering + FP suppression
Resource Constraints Drone module simulating aerial coverage of remote zones
Data Integration Auto-discovery ML pipeline with fuzzy schema mapping

πŸ”„ How It Works (Simple Flow)

  1. YOLO detects objects from CCTV / dataset
  2. Features extracted into structured vectors
  3. Isolation Forest detects anomalies
  4. Random Forest classifies threat levels
  5. Alert priority is calculated
  6. Output is signed using post-quantum cryptography
  7. Data is sent to dashboard via REST APIs

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        DATA SOURCES                             β”‚
β”‚   NSL-KDD Β· RT-IoT2022 Β· UNSW-NB15 Β· Network CSV Β· Intrusion    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  ML PIPELINE  (run_pipeline.py)                 β”‚
β”‚   Auto-Discovery β†’ Fuzzy Merge (8,208 rows) β†’ EDA β†’ Train       β”‚
β”‚         ↓                    ↓                     ↓            β”‚
β”‚   Isolation Forest     Random Forest           EDA Charts       β”‚
β”‚   (iso_model.pkl)     (rf_model.pkl)           (5 PNGs)         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚  PKL files + CSV outputs
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  FLASK BACKEND  (app.py)                        β”‚
β”‚                                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚   YOLOv8     β”‚ β”‚ Iso Forest    β”‚ β”‚   Random Forest       β”‚   β”‚
β”‚  β”‚  (webcam)    β”‚ β”‚ (anomaly)     β”‚ β”‚   (classification)    β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                    ↓                                            β”‚
β”‚          Quantum Security Layer  (quantum_security.py)          β”‚
β”‚          Kyber-512 KEM Β· Dilithium2 Signatures Β· AES-256-GCM    β”‚
β”‚                                                                 β”‚
β”‚   REST API Endpoints β†’ frontend + quantum dashboard             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚  JSON
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               REACT FRONTEND  (App.jsx)                         β”‚
β”‚                                                                 β”‚
β”‚  OVERVIEW Β· LIVE DEMO Β· CCTV Β· DRONE Β· THREATS Β· ANALYTICS      β”‚
β”‚            SENSORS Β· OSINT Β· MAP Β· QUANTUM                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Detection Pipeline β€” 6 Stages Per Frame

Stage Name Model / Method
1 Object Detection YOLOv8n (COCO fallback)
2 Feature Extraction 10-feature vector from detections
3 Anomaly Scoring Isolation Forest (PKL) / formula fallback
4 Threat Classification Random Forest (PKL) / rule-based fallback
5 Alert Priority Weighted formula + FP suppression
6 Quantum Signing Dilithium2 (liboqs) / HMAC-SHA3-256 fallback

πŸ€– AI/ML Models

1. πŸ” YOLOv8 β€” Real-Time Object Detection

YOLOv8n PyTorch

  • Type: Deep Learning / Computer Vision
  • Use: Real-time CCTV object detection β€” detects persons, vehicles, and objects with bounding boxes and confidence scores
  • Custom CentroidTracker: Euclidean distance matching (80px threshold), 20-point path history, 8-frame disappearance logic for persistent object tracking
  • Fallback: Claude Vision API when YOLOv8 unavailable

Note: Live CCTV detection requires a physical webcam. In evaluation without hardware, the system continues via dataset-driven threat simulation.

2. 🚨 Isolation Forest β€” Anomaly Detection

Unsupervised Anomalies

  • Type: Unsupervised Machine Learning
  • Use: Detects abnormal sensor patterns without labelled data β€” catches novel threats no known category covers
  • Config: contamination=0.12 Β· n_estimators=200 Β· random_state=42
  • Results: 975 anomalies detected Β· 12% contamination rate
  • Trained on: RT-IoT2022, NSL-KDD, UNSW-NB15

3. 🎯 Random Forest β€” Threat Classification

Supervised Accuracy

  • Type: Supervised Machine Learning
  • Use: Classifies sensor events into CRITICAL / HIGH / MEDIUM / LOW threat levels with probability scores
  • Config: n_estimators=200 Β· max_depth=12 Β· 5-fold cross-validation
  • Results: 80.2% accuracy Β· 5-fold CV 73.9%
  • Why RF: Interpretable classifications β€” unlike deep learning, every decision can be explained by feature contribution

πŸ–₯️ Navigation Modules

Module Description
OVERVIEW Live KPIs (total/active/neutralized/falsePos), threat log, 24-hour timeline β€” all from real dataset rows
LIVE DEMO 5-stage ML pipeline visualiser: Webcam β†’ YOLO β†’ Anomaly β†’ Priority β†’ Map Marker
πŸ“· CCTV YOLOv8 object detection with bounding boxes and CentroidTracker path trails (webcam required)
πŸ›Έ DRONE Simulated aerial surveillance β€” GARUDA-1/2/3 UAVs, IR/VIS mode, 1Γ—/2Γ—/4Γ—/8Γ— zoom (simulated)
THREATS Dataset-driven threat feed (4 per level), Cognitive Tactical SITREP, NEUTRALIZE/MONITOR/ESCALATE actions
ANALYTICS 5 EDA charts from ML pipeline, classification results, anomaly detection visuals
SENSORS 6 sensor cards (VISUAL Β· IR Β· SEISMIC Β· RF Β· SATELLITE Β· ACOUSTIC) β€” dataset-driven readings
OSINT 27 ML-predicted high-risk border zones from high_risk_zone_predictions.csv
🌍 MAP World map with India LoC/LAC overlays, threat markers, Markov-chain infiltration route predictor
βš› QUANTUM Live PQC dashboard β€” algorithm status, signature chain feed, key rotation timer, chain verification

πŸ” Quantum Security Layer

CHAKRAVYUH-AI v1.0 introduces a Post-Quantum Cryptography layer that cryptographically signs every ML pipeline output and chains the signatures together to create a tamper-evident audit trail.

Why Post-Quantum?

Classical encryption (RSA, ECC) used in current defence systems is vulnerable to quantum computers running Shor's algorithm. NIST finalised post-quantum standards in 2024. CHAKRAVYUH-AI implements these standards to demonstrate quantum-resistant ML output integrity β€” a real and near-term concern for defence AI systems.

Algorithms

Algorithm Standard Role
CRYSTALS-Kyber-512 NIST FIPS 203 Key Encapsulation β€” protects AES session key
CRYSTALS-Dilithium2 NIST FIPS 204 Digital Signatures β€” signs every ML output
AES-256-GCM NIST FIPS 197 Bulk Encryption β€” encrypts threat payloads
SHA3-256 NIST FIPS 202 Pre-hash for signature construction

Signature Chain

Every ML output (threat level, anomaly score, alert priority) is:

  1. Hashed with SHA3-256
  2. Signed with Dilithium2
  3. Linked to the previous output's hash

This creates a cryptographically linked chain. Modifying any output after signing β€” even by one byte β€” breaks the signature and invalidates all subsequent links. The QUANTUM module provides on-demand chain integrity verification.

Key Rotation β€” Perfect Forward Secrecy

Kyber and Dilithium keys rotate automatically every 15 minutes via a background thread. Compromising a current session key cannot decrypt past sessions.

Graceful Degradation

The liboqs-python native PQC library requires platform-specific compilation. When not installed, the system automatically falls back to HMAC-SHA3-256 + AES-256-GCM. The QUANTUM dashboard displays the active mode clearly:

PQC ACTIVE      β†’  liboqs installed Β· Kyber-512 + Dilithium2 running
FALLBACK MODE   β†’  liboqs unavailable Β· HMAC-SHA3-256 + AES-256-GCM active

This is graceful degradation by design β€” not an error state. All chain, rotation, tamper detection, and verification features operate identically in both modes.

# Install full PQC mode
pip install liboqs-python pycryptodome

πŸ› οΈ Tech Stack

Frontend

React Canvas Recharts

  • React 18 β€” Single Page Application, 10 modules, 3,500+ lines
  • HTML5 Canvas β€” world map with 4-pass glow rendering + DPR scaling, drone canvas with zoom
  • Recharts β€” analytics charts, radar chart, area charts
  • Orbitron + Share Tech Mono β€” military-grade dark UI

Backend

Flask Ultralytics scikit-learn

  • Python Flask β€” REST API, 8 endpoints
  • Ultralytics YOLOv8 β€” real-time object detection
  • scikit-learn β€” Random Forest + Isolation Forest inference
  • quantum_security.py β€” PQC signing layer (Kyber + Dilithium + AES)

ML Pipeline

AutoDiscovery Datasets

  • Auto-discovery scanner β€” recursively finds and merges all CSV datasets
  • Fuzzy column mapping β€” handles schema differences across datasets automatically
  • Generates PKL model files + 5 EDA visualisation PNGs + risk zone CSV

πŸ“¦ Datasets

Dataset Size Domain Use
NSL-KDD (Train + Test) ~5.1 MB Network Intrusion RF threat classification
RT-IoT2022 52 MB IoT Sensor Data Anomaly detection
UNSW-NB15 Events 5 KB Network Events Feature augmentation
train_test_network.csv 29 MB Network Traffic Multi-class classification
cybersecurity_intrusion_data.csv 709 KB Intrusion Patterns EDA + feature analysis

⚠️ Datasets not included in repository due to size. Place all CSV files in datasets/ folder before running the pipeline.

Sources: NSL-KDD Β· UNSW-NB15 Β· RT-IoT2022


πŸ“ Project Structure

chakravyuh_ai/
β”‚
β”œβ”€β”€ πŸ“ backend/
β”‚   β”œβ”€β”€ app.py                          # Flask REST API β€” 6-stage ML pipeline
β”‚   β”œβ”€β”€ quantum_security.py             # PQC layer (Kyber + Dilithium + AES)
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── chakravyuh_outputs/             # PKL models + CSV outputs (git-excluded)
β”‚
β”œβ”€β”€ πŸ“ frontend/
β”‚   β”œβ”€β”€ πŸ“ src/
β”‚   β”‚   └── App.jsx                     # React SPA β€” 10 modules (3,500+ lines)
β”‚   β”œβ”€β”€ πŸ“ public/
β”‚   β”‚   └── πŸ“ maps/
β”‚   β”‚       └── ne_50m_admin_0_countries.json   # Natural Earth GeoJSON
β”‚   β”œβ”€β”€ package.json
β”‚   └── package-lock.json
β”‚
β”œβ”€β”€ πŸ“ ml_pipeline/
β”‚   β”œβ”€β”€ run_pipeline.py                 # Auto-discovery ML training pipeline
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── chakravyuh_outputs/             # Generated charts, CSVs, PKLs
β”‚
β”œβ”€β”€ πŸ“ datasets/                        # Real CSV files (git-excluded)
β”‚   β”œβ”€β”€ Train_data.csv
β”‚   β”œβ”€β”€ Test_data.csv
β”‚   β”œβ”€β”€ RT_IOT2022.csv
β”‚   β”œβ”€β”€ train_test_network.csv
β”‚   β”œβ”€β”€ cybersecurity_intrusion_data.csv
β”‚   └── UNSW-NB15_LIST_EVENTS(in).csv
β”‚
β”œβ”€β”€ download_borders.py                 # Downloads Natural Earth GeoJSON
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md

πŸš€ Setup & Installation

Prerequisites

Python Node

1. Backend

cd backend
pip install flask flask-cors numpy pandas scikit-learn joblib ultralytics
pip install liboqs-python pycryptodome    # Optional β€” full PQC mode
pip install anthropic                     # Optional β€” Claude SITREP

python app.py
# API running at http://localhost:5000

2. Frontend

cd frontend
npm install
npm start
# Dashboard running at http://localhost:3000

3. ML Pipeline (run once to generate models)

cd ml_pipeline
pip install numpy pandas scikit-learn matplotlib seaborn joblib
python run_pipeline.py

# Copy outputs to backend (Windows)
copy chakravyuh_outputs\*.pkl ..\backend\chakravyuh_outputs\
copy chakravyuh_outputs\*.csv ..\backend\chakravyuh_outputs\

4. Map Data

python download_borders.py
# Places ne_50m_admin_0_countries.json β†’ frontend/public/maps/

5. Optional β€” Claude API for AI Tactical Briefs

# PowerShell only β€” never store API keys in files
$env:ANTHROPIC_API_KEY = "sk-ant-..."

The system runs fully offline with local fallbacks for all AI features. No external API keys are required for core functionality.


πŸ“‘ API Reference

Method Endpoint Description
GET /health System status β€” models, engines, quantum, uptime
POST /api/analyze-frame Full 6-stage ML + Quantum pipeline per frame
POST /api/tactical-brief AI-generated SITREP (Claude / local fallback)
GET /api/risk-zones 27 ML-predicted high-risk border zones
GET /api/sensor-data Balanced threat feed (4 per level, real CSV rows)
GET /api/quantum-status Live PQC metrics: algorithms, chain, key rotation
POST /api/quantum-verify On-demand full signature chain integrity verification
GET /api/quantum-signatures Last N signed ML payloads for live feed display

πŸ“Š ML Pipeline Results

╔══════════════════════════════════════════════════════╗
β•‘         CHAKRAVYUH-AI  ML Pipeline v5.0              β•‘
╠══════════════════════════════════════════════════════╣
β•‘  Datasets discovered        :  5 files               β•‘
β•‘  Total rows merged          :  8,208                 β•‘
╠══════════════════════════════════════════════════════╣
β•‘  Random Forest Accuracy     :  80.2%                 β•‘
β•‘  Cross-Validation (5-fold)  :  73.9%                 β•‘
╠══════════════════════════════════════════════════════╣
β•‘  Isolation Forest           :  12% contamination     β•‘
β•‘  Anomalies Detected         :  975                   β•‘
╠══════════════════════════════════════════════════════╣
β•‘  Risk Zones Predicted       :  27                    β•‘
β•‘  PKL Models Generated       :  2                     β•‘
β•‘  EDA Charts Generated       :  5                     β•‘
╠══════════════════════════════════════════════════════╣
β•‘  Quantum Signatures Issued  :  Live (grows per run)  β•‘
β•‘  Chain Integrity            :  INTACT                β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

⚠️ System Notes & Limitations

Area Status Notes
CCTV live feed Hardware required YOLOv8 detection works with webcam; module inactive without one
Drone surveillance Simulated Canvas-based simulation β€” no real UAV hardware connected
Quantum PQC (full) Optional Requires liboqs-python; graceful HMAC fallback always active
Claude API Optional Local rule-based tactical brief fallback active without key
Satellite feeds Not implemented All sensor readings are dataset-derived, not live satellite data
Military deployment Academic only Research and internship demonstration project β€” not a production system

This system is a dataset-driven simulation built for academic evaluation and research. It demonstrates the feasibility of integrating multiple AI/ML paradigms into a unified defence intelligence interface β€” not a deployable military product.


πŸ” Security

  • API keys are never stored in source files β€” set via environment variables only
  • All datasets excluded from repository via .gitignore
  • PKL model files excluded β€” regenerate using run_pipeline.py
  • YOLOv8 weights excluded β€” auto-downloaded by Ultralytics on first run

CHAKRAVYUH-AI v1.0 Β· Border Defence & Surveillance Intelligence Dashboard

Built with


GitHub: github.com/priyank5548/chakravyuh_ai

About

AI-powered border surveillance system with multi-sensor data fusion, YOLO-based detection, anomaly scoring (Isolation Forest), threat classification (Random Forest), and post-quantum cryptographic signature chaining for secure, tamper-evident intelligence.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors