How ringecosystem/degov works
Main Components
• Smart Contracts Module:
• Located in the “contracts” directory.
• Contains Solidity smart contracts built on the OpenZeppelin Governor framework.
• Includes supporting files like foundry.toml, contracts/src, remappings.txt, and Makefile for building and deploying contracts.
• Indexer Service:
• Found under “packages/indexer.”
• Handles blockchain event listening, data extraction, and populates the off-chain database.
• Contains source code (src directory) for ABI handling, event processing (e.g., src/handler, src/processor.ts), database migrations (db/migrations), and GraphQL schema (schema.graphql).
• Includes various Dockerfiles and deployment scripts to run the indexer.
• Web Frontend:
• Located in “packages/web.”
• A Next.js application that provides the user interface for interacting with the DAO.
• Contains API routes, components, pages, and configurations (next.config.ts, tailwind.config.ts).
• Uses GraphQL services (in src/services/graphql) to query data processed by the indexer and stored in the database.
• Ancillary Elements:
• Docker & Deployment: Dockerfiles and docker-compose files (e.g., docker-compose.yml, files under the “docker/” directory) indicate containerized services which include the indexer and web app.
• Configuration and Initialization: Several init-scripts (init-scripts/postgres/init.sql) and configuration files (pnpm-workspace.yaml, package.json) are supplied for bootstrapping the system.
• CI/CD Pipeline: GitHub workflow files under “.github/workflows/” for testing, deploying in different environments (dev, staging, production), and releasing the code.
Relationships and Interactions
• The Smart Contracts on the Ethereum blockchain serve as the core governance engine executing proposals, votes, and state changes.
• The Indexer Service monitors on-chain events from these contracts, parses event data via ABI definitions (both in “contracts” and “packages/indexer/abi”), processes and stores this information in a database (migrations present in indexer’s db directory), and exposes a GraphQL API.
• The Web Frontend communicates with the Indexer’s GraphQL API to display real-time on-chain data, allows users to interact with proposals, vote, and handles authentication (evidenced by auth API endpoints in packages/web/src/app/api).
• Docker orchestration ensures that these services (contracts, indexer, web app) run reliably across different environments.
Architectural Patterns & Design Principles
• Microservices / Modular Structure: Separation into distinct services (contracts, indexer, web).
• API-Driven Communication: The Web Frontend interacts with the Indexer through a GraphQL API.
• Containerization & Orchestration: Use of Dockerfiles in “docker/” and docker-compose for service deployment.
• Event-Driven Processing: The Indexer subscribes to blockchain events and executes the necessary processing routines.
Elements
• Major component (Contracts, Indexer, Web Frontend, Database, CI/CD Pipeline, Docker Containers).
▪ From blockchain events to the indexer.
▪ From the indexer to the database.
▪ From the frontend to the backend (GraphQL API).