# democracyearth/wallet architecture

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

- Interactive diagram: https://gitdiagram.com/democracyearth/wallet
- Repository: https://github.com/democracyearth/wallet

## Overview

##### Project type and purpose
- This is a single-page decentralized application (“dapp”) built in React that provides a UI for interacting with Ethereum-based governance smart contracts (MolochDAO, ERC20/721, Chainlink oracles).
- It is a front-end only repository: no Node/Express backend. Instead it relies on Web3.js, The Graph Protocol, Ethereum nodes (e.g. Infura), and IPFS for hosting.

##### File structure
- Top level:
- public/ – static HTML, manifest, and robots.txt (serves index.html for the React app).
- src/ – all client code
- docs/ – images and screenshots for marketing
- src/components/ – UI building blocks (Account, Browser, DAO, Dapp, Contract, etc.).
- src/lib/ – Web3 utilities, ABIs, contract-address constants, helpers for interacting with Ethereum.
- src/utils/ – analytics, string/date helpers.
- src/lang/ – internationalization JSON.
- src/styles/ – vanilla CSS.
- config files: jsconfig.json, package.json, .env for environment variables (e.g. INFURA_KEY).

##### README for additional insights
- Confirms that Web3.js and The Graph Protocol drive data reads and writes.
- Mentions deployment targets: IPFS, Ethereum mainnet/testnets.
- Notes support for ERC20, ERC721, MolochDAO, Chainlink price oracles.

