# shira98/blockchain-scm architecture

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

- Interactive diagram: https://gitdiagram.com/shira98/blockchain-scm
- Repository: https://github.com/shira98/blockchain-scm

## Overview

##### Main Components
- Frontend Component: Represent the entire "appfrontend" folder which contains the React application. Note key aspects such as:
– Fundamental UI components (many found under "src/components") for features like registration, viewing batch details, and displaying statuses.
– CSS styling and static components that control the user experience.
- Blockchain/Smart Contracts: Represent the "contracts" folder as the core business logic layer written in Solidity. Mention core functionalities related to supply chain management (batch creation, status updates, transaction handling).
- Deployment & Integration Layer: Include the "scripts" folder (specifically "deploy.js") where deployment to a Hardhat network is orchestrated.
- Testing and Simulation: Optionally, show that tests (in "test") validate the contract logic.
- External Services/Dependencies:
– Hardhat blockchain node which the local network (http://127.0.0.1:8545/) represents.
– Wallet integrations (like MetaMask and alternatives such as Coinbase) with browser extensions acting as entry points for users.
- Supporting Artifacts: Include the "images" folder that contains current state images and interface design GIFs, while also noting the configuration files like "hardhat.config.js", package.json files, and GitHub workflows that aid in continuous integration.

##### Relationships and Data Flow
- That once a user takes an action through the UI (e.g., registering or updating a batch), the frontend calls the smart contracts deployed on the Hardhat network.
- Deployment flow: Hardhat compiles the smart contracts and the "deploy.js" script deploys these contracts, then the compiled contract JSON files are stored (or referenced) by the frontend for interaction.

##### Architectural Patterns and Design Principles
- Separation of concerns between frontend and blockchain backend.
- Use of Hardhat for contract management and testing, as well as the integration pattern via React/Ethers.js.
- Modern JavaScript/React architecture, with distinct components for handling both smart contract interaction and UI rendering.

– An annotation on external dependencies such as Node, npm, and wallet providers (MetaMask/Coinbase) linked to the frontend.
- This level of detail not only demonstrates the physical file layout and interaction networks but also the underlying architectural decisions such as separation between presentation, business logic, and deployment processes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Interface
    subgraph "Frontend Interface"
        FE("User Interface (React)"):::frontend
        UIC("UI Components (React)"):::frontend
        Assets("Static Assets & Images"):::frontend
    end

    %% Deployment & Integration Layer
    subgraph "Deployment & Integration Layer"
        Deploy("Hardhat Deployment Script"):::integration
        Config("Hardhat Config"):::integration
    end

    %% Blockchain Network
    subgraph "Blockchain Network"
        Contracts("Smart Contracts (Solidity)"):::blockchain
        Node("Local Blockchain Node\n(http://127.0.0.1:8545)"):::blockchain
        Test("Contract Testing"):::blockchain
    end

    %% External Services
    Wallet("Wallet Integration (MetaMask/Coinbase)"):::external

    %% Connections
    FE -->|"loads"| UIC
    FE -->|"serves"| Assets
    FE -->|"initiatesTx"| Contracts
    Deploy -->|"deploys"| Contracts
    Config -->|"configures"| Contracts
    Contracts -->|"runsOn"| Node
    Test -->|"validates"| Contracts
    FE -->|"connectsVia"| Wallet
    Deploy -->|"updates"| Node

    %% Click Events
    click FE "https://github.com/shira98/blockchain-scm/tree/master/appfrontend"
    click UIC "https://github.com/shira98/blockchain-scm/tree/master/appfrontend/src/components"
    click Assets "https://github.com/shira98/blockchain-scm/tree/master/images"
    click Deploy "https://github.com/shira98/blockchain-scm/blob/master/scripts/deploy.js"
    click Config "https://github.com/shira98/blockchain-scm/blob/master/hardhat.config.js"
    click Contracts "https://github.com/shira98/blockchain-scm/tree/master/contracts"
    click Test "https://github.com/shira98/blockchain-scm/tree/master/test"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef integration fill:#C1FFC1,stroke:#000,stroke-width:1px;
    classDef blockchain fill:#FFE4B5,stroke:#000,stroke-width:1px;
    classDef external fill:#FFD700,stroke:#000,stroke-width:1px;
```
