# atharv181/medown architecture

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

- Interactive diagram: https://gitdiagram.com/atharv181/medown
- Repository: https://github.com/atharv181/medown

## Overview

##### Main Components
- Frontend Application:
- Located in the “frontend” directory with a clear React structure (e.g., components such as Home, Hero, Patient, and others).
- Uses Tailwind CSS (tailwind.config.js) and interacts with the smart contracts.
- Smart Contracts:
- Found in the “contracts” directory (likely written in Solidity) and integrating OpenZeppelin libraries, as seen by the artifacts in the frontend.
- Enable functionalities such as patient whitelist management, ownership transfers, and NFT creation for medical data.
- Blockchain Network:
- The smart contracts are deployed to a blockchain (likely Ethereum-compatible) using Hardhat (hardhat.config.js) and various deployment scripts (located in “scripts” such as deployNFT.js, deployBase.js, etc.).
- Deployment and Build Tools:
- Hardhat configuration for contract compilation and deployments.
- Deployment scripts that automate contract deployment.
- External Services & Integration Points:
- Node Providers: Environment variables indicate integration with Quicknode and Alchemy to connect to the blockchain.
- IPFS/Pinata: Environment variables for Pinata API keys suggest integration with decentralized storage, likely for storing or accessing encrypted medical data content.

##### Relationships and Interactions
- The smart contracts manage NFT-related transactions (for patient data monetization) and medical record permissions. Indicate these dependencies clearly.
- External service integrations like Quicknode/Alchemy and Pinata serve as gateways or additional layers for blockchain connectivity and decentralized storage. Make sure to show these interactions with the blockchain and possibly the frontend.

##### Architectural Patterns and Design Principles
- The project follows a clear separation of concerns: UI in the frontend, business logic in smart contracts, and deployment automation via scripts.
- A common blockchain-driven pattern is employed where the frontend serves as a user interface that calls smart contract functions to read or write data on a decentralized ledger.
- The use of OpenZeppelin libraries indicates adherence to safe, audited contract patterns.

##### Technologies, Frameworks, and Libraries
- Frontend: React (with components in the “components” directory), Tailwind CSS, JavaScript.
- Blockchain: Solidity smart contracts, Hardhat for development and testing.
- OpenZeppelin: Standard library for secure smart contracts (evident in the artifacts folder).
- External APIs: Quicknode/Alchemy for blockchain node access, and Pinata for handling decentralized file storage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Frontend["Frontend (React App)"]:::frontend
        FrontendComponents["Components"]:::frontend
        FrontendPublic["Public Assets"]:::frontend
        TailwindConfig["Tailwind Config"]:::frontend
    end

    %% Smart Contracts Layer
    subgraph "Smart Contracts Layer"
        SmartContracts["Smart Contracts (Solidity/OpenZeppelin)"]:::contracts
        ArtifactsContracts["Artifacts"]:::contracts
    end

    %% Blockchain & Deployment Layer
    subgraph "Blockchain & Deployment"
        Blockchain["Blockchain Network (Ethereum via Quicknode/Alchemy)"]:::blockchain
        subgraph "Deployment Tools"
            HardhatConfig["Hardhat Config"]:::deployment
            DeploymentScripts["Deployment Scripts (Hardhat)"]:::deployment
            DeployAddContent["deployAddContent.js"]:::deployment
            DeployBase["deployBase.js"]:::deployment
            DeployNFT["deployNFT.js"]:::deployment
        end
    end

    %% External Services
    subgraph "External Services"
        Providers["Blockchain Providers (Quicknode/Alchemy)"]:::external
        Pinata["Decentralized Storage (Pinata/IPFS)"]:::external
    end

    %% Connections
    Frontend -->|"calls"| SmartContracts
    SmartContracts -->|"deployed on"| Blockchain
    DeploymentScripts -->|"deploys contracts"| Blockchain
    HardhatConfig -->|"configures"| DeploymentScripts
    Blockchain ---|"integrated with"| Providers
    Frontend -->|"stores data"| Pinata
    SmartContracts -->|"linksNFTdata"| Pinata
    DeploymentScripts -->|"includes"| DeployAddContent
    DeploymentScripts -->|"includes"| DeployBase
    DeploymentScripts -->|"includes"| DeployNFT

    %% Click Events
    click Frontend "https://github.com/atharv181/medown/tree/master/frontend"
    click FrontendComponents "https://github.com/atharv181/medown/tree/master/frontend/src/components"
    click FrontendPublic "https://github.com/atharv181/medown/tree/master/frontend/public"
    click TailwindConfig "https://github.com/atharv181/medown/blob/master/frontend/tailwind.config.js"
    click SmartContracts "https://github.com/atharv181/medown/tree/master/contracts"
    click ArtifactsContracts "https://github.com/atharv181/medown/tree/master/frontend/src/artifacts/contracts"
    click HardhatConfig "https://github.com/atharv181/medown/blob/master/hardhat.config.js"
    click DeploymentScripts "https://github.com/atharv181/medown/tree/master/scripts"
    click DeployAddContent "https://github.com/atharv181/medown/blob/master/scripts/deployAddContent.js"
    click DeployBase "https://github.com/atharv181/medown/blob/master/scripts/deployBase.js"
    click DeployNFT "https://github.com/atharv181/medown/blob/master/scripts/deployNFT.js"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef contracts fill:#C7F9CC,stroke:#333,stroke-width:2px;
    classDef blockchain fill:#FFF79A,stroke:#333,stroke-width:2px;
    classDef deployment fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef external fill:#FADBD8,stroke:#333,stroke-width:2px;
```
