# christo-kumar/fullstack-solidity-polling architecture

> Architecture diagram of the GitHub repository christo-kumar/fullstack-solidity-polling, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/christo-kumar/fullstack-solidity-polling
- Repository: https://github.com/christo-kumar/fullstack-solidity-polling

## Overview

##### Project type and purpose
- This is a full-stack decentralized polling (voting) application (“FullStack-Solidity-Polling”).
- The frontend is a React single-page application. The “backend” is an Ethereum smart-contract project built with Hardhat (no traditional server).
- Users vote on a single-election ballot via a blockchain contract; all state is persisted on the Ethereum network.

##### File structure
- Top level:
- pollingapp/backend – Hardhat project (contracts, scripts, tests, config).
- pollingapp/frontend – React app (components, public assets, contract wrapper).
- pollingapp/scripts – helper scripts (setup.sh).
- Backend indicators: hardhat.config.js, contracts/, scripts/deploy.js, test/.
- Frontend indicators: package.json, src/, public/, components for AdminPanel and VotingPanel, a contract.js file for web3/ethers configuration.

##### README
- Confirms a full-stack decentralized polling application.
- No additional architecture notes; we infer interactions from file structure.

##### Detail
- Subcomponents: AdminPanel vs. VotingPanel in the UI.
- Where SingleElectionVoting.json (ABI) lives in the frontend.
- Hardhat config file as the bridge between scripts, tests, and the network.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actor
    U["User & Wallet"]:::external

    %% Frontend Layer
    subgraph "Frontend (React)" 
        direction TB
        FEApp["App.js"]:::frontend
        FEIndex["index.js"]:::frontend
        AdminPanel["AdminPanel"]:::frontend
        VotingPanel["VotingPanel"]:::frontend
        ContractAdapter["contract.js"]:::frontend
        PublicAssets["public/"]:::frontend
        ABI["SingleElectionVoting.json (ABI)"]:::frontend
    end

    %% Blockchain Layer
    subgraph "Blockchain (Hardhat / Ethereum)"
        direction TB
        EthereumNode["Ethereum Node (RPC)"]:::blockchain
        Blockchain["Ethereum Blockchain"]:::blockchain
        ContractsDir["contracts/"]:::blockchain
        SmartContract["SingleElectionVoting.sol"]:::blockchain
        HardhatConfig["hardhat.config.js"]:::blockchain
        DeployScript["deploy.js"]:::blockchain
        Tests["SingleElectionVoting.tests.js"]:::blockchain
    end

    %% Helper Scripts
    SetupScript["scripts/setup.sh"]:::external

    %% Connections
    U -->|"interacts"| AdminPanel
    U -->|"interacts"| VotingPanel
    AdminPanel -->|"calls methods via"| ContractAdapter
    VotingPanel -->|"calls methods via"| ContractAdapter
    FEApp -->|"renders panels"| AdminPanel
    FEApp -->|"renders panels"| VotingPanel
    FEIndex -->|"boots app"| FEApp
    ContractAdapter -->|"uses ABI"| ABI
    ContractAdapter -->|"JSON-RPC calls"| EthereumNode
    EthereumNode -->|"transact() / call()"| SmartContract
    SmartContract -->|"emit VoteCast event"| EthereumNode
    EthereumNode -->|"events"| ContractAdapter
    SmartContract -->|"code in"| ContractsDir
    HardhatConfig -->|"configures"| EthereumNode
    DeployScript -->|"deployment TX"| EthereumNode
    Tests -->|"test TXs"| EthereumNode
    SetupScript -->|"sets up env"| HardhatConfig

    %% Persistence
    EthereumNode --> Blockchain

    %% Click Events
    click FEApp "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/frontend/src/App.js"
    click FEIndex "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/frontend/src/index.js"
    click AdminPanel "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/frontend/src/components/AdminPanel.js"
    click VotingPanel "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/frontend/src/components/VotingPanel.js"
    click ContractAdapter "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/frontend/src/contract.js"
    click PublicAssets "https://github.com/christo-kumar/fullstack-solidity-polling/tree/main/pollingapp/frontend/public"
    click ContractsDir "https://github.com/christo-kumar/fullstack-solidity-polling/tree/main/pollingapp/backend/contracts"
    click ABI "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/backend/SingleElectionVoting.json"
    click HardhatConfig "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/backend/hardhat.config.js"
    click DeployScript "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/backend/scripts/deploy.js"
    click Tests "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/backend/test/SingleElectionVoting.tests.js"
    click SetupScript "https://github.com/christo-kumar/fullstack-solidity-polling/blob/main/pollingapp/scripts/setup.sh"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#1B4F72,color:#1B2631;
    classDef blockchain fill:#D5F5E3,stroke:#196F3D,color:#1B2631;
    classDef external fill:#D5D8DC,stroke:#566573,color:#1B2631;
```
