# raimah89888/defendodoge architecture

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

- Interactive diagram: https://gitdiagram.com/raimah89888/defendodoge
- Repository: https://github.com/raimah89888/defendodoge

## Overview

##### Project type and purpose
- DefendoDoge is a full-stack Web3 security suite. It consists of:
- A frontend UI (React) for end users
- A backend “api-integration” layer that orchestrates multiple security-scanning services
- A set of smart-contract scripts for deployment and testing
- Example scripts and documentation

##### File structure
- Top-level directories:
- frontend/ – React single-page application
- api-integration/ – Node.js service modules (one per scan-tool)
- smart-contracts/ – Hardhat config and deploy scripts
- examples/ – CLI/demo scripts illustrating each service
- docs/ – Setup guides, API reference, contributing notes
- CI workflow: .github/workflows/main.yaml
- Config files: package.json in frontend & api-integration, hardhat.config.js

##### README for architecture hints
- Mentions six independent scan tools: Token Scanner, NFT Analyzer, DApp Checker, Airdrop Validator, Team & Community Checker, Web3 Phishing Detector
- Implies a modular design: each tool is a micro-library under api-integration/src/services
- Frontend calls backend services via HTTP or RPC; backend communicates with blockchain nodes and external APIs

##### Diagramming the system
a. Main components
1. End User (browser or CLI)
2. Frontend SPA (React)
3. API-Integration layer (Node.js micro-services)
4. Blockchain Network (Ethereum / EVM node providers)
5. External third-party APIs (e.g., Etherscan, OpenSea, community data sources)
6. Smart Contracts (deployed via Hardhat scripts)
7. Examples & CLI interfaces (optional auxiliary clients)

b. Relationships & interactions
- The End User interacts with the Frontend over HTTPS.
- Frontend issues REST/WebSocket calls to the API-Integration server.
- API-Integration dispatches requests to the appropriate service module (e.g., tokenScannerService).
- Each service module:
– Queries on-chain data from a blockchain node provider (Infura, Alchemy, etc.).
– Calls external REST APIs as needed (e.g., NFT marketplaces, social/community APIs).
– Applies business logic (fraud detection, risk scoring).
- For DApp Checker, the service may fetch and analyze smart-contract bytecode (optionally uses locally deployed contracts for testing).
- Smart-Contracts directory holds deployment scripts—these are run by developers via Hardhat; results may be used by both frontend (to display addresses) and backend (for simulation).
- Examples directory demonstrates direct usage of service modules through CLI or language bindings.

c. Architectural patterns & principles
- Modular / microservice-style within api-integration: one service per security function.
- Separation of concerns: UI (frontend), orchestration & business logic (backend), on-chain code (smart contracts).
- Stateless backend services (no persistent DB shown—results computed on the fly).
- CI/CD pipeline defined in GitHub Actions for testing and deployment.

