# ayan-banerjee-918/voteblocks-dapp architecture

> Architecture diagram of the GitHub repository ayan-banerjee-918/voteblocks-dapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayan-banerjee-918/voteblocks-dapp
- Repository: https://github.com/ayan-banerjee-918/voteblocks-dapp

## Overview

##### Main Components Identification

a) Frontend Layer (React.js):
- Admin Dashboard
- User Dashboard
- Authentication System
- MetaMask Integration

b) Blockchain Layer:
- Smart Contracts (Polygon Mumbai Testnet)
- Voter Contract

c) Storage Layer:
- IPFS (Infura)

d) External Services:
- Google Authenticator (2FA)
- MetaMask Wallet

##### Component Relationships

- User/Admin → Frontend
- Frontend → MetaMask
- Frontend → Smart Contracts
- Frontend → IPFS

- Frontend → Google Authenticator
- Frontend → MetaMask Authentication

##### Detailed Component Breakdown

For each major component, include sub-components:

Frontend Layer:
- Admin Section
- Election Management
- Candidate Management
- User Validation
- Results View
- User Section
- Vote Casting
- History View
- Results View
- Authentication
- 2FA Integration
- MetaMask Connection

##### Technical Details

Annotations for:
- Smart Contract Address
- IPFS Configuration
- Supported Networks (Polygon Mumbai Testnet)
- Authentication Methods

##### Additional Elements

Include:
- System requirements (MetaMask installation)
- External dependency connections
- Error handling flows
- Data encryption flows

Remember to emphasize the security aspects, particularly around the voting mechanism and 2FA implementation, as these are crucial for a voting system's integrity.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef blockchain fill:#e67e22,stroke:#d35400,color:white
    classDef storage fill:#27ae60,stroke:#219a52,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        AD["Admin Dashboard"]
        UD["User Dashboard"]
        AS["Authentication System"]
        MI["MetaMask Integration"]

        subgraph AdminSection
            EM["Election Management"]
            CM["Candidate Management"]
            UV["User Validation"]
            RV["Results View"]
        end

        subgraph UserSection
            VC["Vote Casting"]
            HV["History View"]
            URV["User Results View"]
        end

        subgraph AuthSystem
            TFA["2FA Integration"]
            MC["MetaMask Connection"]
            AA["Admin Auth"]
            UA["User Auth"]
        end
    end

    %% Blockchain Layer
    subgraph Blockchain
        SC["Smart Contracts"]
        VC_Contract["Voter Contract"]
    end

    %% Storage Layer
    subgraph Storage
        IPFS["IPFS Storage"]
    end

    %% External Services
    subgraph External
        GA["Google Authenticator"]
        MW["MetaMask Wallet"]
    end

    %% Relationships
    AD --> SC
    UD --> SC
    AS --> GA
    MI --> MW
    SC --> IPFS
    VC --> SC
    TFA --> GA
    MC --> MW
    
    %% Component Styling
    class AD,UD,AS,MI,EM,CM,UV,RV,VC,HV,URV,TFA,MC,AA,UA frontend
    class SC,VC_Contract blockchain
    class IPFS storage
    class GA,MW external

    %% Click Events
    click AD "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/tree/main/client/src/Components/Admin/AdminDashComponents/"
    click UD "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/tree/main/client/src/Components/User/UserDashComponents/"
    click AS "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/tree/main/client/src/auth/"
    click MI "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/blob/main/client/src/MetamaskInstall.jsx"
    click SC "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/tree/main/smart_contract/contracts/"
    click VC_Contract "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/blob/main/smart_contract/build/contracts/Voters.json"
    click IPFS "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/tree/main/client/src/ipfs/"
    click TFA "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/tree/main/client/src/2fa/"
    click AA "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/blob/main/client/src/auth/AdminLoginAuth.jsx"
    click UA "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/blob/main/client/src/auth/UserLoginAuth.jsx"
    click EM "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/blob/main/client/src/Components/Admin/AdminDashComponents/AddElections.jsx"
    click CM "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/blob/main/client/src/Components/Admin/AdminDashComponents/AddCandidates.jsx"
    click VC "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/blob/main/client/src/Components/User/UserDashComponents/VoteCast.jsx"
    click RV "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/blob/main/client/src/Components/Admin/AdminDashComponents/ViewResults.jsx"
    click UV "https://github.com/Ayan-Banerjee-918/VoteBlocks-Dapp/blob/main/client/src/Components/Admin/AdminDashComponents/ValidateUsers.jsx"

    %% Legend
    subgraph Legend
        F["Frontend Component"]:::frontend
        B["Blockchain Component"]:::blockchain
        S["Storage Component"]:::storage
        E["External Service"]:::external
    end
```
