# abgoyal/airtel_gpon_usage_monitor architecture

> Architecture diagram of the GitHub repository abgoyal/airtel_gpon_usage_monitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abgoyal/airtel_gpon_usage_monitor
- Repository: https://github.com/abgoyal/airtel_gpon_usage_monitor

## Overview

##### Core Components
- Nokia G-2425G-A Router (FTTH Modem)
- Monitoring Script (Node.js)
- Smart Plug (External Device)
- Storage/Logging System

##### Data Flow Architecture

a) Input Layer:
- WebUI interface with a note about the 32-bit counter limitation
- Smart Plug connection to the router (showing periodic reboot capability)

b) Processing Layer:
- Node.js Script Components:
- Authentication Module (using node-jsencrypt)
- Web Scraping Module
- Counter Overflow Detection Logic
- Data Processing/Correction Module

c) Output Layer:
- Logging System
- Usage Statistics Output

Use these specific visual elements:

##### Component Representations
- Use rectangles for main components (Router, Script, Smart Plug)

##### Error Handling
- How the system handles router reboots
- Counter overflow detection
- Data correction mechanisms

##### Timing Aspects
- 15-second polling cycle
- Nightly reboot schedule
- Potential overflow windows

##### Security Layer
- Custom authentication process
- Encryption mechanism for router communication

**[Router & Smart Plug] (Top)**
- ↓
**[Authentication & Scraping Layer]**
- ↓
**[Processing & Overflow Detection]**
- ↓
**[Statistics Output] (Bottom)**

Keep these specific aspects in mind:
- Critical path of data collection
- Error handling mechanisms
- Where data corrections occur
- Potential failure points
- Periodic nature of operations

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef router fill:#a8d1f0,stroke:#333
    classDef script fill:#90EE90,stroke:#333
    classDef external fill:#FFE5B4,stroke:#333
    classDef storage fill:#D3D3D3,stroke:#333
    classDef critical fill:#FFB6C1,stroke:#333
    classDef process fill:#E6E6FA,stroke:#333

    %% Main Components
    Router["Nokia G-2425G-A Router<br/>(32-bit Counter)"]:::router
    SmartPlug["Smart Plug<br/>(Reboot Control)"]:::external
    MonitorScript["Monitoring Script<br/>(15s Polling)"]:::script
    AuthModule["Authentication Module<br/>(node-jsencrypt)"]:::critical
    WebScraper["Web Scraping<br/>Module"]:::script
    OverflowDetect["Counter Overflow<br/>Detection"]:::critical
    DataProcess["Data Processing &<br/>Correction"]:::process
    LogSystem["Logging System"]:::storage
    StatsOutput["Usage Statistics<br/>Output"]:::storage

    %% Relationships
    Router --> |"WebUI Interface"| WebScraper
    SmartPlug --> |"Periodic Reboot"| Router
    WebScraper --> |"Raw Data"| OverflowDetect
    AuthModule --> |"Encrypted Auth"| WebScraper
    OverflowDetect --> |"Corrected Data"| DataProcess
    DataProcess --> |"Processed Stats"| LogSystem
    LogSystem --> |"Final Output"| StatsOutput

    %% Add notes
    subgraph Legend
        RouterLeg["Router Component"]:::router
        ScriptLeg["Script Component"]:::script
        ExternalLeg["External Device"]:::external
        CriticalLeg["Critical Component"]:::critical
        StorageLeg["Storage Component"]:::storage
        ProcessLeg["Processing Component"]:::process
    end

    %% Click events for component mapping
    click MonitorScript "https://github.com/abgoyal/airtel_gpon_usage_monitor/blob/main/index.js"
    click StatsOutput "https://github.com/abgoyal/airtel_gpon_usage_monitor/blob/main/hist.awk"
    click AuthModule "https://github.com/abgoyal/airtel_gpon_usage_monitor/blob/main/package.json"
```
