# os-lab-daejinuniv/smart-lab architecture

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

- Interactive diagram: https://gitdiagram.com/os-lab-daejinuniv/smart-lab
- Repository: https://github.com/os-lab-daejinuniv/smart-lab

## Overview

##### Main Components Identification

a. Core Components:
- Wallpad System (Frontend + Backend)
- Smart Card System
- Server (IoT Hub)
- Mobile Application
- Database (SQLite)
- IoT Devices (Door Lock, Lighting)

##### Detailed Component Representation

Frontend (Wallpad):
**[Next.js Frontend]**
- User Interface
- Advertisement Component
- Profile Management
- Real-time Updates (Socket.io Client)

Backend (Wallpad):
**[Node.js Backend]**
- Smart Card Processing
- Device Control Logic
- Event Management
- Socket.io Server

Smart Card System:
**[JavaCard Implementation]**
- Authentication Logic
- Challenge-Response System
- User Data Storage

Mobile App:
**[Flutter Application]**
- NFC Operations
- Card Info Management
- User Preferences
- 2FA Implementation

##### Data Flow Representation

- Smart Card authentication flow
- Real-time updates between frontend and backend
- Mobile app interactions with smart cards
- IoT device control commands
- Database operations

##### Implementation Notes

- The Socket.IO-based real-time communication
- The Challenge-Response authentication system
- The extension system for device control
- The mobile app's NFC capabilities
- The 2FA implementation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Physical
        WD[Wallpad Display]
        IOT1[Door Lock]
        IOT2[Lighting System]
        SC[Smart Cards]
        MD[Mobile Devices]
        SH[Server Hardware]
    end

    subgraph Application
        subgraph Frontend
            WF["Next.js Frontend"]:::frontend
            UI["User Interface"]:::frontend
            AD["Advertisement Component"]:::frontend
            PM["Profile Management"]:::frontend
            SIC["Socket.IO Client"]:::frontend
        end

        subgraph Backend
            WB["Node.js Backend"]:::backend
            SCP["Smart Card Processor"]:::backend
            DCL["Device Control Logic"]:::backend
            EM["Event Manager"]:::backend
            SIS["Socket.IO Server"]:::backend
            EXT["Extension System"]:::backend
        end

        subgraph SmartCard
            JC["JavaCard Implementation"]:::security
            AL["Authentication Logic"]:::security
            CRS["Challenge-Response System"]:::security
            UDS["User Data Storage"]:::security
        end

        subgraph Mobile
            FA["Flutter Application"]:::mobile
            NFC["NFC Operations"]:::mobile
            CIM["Card Info Management"]:::mobile
            UP["User Preferences"]:::mobile
            TFA["2FA Implementation"]:::mobile
        end

        subgraph Storage
            DB[(SQLite Database)]:::storage
        end
    end

    %% Physical Layer Connections
    WD --> WF
    SC --> SCP
    MD --> FA
    IOT1 & IOT2 --> DCL

    %% Frontend Connections
    WF --> UI & AD & PM
    UI & AD & PM --> SIC
    
    %% Backend Connections
    WB --> SCP & DCL & EM & SIS & EXT
    DCL --> IOT1 & IOT2
    SCP --> CRS
    
    %% Mobile Connections
    FA --> NFC & CIM & UP & TFA
    
    %% Database Connections
    WB --> DB
    SCP --> DB
    
    %% Real-time Communications
    SIC <--> SIS

    %% Click Events
    click WF "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/tree/main/wallpad-frontend/src/app/"
    click AD "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/wallpad-frontend/src/app/components/Advertisement.js"
    click PM "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/wallpad-frontend/src/app/components/Profile.js"
    click SIC "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/wallpad-frontend/src/socket.js"
    click WB "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/wallpad-backend/Wallpad.js"
    click EXT "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/wallpad-backend/Extension.js"
    click DB "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/wallpad-backend/wallpad_example.db"
    click SCP "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/wallpad-backend/SCData.js"
    click FA "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/smartcard-agent-app/lib/main.dart"
    click NFC "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/smartcard-agent-app/lib/utils/nfcOperation.dart"
    click CIM "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/smartcard-agent-app/lib/CardinfoPage.dart"
    click JC "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/blob/main/smartcard/OSLabID/OSLabID.java"
    click DCL "https://github.com/OS-LAB-DaejinUniv/Smart-Lab/tree/main/wallpad-backend/extensions/"

    %% Styling
    classDef frontend fill:#3498db
    classDef backend fill:#2ecc71
    classDef security fill:#f1c40f
    classDef mobile fill:#9b59b6
    classDef storage fill:#95a5a6
    
    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        B[Backend]:::backend
        S[Security]:::security
        M[Mobile]:::mobile
        ST[Storage]:::storage
    end
```
