# thomasheim11/tickettoken architecture

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

- Interactive diagram: https://gitdiagram.com/thomasheim11/tickettoken
- Repository: https://github.com/thomasheim11/tickettoken

## Overview

Based on your project’s file structure and the details in the README, this is a decentralized ticket marketplace built on Ethereum using an ERC721 smart contract. The project contains two main components:

1. A smart contract layer (under the contracts directory, Hardhat configuration, deployment scripts, and tests).
2. A React-based frontend (under the src and public directories) that interacts with the blockchain through the deployed smart contract.

##### Main Components
- Smart Contract Layer:
- Contracts: Your Solidity contracts (in the contracts folder) implementing the ERC721 ticket logic.
- Deployment & Testing: Hardhat setup (hardhat.config.js, scripts/deploy.js, and tests) for deploying and testing the contracts.
- Frontend Layer:
- React Application: All UI components (src folder with App.js and components like Navigation, SeatChart, etc.), assets, and configuration.
- Interaction with Contracts: The ABI for the TicketToken (src/abis/TicketToken.json) and config files that facilitate communication with the blockchain.

##### Relationships and Interactions
- User Interactions (through the browser) occur via the React frontend.
- The frontend communicates with the smart contracts using a Web3 provider (injected by wallets like MetaMask) to interact with the blockchain.
- Deployment scripts and Hardhat testing are used in the development flow to deploy the smart contract on a local blockchain node and test networks (like Sepolia) before going live.
- The system depends on external Ethereum nodes (Sepolia testnet) and, optionally, services like Alchemy to access the blockchain.

##### Architectural Patterns & Important Elements
- Separation of Concerns: The architecture clearly separates the presentation layer (React) from the blockchain logic (smart contract).
- Decentralization: Smart contracts are immutable and deployed on Ethereum, ensuring a trustless system for ticket management.
- CI/CD Elements: Although not directly indicated, the presence of scripts, tests, and deployment instructions suggests an integrated deployment and testing pipeline.
- Use of Standard Technologies: Hardhat for smart contract development, React for the frontend, and ERC721 for NFT ticketization.

##### Additional Practical Details
- A note or a side element for “Testing” that uses unit tests (inside the test directory) to ensure smart contract correctness.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level
    User["User"]:::user

    External_Services["External Services (MetaMask & RPC Provider)"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        React_App["React Application (App.js & Components)"]:::frontend
        Contract_ABI["Contract ABI (TicketToken.json)"]:::frontend
        Public_Files["Public Files (index.html, manifest.json, robots.txt)"]:::frontend
    end

    %% Smart Contract Layer
    subgraph "Smart Contract Layer"
        TicketToken["ERC721 TicketToken Contract"]:::contract
        subgraph "Deployment & Testing Tools"
            Hardhat_Config["Hardhat Config (hardhat.config.js)"]:::deployment
            Deploy_Script["Deployment Script (scripts/deploy.js)"]:::deployment
            Contract_Tests["Contract Tests (test/TicketToken.js)"]:::deployment
        end
    end

    %% Blockchain Node
    Blockchain["Ethereum Sepolia Testnet"]:::blockchain

    %% Relationships
    User -->|"interacts"| React_App
    External_Services -->|"injects web3"| React_App

    React_App -->|"uses ABI"| Contract_ABI
    Contract_ABI -->|"calls"| TicketToken

    TicketToken -->|"logs state"| Blockchain

    Deploy_Script -->|"deploys to"| Blockchain
    Hardhat_Config -->|"configures"| Blockchain
    Contract_Tests -->|"tests against"| Blockchain

    %% Styles
    classDef user fill:#ffeb3b,stroke:#333,stroke-width:2px;
    classDef frontend fill:#aed581,stroke:#333,stroke-width:2px;
    classDef contract fill:#4fc3f7,stroke:#333,stroke-width:2px;
    classDef deployment fill:#ffab91,stroke:#333,stroke-width:2px;
    classDef blockchain fill:#ef9a9a,stroke:#333,stroke-width:2px;
    classDef external fill:#ce93d8,stroke:#333,stroke-width:2px;

    %% Click Events
    click TicketToken "https://github.com/thomasheim11/tickettoken/tree/main/contracts"
    click Hardhat_Config "https://github.com/thomasheim11/tickettoken/blob/main/hardhat.config.js"
    click Deploy_Script "https://github.com/thomasheim11/tickettoken/blob/main/scripts/deploy.js"
    click Contract_Tests "https://github.com/thomasheim11/tickettoken/blob/main/test/TicketToken.js"
    click React_App "https://github.com/thomasheim11/tickettoken/tree/main/src"
    click Public_Files "https://github.com/thomasheim11/tickettoken/tree/main/public"
    click Contract_ABI "https://github.com/thomasheim11/tickettoken/blob/main/src/abis/TicketToken.json"
```
