# x302502/nftfeed-contracts architecture

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

- Interactive diagram: https://gitdiagram.com/x302502/nftfeed-contracts
- Repository: https://github.com/x302502/nftfeed-contracts

## Overview

##### Main Components
a. Smart Contracts Layer:
- Contracts directory as the “Core Smart Contracts Module”. Note that it contains submodules such as common utilities, interfaces, and libraries.
- That these contracts implement the NFT minting logic and serve as the backbone of the service.

b. Deployment & Configuration Scripts:
- From the “scripts” directory, highlight the different deployment scripts for features such as “free-mint-factory”, “stake-nft-factory”, “feed-agg”, “feed-vault”, and others.
- @config folder where environment settings for different chains (e.g., arbitrumMainnet.ts, bscTestnet.ts, etc.) are maintained.
- Auxiliary helper scripts (like log.helper.ts and block-chain.helper.ts) that support the deployment and configuration process.

c. Environment Configuration:

d. Testing Suite:
- Incorporate the “test” directory indicating that there is a layer for verifying the integrity and behavior of these contracts.

e. Integration with External Services:

##### Relationships and Data Flow
- A feedback loop from the test suite to the contracts layer to indicate continuous testing/verification.

##### Architectural Patterns and Design Principles
- This design leverages modularization by separating smart contract code from deployment scripts and further splitting the configuration per target blockchain.
- The project follows a pattern common to blockchain development with clearly delineated modules for deployment, verification, parameter configuration, and testing.
- Reusability—notice that several factories (e.g., MINT_NFT_FACTORY and MINT_NFT_FACTORY_V2) are deployed across different networks with similar underlying logic.

##### Technologies and Frameworks
- Hardhat: For smart contract compilation, deployment, and testing.
- TypeScript: Evident from the .ts file extensions (hardhat.config.ts, various deployment scripts, and helper files).
- Solidity (implied by the contracts folder and typical naming conventions in smart contract development).
- Node.js and NPM: Due to the presence of package.json and other scripts used for orchestration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Environment and Helpers
    EnvConfig["Environment Config"]:::config
    Helpers["Helper Scripts"]:::config

    %% Deployment Engine Node receiving configuration and helper support
    EnvConfig -->|"configures"| DE
    Helpers -->|"supports"| DE

    %% Deployment Scripts Subgraph
    subgraph "Deployment Scripts"
        DE("Deployment Engine"):::deployment
        D1("Free Mint Factory v1"):::deploymentDetail
        D2("Free Mint Factory v2"):::deploymentDetail
        D3("Social Vault"):::deploymentDetail
        D4("Feed Aggregator"):::deploymentDetail
        D5("Feed Vault"):::deploymentDetail
        D6("Stake NFT Factory"):::deploymentDetail
        D7("Stake NFT Auto Apy"):::deploymentDetail
        D8("Stake Multiple ERC721"):::deploymentDetail
        D9("Presale Fair Launch Factory"):::deploymentDetail
        D10("Token Factory v1"):::deploymentDetail
        D11("Token Factory v2"):::deploymentDetail

        DE --> D1
        DE --> D2
        DE --> D3
        DE --> D4
        DE --> D5
        DE --> D6
        DE --> D7
        DE --> D8
        DE --> D9
        DE --> D10
        DE --> D11
    end

    %% Core Smart Contracts Module
    SC["Core Smart Contracts Module"]:::contracts

    %% Testing Suite
    TS("Testing Suite"):::testing

    %% Blockchain Networks Subgraph
    subgraph "Blockchain Networks"
        BN1("Ethereum"):::chain
        BN2("Optimism"):::chain
        BN3("Base"):::chain
        BN4("Arbitrum"):::chain
        BN5("Polygon"):::chain
        BN6("AVAX"):::chain
    end

    %% Relationships
    DE -->|"deploys"| SC
    DE -->|"deploysTo"| BN1
    DE -->|"deploysTo"| BN2
    DE -->|"deploysTo"| BN3
    DE -->|"deploysTo"| BN4
    DE -->|"deploysTo"| BN5
    DE -->|"deploysTo"| BN6

    TS -->|"verifies"| SC
    SC -->|"feedback"| TS

    %% Click Events
    click SC "https://github.com/x302502/nftfeed-contracts/tree/main/contracts"
    click D1 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/free-mint-factory"
    click D2 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/free-mint-factory-v2"
    click D3 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/social-vault"
    click D4 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/feed-agg"
    click D5 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/feed-vault"
    click D6 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/stake-nft-factory"
    click D7 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/stake-nft-auto-apy"
    click D8 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/stake-multiple-erc721"
    click D9 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/presale-fair-launch-factory-v1"
    click D10 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/token-factory-v1"
    click D11 "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/token-factory-v2"
    click EnvConfig "https://github.com/x302502/nftfeed-contracts/blob/main/env-config.ts"
    click Helpers "https://github.com/x302502/nftfeed-contracts/tree/main/scripts/@helpers"
    click TS "https://github.com/x302502/nftfeed-contracts/tree/main/test"

    %% Styles
    classDef config fill:#CCF,stroke:#333,stroke-width:2px;
    classDef deployment fill:#FCD,stroke:#333,stroke-width:2px;
    classDef deploymentDetail fill:#F99,stroke:#333,stroke-width:2px;
    classDef contracts fill:#9F9,stroke:#333,stroke-width:2px;
    classDef testing fill:#FFD,stroke:#333,stroke-width:2px;
    classDef chain fill:#CFF,stroke:#333,stroke-width:2px;
```
