# instruxi-io/sxt-utils-hardhat architecture

> Architecture diagram of the GitHub repository instruxi-io/sxt-utils-hardhat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/instruxi-io/sxt-utils-hardhat
- Repository: https://github.com/instruxi-io/sxt-utils-hardhat

## Overview

##### Main Components

a) Core Infrastructure Layer:
- Hardhat Development Environment
- Blockchain Networks (Multiple networks supported)
- Space and Time Database
- Security/Authentication Components

b) Project Components:
- Task Management System
- Contract Management
- Business Objects Layer
- Data Management Layer
- Security Artifacts Management

##### Key Relationships to Highlight

- Development workflow
- Deployment pipeline
- Data flow between blockchain and SxT
- Security token management
- Business object interactions

**[Development Environment]**

- [Task System]
- SxT Utils Tasks
- Deployment Tasks
- Contract Management Tasks

- [Contract Layer]
- Smart Contracts
- TypeChain Types
- Contract Factories

- [Business Layer]
- Business Objects (.ejs)
- Schema Definitions
- Table Structures

- [Data Management]
- Insert Operations
- Update Operations
- Delete Operations

- [Security Layer]
- Biscuit Management
- Table Security
- Environment Security

- [External Integrations]
- Blockchain Networks
- Space and Time API

##### Important Elements

a) Infrastructure Components:
- Node.js Runtime
- Hardhat Framework
- Network Providers
- SxT API Endpoints

b) Security Flow:
- Private Key Management
- Biscuit Generation
- Table Security
- Environment Variables

c) Development Flow:
- Schema Initialization
- Business Object Definition
- Table Creation
- Data Management

##### Specific Implementation Details

- The modular nature of the tasks system
- The separation between blockchain and database operations
- The security layer's integration points
- The business object transformation pipeline

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Infrastructure
        HH[Hardhat Environment]:::core
        BN[Blockchain Networks]:::core
        SxT[Space and Time DB]:::core
    end

    subgraph "Task System"
        TMS[Task Management System]:::task
        click TMS "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/tasks"
        SUT[SxT Utils Tasks]:::task
        click SUT "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/tasks/SxTUtils"
        DT[Deployment Tasks]:::task
        click DT "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/tasks/Deployer"
        
        TMS --> SUT
        TMS --> DT
    end

    subgraph "Contract Layer"
        SC[Smart Contracts]:::contract
        click SC "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/contracts"
        TT[TypeChain Types]:::contract
        click TT "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/typechain-types"
        CF[Contract Factories]:::contract
        click CF "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/typechain-types/factories"
        
        SC --> TT
        TT --> CF
    end

    subgraph "Business Layer"
        BO[Business Objects]:::business
        click BO "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/business-objects"
        SD[Schema Definitions]:::business
        TS[Table Structures]:::business
    end

    subgraph "Data Management"
        IO[Insert Operations]:::data
        click IO "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/data/insert"
        UO[Update Operations]:::data
        click UO "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/data/update"
        DO[Delete Operations]:::data
        click DO "https://github.com/instruxi-io/SxT-Utils-Hardhat/tree/main/data/delete"
    end

    subgraph "Security Layer"
        BM[Biscuit Management]:::security
        click BM "https://github.com/instruxi-io/SxT-Utils-Hardhat/blob/main/scripts/makeTableBiscuits.js"
        KM[Key Management]:::security
        click KM "https://github.com/instruxi-io/SxT-Utils-Hardhat/blob/main/scripts/makeEthKeys.ts"
        SU[SxT Security Utils]:::security
        click SU "https://github.com/instruxi-io/SxT-Utils-Hardhat/blob/main/tasks/SxTUtils/Session.ts"
    end

    subgraph "SxT Integration"
        Client[SxT Client]:::integration
        click Client "https://github.com/instruxi-io/SxT-Utils-Hardhat/blob/main/tasks/SxTUtils/Client.ts"
        Schema[Schema Management]:::integration
        click Schema "https://github.com/instruxi-io/SxT-Utils-Hardhat/blob/main/tasks/SxTUtils/Schema.ts"
        Tables[Table Management]:::integration
        click Tables "https://github.com/instruxi-io/SxT-Utils-Hardhat/blob/main/tasks/SxTUtils/Tables.ts"
    end

    Infrastructure --> TMS
    TMS --> SC
    SC --> BO
    BO --> IO
    BO --> UO
    BO --> DO
    BM --> SxT
    KM --> BN
    SU --> SxT
    Client --> SxT
    Schema --> SxT
    Tables --> SxT

    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef task fill:#2ecc71,stroke:#27ae60,color:white
    classDef contract fill:#e74c3c,stroke:#c0392b,color:white
    classDef business fill:#9b59b6,stroke:#8e44ad,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e67e22,stroke:#d35400,color:white
    classDef integration fill:#1abc9c,stroke:#16a085,color:white
```
