How easonchai/proof-of-interaction works
Project Type and Purpose
• This repository is a full-stack blockchain-integrated project with three core segments: a Frontend (built using Next.js and React), a Backend (using NestJS with modules for oracles, validation, and Prisma for database access), and a Smart Contracts suite managed via Hardhat.
• As explained in the README, the solution implements “Proof of Interaction” where off-chain interactions are signed, stored on-chain, and then verified via oracle mechanisms. It targets use cases like event participation, rewards, and trustless verification.
High-Level Architecture Components
• Frontend:
• Built with Next.js (evidenced by next.config.js, React components in the src directory, and Tailwind CSS configuration).
• Provides interactive user interfaces (pages, modals, components) that allow users to sign transactions and view real time data.
• Handles API calls (e.g., from files in src/apis, axios utilities) to interact with the backend.
• Backend:
• A Node.js service using NestJS (as seen in files like app.module.ts, main.ts, and multiple module directories including oracle and validation).
• Integrates with a database via Prisma (with schema and migration files in the prisma folder).
• Contains business logic to facilitate the storage of signed interactions, verification via oracles (Oracle.ts implementations), and validation of user-submitted data.
• Containerized using Docker (Dockerfile and docker-compose configurations are present).
• Smart Contracts:
• Managed in the smart-contracts folder. Uses Hardhat for deployment (hardhat.config.ts) and includes Solidity contracts under contracts directories.
• Contains scripts and tests to deploy and validate core blockchain logic (e.g., handling ProofOfInteraction logic and oracle behavior).
• Acts as the decentralized mechanism where interactions are recorded and verified on-chain.
Relationships and Interactions
• Users interact with the Frontend which sends API requests to the Backend.
• The Backend processes these requests, interacts with the database (using Prisma) for off-chain data management, and calls out to Smart Contracts for recording the signed interactions on the blockchain.
• The smart contracts (deployed on Ethereum or a testnet) interact with external oracles (also implemented in both backend modules and contract interfaces) to verify data integrity.
Architectural Patterns and Key Technologies
• Separation of Concerns / Modular Architecture: The division into frontend, backend (with distinct modules for validation, oracle functions, and database interactions), and blockchain components is key.
• Containerization: The use of Docker implies that the backend deployment is containerized, which might be represented as a separate deployment unit.
• Blockchain-Oriented Design: Smart contract interactions, oracle verification, and the signature-based proofing mechanism underpin the design.
• Relevant libraries & frameworks include NestJS (backend), Prisma (ORM), Next.js/React (frontend), and Hardhat (smart contract development).
• Frontend:
• Components such as pages, API utilities, and UI components.
• How it interacts with backend APIs.
• Backend:
• Configuration files, testing, and middleware.
• How the API server handles incoming requests and orchestrates smart contract interactions.
• Smart Contracts:
• Core contracts (ProofOfInteraction, Oracle) and any scripts used to deploy them.
• Testing flow in the smart-contracts/test directory.
• Infrastructure:
• Optionally, indicate Docker as a deployment container for the backend.
• Interconnections with Ethereum networks (based on the proof mechanism described).