# tmanas06/healthdapp_azero architecture

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

- Interactive diagram: https://gitdiagram.com/tmanas06/healthdapp_azero
- Repository: https://github.com/tmanas06/healthdapp_azero

## Overview

##### Main Components
- Frontend dApp: The source code in the “src” directory and accompanying assets (index.html, public folder) represent a rich React/TypeScript user interface. This includes key components such as login pages, dashboard, wallet connection, and specific modules like AIPredictor, AccessControl, and ZeroKnowledge views.
- Smart Contracts Backend: The “contracts” folder contains multiple smart contracts written in Rust using Cargo. The project has separate contracts for:
- Access Control: Managing permissions in the system.
- AI Manager: For orchestrating AI-driven predictive analytics.
- Health Records: Handling medical data storage and access.
- Zero-Knowledge: Implementing proof mechanisms to ensure data privacy.
- Blockchain Layer: While not directly part of the code, the README indicates that these contracts operate on the Aleph Zero blockchain.
- External Dependencies: Other parts include linting, configuration, and bundling scripts (e.g., package.json, vite.config.ts, tailwind.config.ts) which play roles in the build and deployment process.

##### Component Interactions
- The Frontend is the consumer interface that interacts with end users (patients and medical professionals). It will use wallet connectivity (indicated by the WalletConnector component) to securely connect to the blockchain.
- The Frontend issues transactions and queries to the Smart Contracts deployed on the Aleph Zero blockchain.
- The Smart Contracts interact with each other: for example, the AI Manager contract might fetch or manipulate data from the Health Records contract, while Access Control ensures that only authorized users can perform certain operations.
- Zero-Knowledge proofs are used within the system to enable secure, private verification of data without exposing the underlying details.

##### Architectural Patterns and Design Principles
- Decentralized Architecture Pattern: The system splits responsibilities between client-side logic and on-chain smart contracts.
- Modular Smart Contracts: Each contract (AccessControl, AI Manager, HealthRecords, Zero-Knowledge) is isolated and focused on specific business logic, which may be depicted as separate microservices/entities within the overall blockchain network.
- Separation of Concerns: The UI is developed independently from the backend smart contracts, emphasizing a clear API (likely through blockchain-specific libraries) for communication.
- Security and Privacy by Design: Use of zero-knowledge proofs ensures that authentication and data privacy are inherent in the design.

##### Technologies and Significant Elements
- Frontend: React (with TypeScript), styled using CSS/Tailwind, and built with Vite.
- Smart Contracts: Rust-based contracts (using Cargo manifests) for each distinct domain (access management, AI processing, health records, zero-knowledge proofs).
- Blockchain: The Aleph Zero blockchain which hosts the smart contracts.
- Wallet Integration: Components like WalletConnector to manage user authentication and transaction signing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Application
    subgraph "Frontend Application"
        F["Frontend (React/TypeScript UI)"]:::frontend
        D["Dashboard (UI)"]:::ui
        AC["Access Control (UI)"]:::ui
        AIP["AIPredictor (UI)"]:::ui
        WC["Wallet Connector (UI)"]:::ui
        ZK["ZeroKnowledge (UI)"]:::ui
    end

    %% Smart Contracts Layer
    subgraph "Smart Contracts Layer"
        SC_AC["Access Control (Contract)"]:::contract
        SC_AI["AI Manager (Contract)"]:::contract
        SC_HR["Health Records (Contract)"]:::contract
        SC_ZK["Zero-Knowledge (Contract)"]:::contract
    end

    %% Blockchain Layer
    BC["Aleph Zero Blockchain"]:::blockchain

    %% Relationships: Frontend Interaction with Smart Contracts
    F -->|"issuesTransaction"| SC_AC
    F -->|"issuesTransaction"| SC_AI
    F -->|"issuesTransaction"| SC_HR
    F -->|"issuesTransaction"| SC_ZK

    %% Wallet Connector Interaction with Blockchain
    WC -->|"connectsTo"| BC

    %% Inter-contract Communications
    SC_AI -->|"fetchesDataFrom"| SC_HR
    SC_AC -->|"enforcesAccessFor"| SC_HR
    SC_ZK -->|"verifiesProofsFor"| SC_HR

    %% Deployment: Smart Contracts are on the Blockchain
    SC_AC -->|"deployedOn"| BC
    SC_AI -->|"deployedOn"| BC
    SC_HR -->|"deployedOn"| BC
    SC_ZK -->|"deployedOn"| BC

    %% Click Events for Frontend Components
    click F "https://github.com/tmanas06/healthdapp_azero/tree/main/src/"
    click D "https://github.com/tmanas06/healthdapp_azero/blob/main/src/components/Dashboard.tsx"
    click AC "https://github.com/tmanas06/healthdapp_azero/blob/main/src/components/AccessControl.tsx"
    click AIP "https://github.com/tmanas06/healthdapp_azero/blob/main/src/components/AIPredictor.tsx"
    click WC "https://github.com/tmanas06/healthdapp_azero/blob/main/src/components/WalletConnector.tsx"
    click ZK "https://github.com/tmanas06/healthdapp_azero/blob/main/src/components/ZeroKnowledge.tsx"

    %% Click Events for Smart Contract Components
    click SC_AC "https://github.com/tmanas06/healthdapp_azero/tree/main/contracts/contracts/access_control"
    click SC_AI "https://github.com/tmanas06/healthdapp_azero/tree/main/contracts/contracts/ai_manager"
    click SC_HR "https://github.com/tmanas06/healthdapp_azero/tree/main/contracts/contracts/health_records"
    click SC_ZK "https://github.com/tmanas06/healthdapp_azero/tree/main/contracts/contracts/zero_knowledge"

    %% Style Classes
    classDef frontend fill:#A6CEE3,stroke:#1F78B4,stroke-width:2px;
    classDef ui fill:#E5C494,stroke:#8B572A,stroke-width:2px;
    classDef contract fill:#B2DF8A,stroke:#33A02C,stroke-width:2px;
    classDef blockchain fill:#FDBF6F,stroke:#FF7F00,stroke-width:2px;
```