##### Detail
- Break out major component groups: UI/Components, Lib/Web3, Language, Styles.
- External dependencies like MetaMask and analytics endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        style PresentationLayer fill:none,stroke:none
        IndexHTML["public/index.html"]:::frontend
        SPA["React SPA"]:::frontend
        UI["UI Components"]:::frontend
        LibWeb3Module["Web3 Provider Module"]:::frontend
        ABIsSubgraph["Smart Contract ABIs"]:::frontend
        Utils["Helpers & Utilities"]:::frontend
        I18n["Internationalization"]:::frontend
        Styles["Styles & Theming"]:::frontend
        QueriesSubgraph["GraphQL Queries"]:::frontend
    end

    %% ABIs
    subgraph " "
        Erc20["erc20.js"]:::abi
        Moloch["moloch.js"]:::abi
        ProofHumanity["proofOfHumanity.json"]:::abi
        ChainlinkDAI["chainlink-daiprice-abi.js"]:::abi
        ChainlinkWETH["chainlink-wethprice-abi.js"]:::abi
        UBIDAI["ubidai-abi.js"]:::abi
        UBIWETH["ubiweth-abi.js"]:::abi
    end

    %% Queries
    subgraph " "
        MenuQ["Menu/queries.js"]:::query
        TimelineQ["Timeline/queries.js"]:::query
        VoteQ["Vote/queries.js"]:::query
    end

    %% Data Layer
    subgraph "Data Layer"
        RPC["MetaMask / Infura RPC"]:::backend
        GraphAPI["The Graph API"]:::offchain
    end

    %% Storage & Execution
    subgraph "Storage & Execution"
        Ethereum["Ethereum Network"]:::db
        IPFS["IPFS / CDN"]:::offchain
    end

    %% External Services
    Analytics["Analytics Endpoint"]:::external

    %% Build Pipeline
    Build["Build Pipeline"]:::tool

    %% Relationships
    IndexHTML -->|loads| SPA
    SPA -->|"JSON-RPC over HTTPS"| RPC
    RPC -->|transactions| Ethereum
    Ethereum -->|tx receipts| RPC
    SPA -->|GraphQL query| GraphAPI
    GraphAPI -->|GraphQL response| SPA
    Ethereum -->|events| GraphAPI
    IPFS -->|HTTP GET static assets| IndexHTML
    Build -->|deploy| IPFS
    SPA -->|"POST event"| Analytics

    %% ABI relationships
    SPA --> ABIsSubgraph
    ABIsSubgraph --> Erc20
    ABIsSubgraph --> Moloch
    ABIsSubgraph --> ProofHumanity
    ABIsSubgraph --> ChainlinkDAI
    ABIsSubgraph --> ChainlinkWETH
    ABIsSubgraph --> UBIDAI
    ABIsSubgraph --> UBIWETH

    %% Queries relationships
    SPA --> QueriesSubgraph
    QueriesSubgraph --> MenuQ
    QueriesSubgraph --> TimelineQ
    QueriesSubgraph --> VoteQ

    %% Other modules
    SPA --> UI
    SPA --> LibWeb3Module
    SPA --> Utils
    SPA --> I18n
    SPA --> Styles

    %% Click Events
    click SPA "https://github.com/democracyearth/wallet/blob/master/src/index.js"
    click IndexHTML "https://github.com/democracyearth/wallet/blob/master/public/index.html"
    click UI "https://github.com/democracyearth/wallet/tree/master/src/components/"
    click LibWeb3Module "https://github.com/democracyearth/wallet/blob/master/src/lib/web3.js"
    click ABIsSubgraph "https://github.com/democracyearth/wallet/tree/master/src/lib/abi/"
    click Erc20 "https://github.com/democracyearth/wallet/blob/master/src/lib/abi/erc20.js"
    click Moloch "https://github.com/democracyearth/wallet/blob/master/src/lib/abi/moloch.js"
    click ProofHumanity "https://github.com/democracyearth/wallet/blob/master/src/lib/abi/proofOfHumanity.json"
    click ChainlinkDAI "https://github.com/democracyearth/wallet/blob/master/src/components/Vault/chainlink-daiprice-abi.js"
    click ChainlinkWETH "https://github.com/democracyearth/wallet/blob/master/src/components/Vault/chainlink-wethprice-abi.js"
    click UBIDAI "https://github.com/democracyearth/wallet/blob/master/src/components/Vault/ubidai-abi.js"
    click UBIWETH "https://github.com/democracyearth/wallet/blob/master/src/components/Vault/ubiweth-abi.js"
    click MenuQ "https://github.com/democracyearth/wallet/blob/master/src/components/Menu/queries.js"
    click TimelineQ "https://github.com/democracyearth/wallet/blob/master/src/components/Timeline/queries.js"
    click VoteQ "https://github.com/democracyearth/wallet/blob/master/src/components/Vote/queries.js"
    click Utils "https://github.com/democracyearth/wallet/blob/master/src/lib/utils.js"
    click UtilsConst "https://github.com/democracyearth/wallet/blob/master/src/lib/const.js"
    click Contracts "https://github.com/democracyearth/wallet/blob/master/src/lib/contracts.js"
    click Analytics "https://github.com/democracyearth/wallet/blob/master/src/utils/Analytics.jsx"
    click Chronos "https://github.com/democracyearth/wallet/blob/master/src/utils/chronos.js"
    click Strings "https://github.com/democracyearth/wallet/blob/master/src/utils/strings.js"
    click I18n "https://github.com/democracyearth/wallet/blob/master/src/i18n.js"
    click Lang "https://github.com/democracyearth/wallet/blob/master/src/lang/en.json"
    click Styles "https://github.com/democracyearth/wallet/blob/master/src/styles/Dapp.css"
    click Material "https://github.com/democracyearth/wallet/blob/master/src/styles/material.css"
    click Palette "https://github.com/democracyearth/wallet/blob/master/src/components/Token/palette.js"
    click Config "https://github.com/democracyearth/wallet/blob/master/src/config.js"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#02539B,color:#02539B
    classDef backend fill:#DFF7D0,stroke:#2E7D32,color:#2E7D32
    classDef db fill:#D0FFD6,stroke:#1B5E20,color:#1B5E20,stroke-dasharray: 5 5
    classDef offchain fill:#FFE7C0,stroke:#E65100,color:#E65100
    classDef external fill:#E0E0E0,stroke:#424242,color:#424242
    classDef tool fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A
    classDef abi fill:#E8F0FE,stroke:#1A73E8,color:#1A73E8
    classDef query fill:#FFF4E5,stroke:#FB8C00,color:#FB8C00
```
