How shardeum/network-status works
Based on your file tree and README, this project is a real-time monitoring system titled “Shardeum Network Status Monitor.” It’s built using Next.js for the frontend and an Express-based Prometheus exporter for the backend, while Prometheus itself is used for scraping and storing metrics. The project monitors service availability and performance metrics, visualizing latency, uptime, and status information in real time.
Main Components
• Next.js Frontend: Represented by the “app” directory (with its API routes, pages, and layout) and “components” (UI elements such as Header, Footer, and monitors). This portion handles real-time visualization of metrics, latency graphs, and status indicators.
• Prometheus Exporter (Express Server): Found under the “server” directory (exporter.js and endpoints.json). Its role is to query the endpoints, implement retry logic and error handling, and expose metrics (like service_up and service_response_time) for Prometheus scraping.
• Prometheus Server: Although not part of the project code per se, the README specifies that Prometheus runs on port 9090 and scrapes metrics from the exporter.
• External Services: Represent the monitored endpoints configured via “endpoints.json” (inside the server directory) which define each service's URL, expected response format, etc.
• Docker/Deployment Components: Note Dockerfiles (Dockerfile.exporter and Dockerfile.frontend) and docker-compose.yml, indicating containerized deployment for different parts of the system.
Relationships and Data Flow
• The Next.js Frontend interacts with its own API routes (located in “app/api”) to fetch real-time metrics and status data, communicating possibly with custom hooks (from the “hooks” directory) that abstract away data fetching.
• The Prometheus Exporter is responsible for performing automated and concurrent checks on the configured external services, applies retry logic, and then exposes the formatted metrics.
• The Prometheus Server periodically scrapes data from the Exporter, storing time-series data that the frontend can query (directly or indirectly, as per architecture).
• External services are constantly monitored by the Exporter via HTTP requests, with retry handling and state management (as per the detailed “Monitoring Logic” in the README).
Essential Architectural Patterns and Design Principles
• Separation of Frontend and Backend: The architecture clearly distinguishes the user interface (Next.js) from backend service monitoring (Express exporter) and metric storage/processing (Prometheus).
• Microservice and API Patterns: The project uses API routes (in Next.js) to facilitate interaction, while the exporter runs as an independent service.
• Retry and Grace Period Mechanisms: Emphasize the retry logic implemented in the exporter (with exponential backoff) and the state management (grace period before generating alerts).
• Containerization: The multiple Dockerfiles and docker-compose configuration indicate that containerized deployment is intended – include containers for the Frontend, Exporter, and possibly a separate container for Prometheus.
• Real-time Data Flow and Polling: With realtime views refreshing every second and service checks every 60 seconds, denote different refresh intervals for user interaction and backend monitoring.