# ab7zz/metasave architecture

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

- Interactive diagram: https://gitdiagram.com/ab7zz/metasave
- Repository: https://github.com/ab7zz/metasave

## Overview

##### Main Components

a) Client-Side Components:
- Frontend Application (metasave-fe)
- User Portal
- Hospital/Clinic Portal
- Dashboard Components
- Authentication System

b) IoT Devices Layer:
- Camera System (YOLOv7-W6-Pose Model)
- Wearable Device (Arduino Nano BLE)
- Fall Detection Components

c) Backend Services:
- Main Server (metasave-be)
- Authentication Service
- WhatsApp Notification System
- Merkle Tree Management
- Data Processing Pipeline

d) Blockchain Layer:
- Smart Contracts (MetaSave Contracts)
- ZK-Proof System
- Access Control System

e) Storage Layer:
- IPFS Storage
- Database Systems

##### Connection and Data Flow Representation

- Real-time data flows (fall detection)
- API calls
- Blockchain transactions
- Authentication flows
- Notification pathways

##### Specific Implementation Details

a) IoT Layer:
- YOLOv7 model processing pipeline
- BLE communication channels
- Fall detection algorithm flow

b) Backend Services:
- WhatsApp integration
- Merkle tree verification flow
- User operation handling

c) Blockchain Integration:
- Smart contract interaction paths
- ZK-proof verification flow
- Access control mechanisms

##### Security Layer Representation

- Zero-knowledge proof pathways
- Access control checkpoints
- Data encryption points

##### Additional Elements

Specialized sections for:
- Model metrics display (84.5% accuracy, 0.69 Kappa score)
- Performance indicators (10 fps, 100ms latency)
- Security protocol indicators

##### Technical Details

- Node.js v20.16.0 requirement
- CUDA/GPU processing capabilities
- Communication protocols (BLE, HTTP, WebSocket)
- Smart contract addresses and interfaces

- Fall detection capabilities
- Real-time monitoring
- Blockchain-based security
- Zero-knowledge proof implementation
- Multi-party access control

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef iot fill:#90EE90,stroke:#333,stroke-width:2px
    classDef backend fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef blockchain fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef storage fill:#FFD700,stroke:#333,stroke-width:2px
    classDef security fill:#FF6B6B,stroke:#333,stroke-width:2px

    %% Frontend Layer
    subgraph Frontend
        FE["Frontend Application"]:::frontend
        UP["User Portal"]:::frontend
        HP["Hospital Portal"]:::frontend
        DB["Dashboard"]:::frontend
        Auth["Authentication"]:::frontend
    end

    %% IoT Layer
    subgraph IoT
        CS["Camera System\n(YOLOv7)"]:::iot
        WD["Wearable Device\n(Arduino Nano BLE)"]:::iot
        FD["Fall Detection"]:::iot
        ML["Model Implementation"]:::iot
        DL["Detection Logic"]:::iot
        DV["Device Listener"]:::iot
    end

    %% Backend Layer
    subgraph Backend
        MS["Main Server"]:::backend
        WN["WhatsApp\nNotification"]:::backend
        MTM["Merkle Tree\nManagement"]:::backend
        DP["Data Processing"]:::backend
        BC["BLE Communication"]:::backend
    end

    %% Blockchain Layer
    subgraph Blockchain
        SC["Smart Contracts"]:::blockchain
        ZK["ZK-Proof System"]:::blockchain
        AC["Access Control"]:::blockchain
    end

    %% Security Layer
    subgraph Security
        ZKH["ZK-Proof Helper"]:::security
        MT["Merkle Tree"]:::security
    end

    %% Storage Layer
    subgraph Storage
        IPFS["IPFS Storage"]:::storage
        DB_SYS["Database Systems"]:::storage
    end

    %% Connections
    FE --> MS
    UP --> MS
    HP --> MS
    Auth --> MS
    CS --> FD
    WD --> FD
    FD --> MS
    MS --> WN
    MS --> MTM
    MS --> SC
    SC --> ZK
    SC --> AC
    MTM --> MT
    MS --> BC
    BC --> WD
    ZK --> ZKH
    MS --> IPFS
    MS --> DB_SYS

    %% Click Events
    click FE "https://github.com/AB7zz/metasave/tree/main/packages/metasave-fe/src/"
    click UP "https://github.com/AB7zz/metasave/tree/main/packages/metasave-fe/src/pages/user/"
    click HP "https://github.com/AB7zz/metasave/tree/main/packages/metasave-fe/src/pages/clinic/"
    click DB "https://github.com/AB7zz/metasave/tree/main/packages/metasave-fe/src/components/Dashboard/"
    click Auth "https://github.com/AB7zz/metasave/blob/main/packages/metasave-fe/src/context/AuthContext.jsx"
    click CS "https://github.com/AB7zz/metasave/blob/main/packages/model/camera.py"
    click WD "https://github.com/AB7zz/metasave/blob/main/packages/model/nano_ble.ino"
    click FD "https://github.com/AB7zz/metasave/blob/main/packages/model/fall_detection.proto"
    click MS "https://github.com/AB7zz/metasave/blob/main/packages/metasave-be/index.js"
    click WN "https://github.com/AB7zz/metasave/tree/main/packages/metasave-be/controllers/whatsapp/"
    click MTM "https://github.com/AB7zz/metasave/tree/main/packages/metasave-be/controllers/merkleTree/"
    click DP "https://github.com/AB7zz/metasave/tree/main/packages/metasave-be/controllers/"
    click SC "https://github.com/AB7zz/metasave/tree/main/packages/metasave-contracts/contracts/"
    click ZK "https://github.com/AB7zz/metasave/blob/main/packages/metasave-contracts/build/contracts/ZKProof.json"
    click AC "https://github.com/AB7zz/metasave/blob/main/packages/metasave-contracts/build/contracts/AccessControl.json"
    click ML "https://github.com/AB7zz/metasave/tree/main/packages/model/yoloutils/"
    click DL "https://github.com/AB7zz/metasave/blob/main/packages/model/test/detect.py"
    click DV "https://github.com/AB7zz/metasave/blob/main/packages/model/listenDevice.py"
    click ZKH "https://github.com/AB7zz/metasave/blob/main/packages/metasave-be/helpers/device/verifyProof.js"
    click MT "https://github.com/AB7zz/metasave/tree/main/packages/metasave-be/helpers/merkleTree/"
    click BC "https://github.com/AB7zz/metasave/blob/main/packages/metasave-be/ble.js"

    %% Legend
    subgraph Legend
        L1["Frontend Components"]:::frontend
        L2["IoT Components"]:::iot
        L3["Backend Services"]:::backend
        L4["Blockchain Components"]:::blockchain
        L5["Security Components"]:::security
        L6["Storage Systems"]:::storage
    end
```
