How chainstacklabs/compare-dashboard-functions works
Main Components
• Global Serverless Functions: Representing the functions that collect metrics every minute.
• Region-Specific Functions (e.g., EU only): Handling tasks like state updates (30-minute intervals) and measuring transaction landing rate (15-minute intervals).
• Blob Storage – Represents Vercel’s Blob Storage used to store state data. This component will interact with the functions.
• Grafana Cloud – The destination for pushing the collected metrics. Note that it is running a Prometheus instance for visualization.
Detail the Relationships and Interactions
• Blob Storage sends/stores and receives data to/from the Collector functions.
• The Collector functions interact bidirectionally with the RPC nodes to fetch performance metrics.
• Convert the collected metrics and send them to Grafana Cloud.
• The State update and Transaction (TX) functions also interact with Blob Storage and the RPC nodes.
• That while some serverless functions (within the Global category) are collecting metrics continuously, others (like state updates) run at longer intervals and are deployed in specific regions.
Architectural Patterns and Design Principles
• Modular Structure: The file tree is organized into distinct directories such as “api” (with subdirectories for read, write, and support), “common” (for shared utilities and state management), and “metrics” (for individual metric implementations). Emphasize that this decoupling supports clear separation of concerns.
• Serverless and Multi-region Deployment: Illustrate the Vercel Functions deployed in distinct regions (e.g., Singapore, EU, US-West) and how the environment variables are configured for multi-region consistency.
• Extensibility: The project is designed to easily add new metrics. The “common”, “factory”, and “metric” related modules along with tests encourage modularity and extensibility.
Relevant Technologies, Frameworks, and Libraries
• Python: As indicated by the use of Python scripts, virtual environment setup, and requirements.txt.
• Vercel Functions: For serverless deployment along with Blob Storage integration.
• Grafana Cloud & Prometheus: For metrics storage and visualization.
• Blockchain Specific Modules: Within the “api/read” and “api/write” directories, there are separate handlers for Ethereum, Solana, TON, and in some cases “Base” – each indicating blockchain-specific logic.