# swrjsingh/eth24submission architecture

> Architecture diagram of the GitHub repository swrjsingh/eth24submission, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/swrjsingh/eth24submission
- Repository: https://github.com/swrjsingh/eth24submission

## Overview

##### Main Components Identification
- Backend / Smart Contracts Module:
- Located in the “packages/hardhat” directory.
- Contains smart contract code (in Solidity), deployment scripts (deploy directory with various deployment scripts), tests, and configuration files (hardhat.config.ts, tsconfig.json).
- Includes CI/CD configurations (e.g., .github/workflows/lint.yaml) and other project-wide config files.
- Frontend Module:
- Located in “packages/nextjs.”
- A Next.js application structured with multiple pages and components (organized under “app”, “components”, “hooks”, “services” etc.).
- Uses various frontend libraries and integrations such as Scaffold-ETH components, wallet connectors (MetaMask, Coinbase), and a dedicated blockexplorer and event management interface.
- External Dependencies & Integrations:
- Blockchain network: Polygon zkEVM/Amoy (for live deployment and testing).
- Wallet Providers: MetaMask and Coinbase wallets used for role-based authentication.
- Zero-Knowledge Proof Tools: Integrations with tools like Circom and Snark.js for generating and validating zkProofs.
- Deployment and build tools: Yarn, Hardhat, and Next.js development server.

##### Relationships and Interactions
- End Users (Organizers & Buyers):
- Access the frontend (Next.js app) where they authenticate using wallet providers.
- Frontend (Next.js):
- Interacts with smart contracts on the blockchain via connected wallet protocols and services (using scaffolding libraries, hooks for wallet interactions, and custom services like “web3” in the “services” folder).
- Manages event data, provides UI for creating events, viewing tickets, and debugging transactions.
- Smart Contracts / Blockchain Layer (Hardhat):
- The smart contracts govern event creation, ticket issuance (minting NFTs), and verification (using zkProofs).
- Deployed using scripts in “deploy” with interactions logged and managed (deployment artifacts stored in deployments folder).
- External Services:
- Zero-Knowledge Proof generation and validation plugins.
- CI/CD pipelines to ensure code quality and deployment readiness via GitHub workflows.

##### Architectural Patterns and Design Decisions
- Monorepo structure: The project is integrated as a single repository with separate packages for backend (blockchain contracts) and frontend application.
- Separation of Concerns: Smart contract code is decoupled in its dedicated package while the Next.js frontend handles all user interactions.
- Use of Modern Tooling: Leveraging Hardhat for blockchain development, Next.js for a performant React-based frontend, and scaffold libraries (like Scaffold-ETH2) to simplify complex blockchain interactions.

- Make annotations that call out critical elements, for instance the “zkProof Generation” component and wallet integrations.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interaction
    U("End Users"):::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        F("Next.js Frontend"):::frontend
        FE("Event Management UI"):::frontend
        WS("Wallet & Blockchain Services"):::frontend
        SH("Scaffold-ETH Hooks"):::frontend
        ZK("Zero-Knowledge Proof Engine"):::zk
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B("Smart Contracts Module"):::backend
        DS("Deployment Scripts"):::backend
        T("Smart Contract Tests"):::backend
    end

    %% External Services
    subgraph "External Services"
        BN("Blockchain Network (Polygon zkEVM)"):::external
        WP("Wallet Providers (MetaMask/Coinbase)"):::external
        CD("CI/CD Pipeline"):::external
    end

    %% Data Flow Connections
    U -->|"Authenticates"| WS
    U -->|"Accesses"| FE

    F -->|"Renders UI"| FE
    FE -->|"Calls services"| WS
    WS -->|"Invokes contracts"| B
    SH -->|"Enhances blockchain calls"| WS
    ZK -->|"Verifies transactions"| B

    B -->|"Deployed via"| DS
    B -->|"Tested by"| T
    B -->|"Interacts with"| BN

    WS -->|"Submits transactions"| BN

    CD -->|"Deploys/Tests"| B
    CD -->|"Builds Frontend"| F

    WP -->|"Supports connection"| WS

    %% Click Events
    click B "https://github.com/swrjsingh/eth24submission/tree/main/packages/hardhat"
    click DS "https://github.com/swrjsingh/eth24submission/tree/main/packages/hardhat/deploy"
    click T "https://github.com/swrjsingh/eth24submission/tree/main/packages/hardhat/test"
    click CD "https://github.com/swrjsingh/eth24submission/blob/main/.github/workflows/lint.yaml"
    click F "https://github.com/swrjsingh/eth24submission/tree/main/packages/nextjs"
    click FE "https://github.com/swrjsingh/eth24submission/tree/main/packages/nextjs/app"
    click WS "https://github.com/swrjsingh/eth24submission/tree/main/packages/nextjs/services/web3"
    click SH "https://github.com/swrjsingh/eth24submission/tree/main/packages/nextjs/hooks/scaffold-eth"
    click ZK "https://github.com/swrjsingh/eth24submission/tree/main/packages/nextjs/public/zkey"

    %% Styles
    classDef user fill:#E3F2FD,stroke:#2196F3,stroke-width:2px;
    classDef frontend fill:#B8D4FF,stroke:#1F78C1,stroke-width:2px;
    classDef backend fill:#FFD2A6,stroke:#D2691E,stroke-width:2px;
    classDef external fill:#C9F1DF,stroke:#2E8B57,stroke-width:2px;
    classDef zk fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
```
