How iexecblockchaincomputing/iexec-voucher-subgraph works
Project Type & Purpose
• It is focused on reading, indexing, and then exposing data via GraphQL (queriable through a GraphiQL interface) by harnessing The Graph protocol.
• The project also provides dockerized deployment and continuous integration/continuous deployment (CI/CD) pipelines using Jenkins.
Analyzing the File Structure
• Top-level configuration and metadata files (e.g., .dockerignore, .gitignore, package.json, JenkinsfileBuild, JenkinsfileDeploy) hint at build/deploy automation and containerized deployment.
• The “src” folder holds the core TypeScript code, for example, utilities (utils.ts) and files specific to handling vouchers (voucher.ts, voucherHub.ts).
• There’s a “tests” directory organized into unit tests for these modules indicating a well-tested code core.
• A “docker” folder with its Dockerfile and a “test-stack” directory with docker-compose setup illustrate how the system is containerized and integrated (for local testing or deployment).
Key Components
• The core service built in the “src” directory that indexes the blockchain VoucherHub events.
• Code generation step (npm run codegen) using the ABIs from the iexec-voucher-contracts.
• Build & Deployment Pipelines:
• Connection with CI/CD automation is vital.
• External Systems and Services:
• VoucherHub blockchain contract (the origin of events, as configured by environment variables VOUCHER_HUB_ADDRESS and VOUCHER_HUB_START_BLOCK).
• Docker Infrastructure:
• Docker container images built using the provided Dockerfile.
• The “test-stack” (docker-compose) to run a local testing environment that ties together IPFS, Graph Node, and potentially mocks of blockchain nodes.
Relationships and Data Flow
• The blockchain (VoucherHub contract) is the event source.
• It then communicates the data to the Graph Node, which indexes the data and provides a GraphQL API for querying.
• The entire process is automated via build and deploy pipelines orchestrated using Jenkins.
• There is also a test-stack configuration for local testing—this should be represented as an environment that simulates the production integration.
Architectural Patterns & Design Principles
• Separation of concerns – the code is cleanly separated into logical modules (e.g., voucher and voucherHub handling), and CI/CD is clearly separated.
• Containerization – Docker is used to encapsulate deployments ensuring consistency across environments.
• CI/CD integration – Jenkins pipelines manage the building and deployment processes.