# axlabs/grantshares-contracts architecture

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

- Interactive diagram: https://gitdiagram.com/axlabs/grantshares-contracts
- Repository: https://github.com/axlabs/grantshares-contracts

## Overview

- Smart Contracts Layer: This is the core of the application. Within the src/main/java/com/axlabs/neo/grantshares folder you have several key smart contract classes such as:
– GrantSharesGov and GrantSharesGovOld (governance functionality)
– GrantSharesTreasury and GrantSharesTreasuryOld (treasury management)
– Additional components like Intent, Proposal, Paginator, etc.
- Deployment and Configuration Layer: Found under src/deploy, these Java files (Config.java, DeployConfig.java, Deployment.java, Invocations.java) handle contract deployment and configuration. They interface with the blockchain via the neow3j SDK.
- Testing Environment: Located under src/test, which includes various test cases for governance, treasury operations, contract migration, and helper utilities. This validates the behavior of the smart contracts along with test resources that simulate interactions.
- External Systems and Tools:
– Neo N3 Mainnet: The deployed smart contracts interact with the blockchain. Include a representation of the Neo network with pointers to the deployed contracts’ addresses mentioned in the README.
– Build/CI Infrastructure: Gradle (with build.gradle, settings.gradle, gradlew scripts) and the GitHub Actions workflows under .github/workflows define the build, test, and deployment automation.
– Neow3j Devpack: Mark this as an external dependency/framework that enables the smart contract compilation and deployment.

##### Representing Relationships and Data Flow
- Testing Environment to both the Smart Contracts Layer and the Deployment layer, showing that tests simulate various blockchain operations and verify the contracts’ functionalities.
- Interactions between the contracts post-deployment on the Neo N3 mainnet. You might show both read and write operations, as well as invoke routes (e.g., GrantSharesBridgeAdapter is mentioned in the README though not visible in the source tree—it should be noted as an external adapter if applicable).

##### Architectural Patterns and Design Principles
- Separation of Concerns: Notice how the contract logic (src/main) is separated from the deployment scripts (src/deploy) and from the testing code (src/test). This layered approach simplifies maintenance and testing.
- Modularity: The presence of “Old” versions of some contracts (e.g., GrantSharesGovOld) suggests an iterative development strategy and backward compatibility considerations.
- Integration with CI/CD: With GitHub Actions workflows provided in .github/workflows, indicate how continuous integration is a key design principle that ensures reliable deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Smart Contracts Layer
    subgraph "Smart Contracts Layer"
        GS1["GrantSharesGov Contract"]:::smart
        GS2["GrantSharesGovOld Contract"]:::smart
        TS1["GrantSharesTreasury Contract"]:::smart
        TS2["GrantSharesTreasuryOld Contract"]:::smart
        INT["Intent Contract"]:::smart
        PAG["Paginator Contract"]:::smart
        PROP["Proposal Contract"]:::smart
    end

    %% Deployment and Configuration Layer
    subgraph "Deployment and Configuration Layer"
        DS["Deployment Scripts"]:::deploy
        DR["Deployment Resources"]:::deploy
    end

    %% Testing Environment
    subgraph "Testing Environment"
        TST["Test Suite"]:::test
        TU["Test Utilities"]:::test
        TR["Test Resources"]:::test
    end

    %% Build/CI Infrastructure
    subgraph "Build/CI Infrastructure"
        CI["CI/CD Workflows"]:::ci
        GB["Gradle Build System"]:::ci
        GW["Gradle Wrapper"]:::ci
    end

    %% External Systems
    NN["Neo N3 Mainnet"]:::external
    NW["Neow3j Devpack"]:::external

    %% Relationships
    GB -->|"builds"| DS
    GB -->|"builds"| TST
    CI -->|"deploys"| DS
    CI -->|"tests"| TST
    DS -->|"deploys"| GS1
    DS -->|"deploys"| GS2
    DS -->|"deploys"| TS1
    DS -->|"deploys"| TS2
    DS -->|"deploys"| INT
    DS -->|"deploys"| PAG
    DS -->|"deploys"| PROP
    TST -->|"tests"| GS1
    TST -->|"tests"| GS2
    TST -->|"tests"| TS1
    TST -->|"tests"| TS2
    TST -->|"tests"| INT
    TST -->|"tests"| PAG
    TST -->|"tests"| PROP
    NW -->|"supports"| DS
    NW -->|"supports"| GS1
    GS1 <-->|"interacts"| NN

    %% Styles
    classDef smart fill:#ffe6e6,stroke:#b30000,stroke-width:2px;
    classDef deploy fill:#e6f7ff,stroke:#005c99,stroke-width:2px;
    classDef test fill:#e6ffe6,stroke:#339933,stroke-width:2px;
    classDef ci fill:#fff2e6,stroke:#cc6600,stroke-width:2px;
    classDef external fill:#f2e6ff,stroke:#6600cc,stroke-width:2px;

    %% Click Events for Smart Contracts
    click GS1 "https://github.com/axlabs/grantshares-contracts/blob/main/src/main/java/com/axlabs/neo/grantshares/GrantSharesGov.java"
    click GS2 "https://github.com/axlabs/grantshares-contracts/blob/main/src/main/java/com/axlabs/neo/grantshares/GrantSharesGovOld.java"
    click TS1 "https://github.com/axlabs/grantshares-contracts/blob/main/src/main/java/com/axlabs/neo/grantshares/GrantSharesTreasury.java"
    click TS2 "https://github.com/axlabs/grantshares-contracts/blob/main/src/main/java/com/axlabs/neo/grantshares/GrantSharesTreasuryOld.java"
    click INT "https://github.com/axlabs/grantshares-contracts/blob/main/src/main/java/com/axlabs/neo/grantshares/Intent.java"
    click PAG "https://github.com/axlabs/grantshares-contracts/blob/main/src/main/java/com/axlabs/neo/grantshares/Paginator.java"
    click PROP "https://github.com/axlabs/grantshares-contracts/blob/main/src/main/java/com/axlabs/neo/grantshares/Proposal.java"

    %% Click Events for Deployment and Configuration
    click DS "https://github.com/axlabs/grantshares-contracts/tree/main/src/deploy/java/com/axlabs/neo/grantshares"
    click DR "https://github.com/axlabs/grantshares-contracts/blob/main/src/deploy/resources/dev.deploy.properties"

    %% Click Events for Testing Environment
    click TST "https://github.com/axlabs/grantshares-contracts/tree/main/src/test/java/com/axlabs/neo/grantshares"
    click TU "https://github.com/axlabs/grantshares-contracts/tree/main/src/test/java/com/axlabs/neo/grantshares/util"
    click TR "https://github.com/axlabs/grantshares-contracts/tree/main/src/test/resources"

    %% Click Events for Build/CI Infrastructure
    click CI "https://github.com/axlabs/grantshares-contracts/tree/main/.github/workflows"
    click GB "https://github.com/axlabs/grantshares-contracts/blob/main/build.gradle"
    click GW "https://github.com/axlabs/grantshares-contracts/tree/main/gradle/wrapper"
```
