# iamrohitkandpal/ddos-cloud-protection-system architecture

> Architecture diagram of the GitHub repository iamrohitkandpal/ddos-cloud-protection-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iamrohitkandpal/ddos-cloud-protection-system
- Repository: https://github.com/iamrohitkandpal/ddos-cloud-protection-system

## Overview

##### Project type and purpose
- This is a full-stack, security-focused web application (“DDoS Protection System”) built to defend Indian government sites in real time.
- Frontend: React dashboard for monitoring and configuration.
- Backend: Node.js/Express API with layered services—traffic ingestion, real-time analysis, rate-limiting, machine-learning detection, alerting.
- Data stores: Redis (cache, rate limits, blacklists) and MongoDB (persistent logs, analytics).
- Deployment: Nginx as a reverse proxy/WAF, hosted on AWS or cloud providers, with optional Redis Cloud and MongoDB Atlas.

##### File structure
- Top-level directories:
– backend/ (MVC structure: controllers, routes, models, services, utils, middlewares)
– frontend/ (React app: components, assets, utils, config)
– deployment/nginx/ (nginx configuration for DDoS protection)
– docs/ (architecture, installation, usage)
- Patterns:
– Backend is layered (routes → controllers → services → utilities → data stores).
– Frontend is component-based with configuration and WebSocket helpers.
– Dedicated middleware for security, rate limiting, geo-blocking, CAPTCHA, logging.
- Notices: .env examples, build scripts (Vite for frontend), linting (ESLint), tailwind config.

##### Extract architectural insights from README
- The system has five logical layers:
1. Traffic Ingestion (Nginx + IP filters + honeypot)
2. Analysis Engine (rule-based middlewares + ML detection via TensorFlow.js)
3. Cache Layer (Redis for rate-limiting and blacklist)
4. Persistent Storage (MongoDB for logs, patterns)
5. Administration Dashboard (React + Socket.IO)
- ML integration and real-time WebSocket notifications are highlighted.
- External services: Redis Cloud, MongoDB Atlas, AWS hosting, CERT-In feeds, API gateway.

##### Essential architectural details
- Every middleware group (e.g., Security → Rate Limit → Geo-Block → CAPTCHA).
- ML detection utility as part of the Analysis Engine.
- Real-time notification path (Socket.IO channel from backend to frontend).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client & Ingestion Layer
    subgraph "Client & Ingestion"
        direction TB
        Client["Web Browser"]:::external
        Nginx["Traffic Ingestion (Nginx/WAF)"]:::service
    end

    Client -->|HTTP/S| Nginx
    click Nginx "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/deployment/nginx/ddos-protection.conf"

    %% Frontend Layer
    subgraph "Administration Dashboard"
        direction TB
        App["React Dashboard"]:::frontend
        DashboardComp["AdvancedDashboard.jsx"]:::frontend
        WSClient["WebSocket Helper"]:::frontend
    end

    click App "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/frontend/src/App.jsx"
    click DashboardComp "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/frontend/src/components/AdvancedDashboard.jsx"
    click WSClient "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/frontend/src/utils/websocket.js"
    click main "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/frontend/src/main.jsx"
    click config "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/frontend/src/config.js"
    click vite "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/frontend/vite.config.js"
    click tailwind "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/frontend/tailwind.config.js"

    %% Backend Layer
    subgraph "Backend API"
        direction TB
        API["Express API (app.js)"]:::backend
        click API "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/app.js"

        subgraph "Routes & Controllers"
            direction TB
            Routes["Routes"]:::backend
            Controllers["Controllers"]:::backend
            Honeypot["Honeypot Route"]:::backend
        end
        click Routes "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/tree/main/backend/routes/"
        click Controllers "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/tree/main/backend/controllers/"
        click Honeypot "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/routes/honeypot.js"

        subgraph "Security Middlewares"
            direction TB
            Sec["security.js"]:::service
            RateLimit["enhancedRateLimiting.js"]:::service
            GeoBlock["geoBlocking.js"]:::service
            Captcha["captchaMiddleware.js"]:::service
            LogTraffic["logTraffic.js"]:::service
        end
        click Sec "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/middlewares/security.js"
        click RateLimit "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/middlewares/enhancedRateLimiting.js"
        click GeoBlock "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/middlewares/geoBlocking.js"
        click Captcha "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/middlewares/captchaMiddleware.js"
        click LogTraffic "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/middlewares/logTraffic.js"

        subgraph "Services & Utilities"
            direction TB
            RedisService["Redis Service"]:::service
            WAFService["WAF Service"]:::service
            subgraph "ML Engine"
                direction TB
                MLDet["mlDetection.js"]:::service
                Behavior["behavioralAnalysis.js"]:::service
                Analyzer["trafficAnalyzer.js"]:::service
            end
            AlertSys["alertSystem.js"]:::service
            Challenge["challengeGenerator.js"]:::service
            WSrv["websocketTest.js"]:::service
        end
        click RedisService "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/services/redisService.js"
        click WAFService "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/services/wafService.js"
        click MLDet "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/utils/mlDetection.js"
        click Behavior "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/utils/behavioralAnalysis.js"
        click Analyzer "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/utils/trafficAnalyzer.js"
        click AlertSys "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/utils/alertSystem.js"
        click Challenge "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/utils/challengeGenerator.js"
        click WSrv "https://github.com/iamrohitkandpal/ddos-cloud-protection-system/blob/main/backend/utils/websocketTest.js"

    end

    Nginx -->|Forward| API
    API -->|use| Routes
    Routes --> Controllers
    Controllers -->|invoke| Sec
    Sec --> RateLimit
    Sec --> GeoBlock
    Sec --> Captcha
    Sec --> LogTraffic

    Controllers --> RedisService
    RedisService -->|read/write| RedisDB

    Controllers --> WAFService

    Controllers -.->|analysis| MLDet
    MLDet --> Behavior
    Behavior --> Analyzer
    Analyzer --> MongoDB

    Controllers --> MongoDB
    Controllers --> AlertSys
    Controllers --> Challenge

    API -->|REST| App
    API -.->|WebSocket| App

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RedisDB["Redis (Cache & Blacklist)"]:::db
        MongoDB["MongoDB (Logs & Analytics)"]:::db
    end

    %% External Services
    subgraph "External"
        direction TB
        CERT["Threat Intelligence (CERT-In)"]:::external
    end

    CERT -->|feed| API

    %% Layout connections to Data Layer
    Analyzer --> MongoDB
    Controllers -->|log| MongoDB

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#1E88E5,color:#0D47A1;
    classDef backend fill:#FFF3E0,stroke:#FB8C00,color:#E65100;
    classDef service fill:#E8F5E9,stroke:#43A047,color:#1B5E20;
    classDef db fill:#F3E5F5,stroke:#8E24AA,color:#4A148C,shape:cylinder;
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#263238;
```