d. Relevant technologies & libraries
- Frontend: React, Webpack or Create React App (index.js, App.js)
- Backend: Node.js, Express or custom HTTP server, web3.js/ethers.js
- Smart Contracts: Hardhat, ethers.js plugin, Solidity
- Examples: JavaScript, Python, Shell scripts
- CI: GitHub Actions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        EndUser["End User (Browser/CLI)"]:::frontend
        subgraph "React Frontend (SPA)"
            direction TB
            RF_pkg["package.json"]:::frontend
            RF_indexHTML["public/index.html"]:::frontend
            RF_App["src/App.js"]:::frontend
            RF_indexJS["src/index.js"]:::frontend
        end
        subgraph "Examples / CLI"
            direction TB
            EX_airdrop["airdrop_validator_example.js"]:::frontend
            EX_dapp["dapp_checker_example.sh"]:::frontend
            EX_nft["nft_analyzer_example.py"]:::frontend
            EX_team["team_community_checker_example.py"]:::frontend
            EX_token["token_scanner_example.js"]:::frontend
            EX_phish["web3_phishing_detector_example.sh"]:::frontend
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        subgraph "API-Integration Gateway"
            direction TB
            API_pkg["package.json"]:::backend
            API_config["src/utils/apiConfig.js"]:::backend
            API_pkg --> API_config
        end
        subgraph "Service Modules"
            direction TB
            SS_token["tokenScannerService"]:::backend
            SS_nft["nftAnalyzerService"]:::backend
            SS_dapp["dappCheckerService"]:::backend
            SS_airdrop["airdropValidatorService"]:::backend
            SS_team["teamCommunityCheckerService"]:::backend
            SS_phish["web3PhishingDetectorService"]:::backend
        end
        API_pkg -->|dispatch| SS_token
        API_pkg -->|dispatch| SS_nft
        API_pkg -->|dispatch| SS_dapp
        API_pkg -->|dispatch| SS_airdrop
        API_pkg -->|dispatch| SS_team
        API_pkg -->|dispatch| SS_phish
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        BC["Blockchain Network (Ethereum/EVM)"]:::infraGrey
        subgraph "External APIs"
            direction TB
            EA1["Etherscan / Alchemy"]:::external
            EA2["OpenSea / NFT Marketplaces"]:::external
            EA3["Community Data APIs"]:::external
        end
        subgraph "Smart Contracts (Hardhat)"
            direction TB
            SC_conf["hardhat.config.js"]:::smart
            SC_deploy["scripts/deploy.js"]:::smart
        end
    end

    %% CI/CD
    CICD["CI/CD (GitHub Actions)"]:::ci

    %% Flows
    EndUser -->|HTTPS| RF_pkg
    EndUser -->|CLI| EX_airdrop
    EndUser -->|CLI| EX_dapp
    EndUser -->|CLI| EX_nft
    EndUser -->|CLI| EX_team
    EndUser -->|CLI| EX_token
    EndUser -->|CLI| EX_phish

    RF_pkg -->|REST/WebSocket| API_pkg
    EX_airdrop -->|uses| API_pkg
    EX_dapp -->|uses| API_pkg
    EX_nft -->|uses| API_pkg
    EX_team -->|uses| API_pkg
    EX_token -->|uses| API_pkg
    EX_phish -->|uses| API_pkg

    SS_token -->|JSON-RPC| BC
    SS_nft -->|JSON-RPC| BC
    SS_dapp -->|JSON-RPC| BC
    SS_airdrop -->|JSON-RPC| BC
    SS_team -->|JSON-RPC| BC
    SS_phish -->|JSON-RPC| BC

    SS_token -->|REST| EA1
    SS_nft -->|REST| EA2
    SS_dapp -->|REST| EA1
    SS_airdrop -->|REST| EA3
    SS_team -->|REST| EA3
    SS_phish -->|REST| EA3

    SC_deploy -->|deploy| BC
    CICD -->|tests & deploy| RF_pkg
    CICD -->|tests & deploy| API_pkg
    CICD -->|runs deploy| SC_deploy

    %% Click Events
    click RF_pkg "https://github.com/raimah89888/defendodoge/blob/main/frontend/package.json"
    click RF_indexHTML "https://github.com/raimah89888/defendodoge/blob/main/frontend/public/index.html"
    click RF_App "https://github.com/raimah89888/defendodoge/blob/main/frontend/src/App.js"
    click RF_indexJS "https://github.com/raimah89888/defendodoge/blob/main/frontend/src/index.js"

    click API_pkg "https://github.com/raimah89888/defendodoge/blob/main/api-integration/package.json"
    click API_config "https://github.com/raimah89888/defendodoge/blob/main/api-integration/src/utils/apiConfig.js"
    click SS_airdrop "https://github.com/raimah89888/defendodoge/blob/main/api-integration/src/services/airdropValidatorService.js"
    click SS_dapp "https://github.com/raimah89888/defendodoge/blob/main/api-integration/src/services/dappCheckerService.js"
    click SS_nft "https://github.com/raimah89888/defendodoge/blob/main/api-integration/src/services/nftAnalyzerService.js"
    click SS_team "https://github.com/raimah89888/defendodoge/blob/main/api-integration/src/services/teamCommunityCheckerService.js"
    click SS_token "https://github.com/raimah89888/defendodoge/blob/main/api-integration/src/services/tokenScannerService.js"
    click SS_phish "https://github.com/raimah89888/defendodoge/blob/main/api-integration/src/services/web3PhishingDetectorService.js"

    click SC_conf "https://github.com/raimah89888/defendodoge/blob/main/smart-contracts/hardhat.config.js"
    click SC_deploy "https://github.com/raimah89888/defendodoge/blob/main/smart-contracts/scripts/deploy.js"

    click EX_airdrop "https://github.com/raimah89888/defendodoge/blob/main/examples/airdrop_validator_example.js"
    click EX_dapp "https://github.com/raimah89888/defendodoge/blob/main/examples/dapp_checker_example.sh"
    click EX_nft "https://github.com/raimah89888/defendodoge/blob/main/examples/nft_analyzer_example.py"
    click EX_team "https://github.com/raimah89888/defendodoge/blob/main/examples/team_community_checker_example.py"
    click EX_token "https://github.com/raimah89888/defendodoge/blob/main/examples/token_scanner_example.js"
    click EX_phish "https://github.com/raimah89888/defendodoge/blob/main/examples/web3_phishing_detector_example.sh"

    click CICD "https://github.com/raimah89888/defendodoge/blob/main/.github/workflows/main.yaml"

    %% Styles
    classDef frontend fill:#cfe2f3,stroke:#034a8f,color:#034a8f;
    classDef backend fill:#d9ead3,stroke:#38761d,color:#274e13;
    classDef infraGrey fill:#e7e6e6,stroke:#5f5f5f,color:#333333;
    classDef external fill:#fce5cd,stroke:#e69138,color:#874e1b;
    classDef smart fill:#ead1dc,stroke:#a64d79,color:#741b47;
    classDef ci fill:#fff2cc,stroke:#bf9000,color:#7f6000;
```
