Skip to content

Development

Architecture

Contains the main source code for the project. - controllers/: Handles incoming requests and business logic. - models/: Defines the data models and schemas. - routes/: Defines the API routes and their handlers. - services/: Contains reusable service logic. - utils/: Utility functions and helpers.

Diagram

Watchers flow diagram

%%{init: {'theme': 'forest', 'themeVariables': { 'fontSize': '10px'}} }%%
flowchart TD

    subgraph Watcher_Management
        C[Create/Update Watcher] --> D[Validate Watcher Data]
        D --> E[Store in Database]
        F[Get Watchers] --> G{Filter Active/Inactive}
        G --> H[Return Active Watchers]
        G --> I[Return Inactive Watchers]
    end

    subgraph Condition_Evaluation
        J[New Device Data] --> K[Get Relevant Watchers]
        K --> L[Check Conditions]
        L --> M{Trigger Met?}
        M -->|Yes| N[Create New Alarm]
        M -->|No| O[Check Existing Alarms]
    end

    subgraph Alarm_Handling
        N --> P[Store Alarm in DB]
        O --> Q{Existing Alarm?}
        Q -->|Yes| R[Compare Values]
        R --> S{Values Changed?}
        S -->|Yes| T[Deactivate Old Alarm]
        S -->|No| U[Maintain Alarm]
        T --> N
        Q -->|No| V[No Action]
    end

    subgraph Notifications
        P --> W[Send Webex Notification]
        T --> X[Send Deactivation Notice]
    end

    subgraph Data_Processing
        L --> Y[Parse Device Data]
        Y --> Z[Check Nested Properties]
        Z --> AA[Compare with Thresholds]
        AA --> AB[Detect Changes]
    end

    Watcher_Management --> Condition_Evaluation
    Condition_Evaluation --> Alarm_Handling
    Alarm_Handling --> Notifications
    Condition_Evaluation --> Data_Processing

    style Watcher_Management fill:#b3e5fc,stroke:#0288d1
    style Condition_Evaluation fill:#c8e6c9,stroke:#388e3c
    style Alarm_Handling fill:#ffcdd2,stroke:#c62828
    style Notifications fill:#e1bee7,stroke:#7b1fa2
    style Data_Processing fill:#fff9c4,stroke:#f57f17