# eshan-sud/secureit architecture

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

- Interactive diagram: https://gitdiagram.com/eshan-sud/secureit
- Repository: https://github.com/eshan-sud/secureit

## Overview

##### Main Components

A. Client-Side (Frontend Layer):
- React Application Container
- Component Modules:
- Authentication Module (MetMask Integration)
- File Management Module
- Permission Control Module
- Audit Trail Viewer
- Web3.js Integration Layer

B. Blockchain Layer:
- Smart Contracts
- Permission Management Contract
- Audit Trail Contract
- Compensation System Contract

C. Backend Services:
- Node.js/Express Server
- File Storage Service
- MongoDB Database

**[Frontend Layer]**
- ↕
**[Blockchain Layer]**
- ↕
**[Backend Services]**

##### Component Relationships to Highlight

a. User Flow Connections:
- MetaMask → Authentication → Smart Contract
- File Upload → Storage Service → Database
- Permission Settings → Smart Contract → Blockchain

b. Data Flow Paths:
- File Storage: Frontend → Backend → MongoDB
- Transaction Flow: Frontend → Web3.js → Blockchain
- Audit Trail: Smart Contract → Frontend Display

##### Specific Implementation Details

Technical elements:
**Frontend:**
- React.js Components (from /frontend/src/components)
- Web3.js Integration
- MetaMask Connection

**Blockchain:**
- Smart Contracts (referenced in /frontend/src/abi)
- Permission Management
- Transaction Handling

**Backend:**
- Express.js Server
- MongoDB Integration
- File Storage System

##### Additional Elements

- Security Layer Indicators
- API Endpoints (referenced in ApiEndpoints.js)
- User Authentication Flow
- File Storage Flow
- Permission Management Flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        App["React App Container"]
        Auth["Authentication Module"]
        FileM["File Management"]
        PermC["Permission Control"]
        AuditV["Audit Trail Viewer"]
        Web3["Web3.js Integration"]
        Wallet["Wallet Management"]
        Nav["Navigation/UI"]
    end

    subgraph Blockchain
        SmartC["Smart Contracts"]
        PermSC["Permission Management Contract"]
        AuditC["Audit Trail Contract"]
        CompC["Compensation System Contract"]
    end

    subgraph Backend
        Express["Node.js/Express Server"]
        Storage["File Storage Service"]
        Mongo[(MongoDB Database)]
    end

    %% Frontend Connections
    App --> Auth
    App --> FileM
    App --> PermC
    App --> AuditV
    App --> Web3
    App --> Wallet
    App --> Nav

    %% Cross-layer Connections
    Auth --> Web3
    Web3 --> SmartC
    FileM --> Express
    PermC --> PermSC
    AuditV --> AuditC
    Wallet --> CompC

    %% Backend Connections
    Express --> Storage
    Storage --> Mongo

    %% Styling
    classDef frontend fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef blockchain fill:#90EE90,stroke:#333,stroke-width:2px
    classDef backend fill:#FFB347,stroke:#333,stroke-width:2px
    classDef database fill:#DDA0DD,stroke:#333,stroke-width:2px

    class App,Auth,FileM,PermC,AuditV,Web3,Wallet,Nav frontend
    class SmartC,PermSC,AuditC,CompC blockchain
    class Express,Storage backend
    class Mongo database

    %% Click Events
    click App "https://github.com/eshan-sud/secureIt/blob/main/frontend/src/App.js"
    click Auth "https://github.com/eshan-sud/secureIt/blob/main/frontend/src/components/MetMaskLogin.js"
    click FileM "https://github.com/eshan-sud/secureIt/blob/main/frontend/src/components/FileUpload.js"
    click PermC "https://github.com/eshan-sud/secureIt/blob/main/frontend/src/components/SetPermissions.jsx"
    click AuditV "https://github.com/eshan-sud/secureIt/blob/main/frontend/src/components/AuditTrail.jsx"
    click Web3 "https://github.com/eshan-sud/secureIt/blob/main/frontend/src/abi/MyContractABI.json"
    click Wallet "https://github.com/eshan-sud/secureIt/blob/main/frontend/src/components/Wallet.jsx"
    click Nav "https://github.com/eshan-sud/secureIt/blob/main/frontend/src/components/Sidebar.jsx"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Blockchain_L["Blockchain Component"]:::blockchain
        Backend_L["Backend Component"]:::backend
        Database_L[(Database)]:::database
    end
```
