Skip to content

Development

Architecture

The project is structured as follows:

  • api/: Contains the API route definitions.
  • controllers/: Contains the controllers for handling API requests.
  • models/: Contains the data models.
  • operations/: Contains the business logic and database operations.
  • middleware/: Contains middleware functions.
  • lib/: Contains utility functions.
  • db.js: Database connection and schema creation.
  • index.js: Entry point of the application.

Diagram

flowchart TD
    subgraph Initialization
        A[Initialize Environment Variables] --> B[Initialize Graph API Client]
        B --> C[Create Device Table if not exists]
    end

    subgraph Graph API Data Fetching
        D[Start Graph API Process] --> E[Fetch All Devices from Graph API]
        E --> F[Fetch Management Info]
        E --> G[Fetch Device Health]
        E --> H[Fetch Device Activity]
        E --> I[Fetch Device Configuration]
        F & G & H & I --> J[Combine Device Data]
    end

    subgraph Data Processing
        J --> K[Add Timestamps/IDs]
        K --> L[Add Severity Info]
        L --> M[Normalize Serial Numbers]
        M --> N[Add Location Data via Geocoder]
        N --> O[Apply Filters from External Service]
        O --> P[Prepare for Database]
    end

    subgraph Database Operations
        P --> Q[Upsert Devices in Batch]
        Q --> R[Delete Obsolete Devices]
        R --> S[Update In-Memory Store]
    end

    style Initialization fill:#f0f4c3,stroke:#827717