# onkardighe/biozen architecture

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

- Interactive diagram: https://gitdiagram.com/onkardighe/biozen
- Repository: https://github.com/onkardighe/biozen

## Overview

##### Project type and purpose
- This is a cross-platform Flutter application (“BioZen”) targeting Android, iOS, Web, Windows, macOS, and Linux.
- Its domain is a biofuels supply-chain tracker built on Ethereum. The client app (Flutter UI + Dart code) interacts with smart contracts via an ABI (assets/abi.json).
- No separate “backend” repo; the blockchain node (Infura or self-hosted) serves as the data layer, with optional Google/Firebase services for OTP and analytics.

##### File structure
- Top level:
- android/, ios/, web/, windows/, macos/, linux/ — platform embedding and build configs
- lib/ — Flutter/Dart source:
– lib/pages/ — all UI screens (Login, Dashboard, NewSupply, etc.)
– lib/utils/ — business logic, helper classes, theme, constants
– lib/Contracts/ — smart-contract wrapper classes
- assets/abi.json — Ethereum contract ABI
- pubspec.yaml — declares dependencies (likely includes web3dart, http, flutter_localizations, etc.)
- test/ — widget_test.dart
- Each platform folder contains native build files: Gradle (android), Xcode & CocoaPods (ios, macos), CMake (linux, windows).

##### READMEs for further insights
- README.md confirms Ethereum integration and shows UI snapshots.
- supplychain/README.md (not shown here) probably lists dependencies (web3dart, flutter_otp, provider/state management).

##### Main components
a. Client App (Flutter)
- UI Layer: pages/widgets in lib/pages
- Business-Logic Layer: service classes in lib/utils and lib/Contracts
- Persistence: local storage (shared_preferences or SQLite, if used)
- Platform Integration: Android (Gradle, Google-services.json), iOS (CocoaPods), Desktop (CMake)
b. Blockchain Backend
- Ethereum Node Provider (Infura or self-hosted Geth/Parity)
- Smart Contracts (deployed on Ethereum mainnet/testnet)
- ABI Interface (assets/abi.json)
c. External Services
- OTP/email provider (Firebase Auth? Twilio)
- Analytics/crash reporting (Firebase Crashlytics / Google Analytics)
d. Development & CI
- Unit/Widget Tests (test/widget_test.dart)
- Deployment pipelines (GitHub Actions / fastlane for Android & iOS)

##### Relationships & data flow
- UI Layer → Business Logic → Web3dart → Ethereum Node
- UI Layer ← Events from Blockchain (tx receipts, events)
- UI Layer ↔ External Auth Service (login, OTP)
- Local storage used for caching session or config

##### Architectural patterns & design principles
- Layered architecture (UI, Service, Data)
- Separation of concerns: UI code in pages/, logic in utils/, contract wrappers in Contracts/
- Cross-platform abstraction via Flutter Engine
- Single source of truth for smart-contract interactions

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Flutter Client Layers
    subgraph "Flutter Client"
        direction TB
        Pages["UI Layer\n(lib/pages)"]:::ui
        Utils["Business Logic\n(lib/utils)"]:::logic
        Contracts["Contract Wrappers\n(lib/Contracts)"]:::contract
        ABI["Ethereum ABI\n(assets/abi.json)"]:::contract
    end

    %% Platform Integrations
    subgraph "Platform Integrations"
        direction TB
        Android["Android\n(build.gradle,\ngoogle-services.json)"]:::platform
        iOS["iOS\n(Runner.xcodeproj,\nPodfile)"]:::platform
        macOS["macOS\n(Runner.xcodeproj,\nFlutter/)"]:::platform
        Linux["Linux\n(CMakeLists.txt,\ngenerated_plugins.cmake)"]:::platform
        Windows["Windows\n(CMakeLists.txt,\nmain.cpp)"]:::platform
    end

    %% External Systems
    EthereumNode["Ethereum Node\n(Infura / Geth)"]:::external
    SmartContracts["Smart Contracts\n(on-chain)"]:::external
    AuthService["Auth/OTP Service\n(Firebase/Twilio)"]:::external

    %% Development & Docs
    Pubspec["pubspec.yaml"]:::docs
    Tests["Widget Tests\n(widget_test.dart)"]:::docs
    README["README.md"]:::docs

    %% Connections
    Pages -->|"user actions"| Utils
    Utils -->|"invoke methods"| Contracts
    Contracts -->|"load ABI"| ABI
    Contracts -->|"JSON-RPC over HTTPS"| EthereumNode
    EthereumNode -->|"contract calls"| SmartContracts
    EthereumNode -->|"events via WebSocket"| Pages
    Pages -->|"OTP request\nREST API"| AuthService
    Pages -->|"analytics/crash"| AuthService
    Utils -->|"local cache"| Pages

    %% Documentation connections
    Pubspec --- Pages
    Tests --- Pages
    README --- Pages

    %% Click Events
    click Pages "https://github.com/onkardighe/biozen/tree/main/supplychain/lib/pages"
    click Utils "https://github.com/onkardighe/biozen/tree/main/supplychain/lib/utils"
    click Contracts "https://github.com/onkardighe/biozen/tree/main/supplychain/lib/Contracts"
    click ABI "https://github.com/onkardighe/biozen/blob/main/supplychain/assets/abi.json"
    click Android "https://github.com/onkardighe/biozen/blob/main/supplychain/android/app/build.gradle"
    click Android "https://github.com/onkardighe/biozen/blob/main/supplychain/android/app/google-services.json"
    click iOS "https://github.com/onkardighe/biozen/blob/main/supplychain/ios/Runner.xcodeproj"
    click iOS "https://github.com/onkardighe/biozen/tree/main/supplychain/ios/Podfile"
    click macOS "https://github.com/onkardighe/biozen/blob/main/supplychain/macos/Runner.xcodeproj"
    click macOS "https://github.com/onkardighe/biozen/tree/main/supplychain/macos/Flutter"
    click Linux "https://github.com/onkardighe/biozen/blob/main/supplychain/linux/CMakeLists.txt"
    click Linux "https://github.com/onkardighe/biozen/blob/main/supplychain/linux/flutter/generated_plugins.cmake"
    click Windows "https://github.com/onkardighe/biozen/blob/main/supplychain/windows/CMakeLists.txt"
    click Windows "https://github.com/onkardighe/biozen/blob/main/supplychain/windows/runner/main.cpp"
    click Pubspec "https://github.com/onkardighe/biozen/blob/main/supplychain/pubspec.yaml"
    click Tests "https://github.com/onkardighe/biozen/blob/main/supplychain/test/widget_test.dart"
    click README "https://github.com/onkardighe/biozen/blob/main/supplychain/README.md"

    %% Styles
    classDef ui fill:#AEC6CF,stroke:#333,stroke-width:1px
    classDef logic fill:#77DD77,stroke:#333,stroke-width:1px
    classDef contract fill:#AAF0D1,stroke:#333,stroke-width:1px
    classDef external fill:#CFCFC4,stroke:#333,stroke-width:1px
    classDef platform fill:#FFD1DC,stroke:#333,stroke-width:1px
    classDef docs fill:#FFB347,stroke:#333,stroke-width:1px
```
