# fouuuadi/blockchain_auto architecture

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

- Interactive diagram: https://gitdiagram.com/fouuuadi/blockchain_auto
- Repository: https://github.com/fouuuadi/blockchain_auto

## Overview

##### Main Components
- Frontend – Located under the "blockchain_app" directory. This is a Next.js application (as indicated by files such as next.config.ts, package.json, tsconfig.json, and the app directory structure) that likely handles user interactions, UI rendering, and integration with the blockchain.
- Smart Contracts – Managed under “artifacts” and possibly “ignition/deployments” directories. The "artifacts" folder holds compiled contract data (including OpenZeppelin contracts) and build info, showing that the project relies on audited contract libraries. The "ignition" directory contains deployment configurations, modules (e.g., Hetic.ts), deployed addresses, and journals that log blockchain interactions.
- Deployment & Environment Artifacts – Files and folders like "cache" and "ignition" indicate usage of development tools (possibly Hardhat) to deploy and test smart contracts on local blockchain instances (e.g., chain-31337).

##### Relationships & Interactions
- The backend of blockchain operations is carried out by smart contracts. These contracts are responsible for business logic such as validating transactions, registering car purchases, etc. The front-end sends requests (or transactions) that update or retrieve information from these contracts.

##### Architectural Patterns & Key Design Principles
- Separation of Concerns – Clearly separate the UI application (client logic) from the blockchain backend (smart contracts).
- Reusability & Security – Use of OpenZeppelin libraries (as seen in the artifacts folder) demonstrates adherence to modern security practices in smart contract development.
- Deployment & Environment Isolation – The existence of caches and deployment logs suggests the use of isolated blockchain instances (e.g., local Hardhat networks) for testing purposes. This is an important part of the development and testing lifecycle.

##### Including Relevant Technologies
- Next.js (TypeScript-based) for the UI (inside the "blockchain_app" folder).
- Solidity smart contracts, constructed with support tools like Hardhat (indicated by the artifacts, cache, and ignition folders).
- OpenZeppelin contracts integrated into the codebase for secure token or contract operations.
- Deployment tools and scripts that are part of the ignition folder (including deployment journals, build-info, and module definitions).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User & Frontend Layer
    subgraph "User & Frontend"
        U("User"):::external
        FE("Next.js Frontend"):::ui
    end

    %% Blockchain Interaction Layer
    subgraph "Blockchain Interaction Layer"
        API("Blockchain Interaction API"):::interaction
    end

    %% Smart Contracts Layer
    subgraph "Smart Contracts Layer"
        SC("Smart Contracts (Solidity)"):::contracts
    end

    %% Deployment & Environment Layer
    subgraph "Deployment & Environment"
        DM1("Deployment Scripts"):::deployment
        DM2("Hetic Module"):::deployment
        BN("Local Blockchain Network (Hardhat)"):::network
    end

    %% Connections
    U -->|"initiates"| FE
    FE -->|"sendsTransaction"| API
    API -->|"callsContract"| SC
    SC -->|"returnsConfirmation"| API
    SC -->|"triggerDeployment"| DM1
    DM1 -->|"includesModule"| DM2
    DM1 -->|"deploysTo"| BN
    BN -->|"notifies"| FE

    %% Click Events
    click FE "https://github.com/fouuuadi/blockchain_auto/tree/main/blockchain_app/"
    click SC "https://github.com/fouuuadi/blockchain_auto/tree/main/artifacts/"
    click DM1 "https://github.com/fouuuadi/blockchain_auto/tree/main/ignition/deployments/chain-31337/"
    click DM2 "https://github.com/fouuuadi/blockchain_auto/blob/main/ignition/modules/Hetic.ts"
    click BN "https://github.com/fouuuadi/blockchain_auto/tree/main/cache/"

    %% Styles
    classDef external fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef ui fill:#B0E0E6,stroke:#333,stroke-width:2px;
    classDef interaction fill:#E7E7E7,stroke:#333,stroke-width:2px;
    classDef contracts fill:#F6D186,stroke:#333,stroke-width:2px;
    classDef deployment fill:#C7F0DB,stroke:#333,stroke-width:2px;
    classDef network fill:#F9D1BD,stroke:#333,stroke-width:2px;
```
