# dut-svbk36/qlda_22nh12_g3_svbk36 architecture

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

- Interactive diagram: https://gitdiagram.com/dut-svbk36/qlda_22nh12_g3_svbk36
- Repository: https://github.com/dut-svbk36/qlda_22nh12_g3_svbk36

## Overview

##### And Label Primary Components
- CameraSocket Module: Represented as a component built in C/C++ that handles low-level interactions with the camera hardware and transmits events or data frames to the server via socket.
- WebApp (Django): Acts as the server managing model frame handling, prediction processing using pre-trained models (as seen in both DesktopApp and WebApp directories with .h5 and .pkl files), and communicating updates back to clients.
- DesktopApp: Represents a rich client-side interface that includes various screens (authentication, dashboard, posture monitoring) as well as internal utility/helper components. This client receives live results and interacts with the backend.

- WebApp receiving these events and passing frames through a model inference pipeline (indicating model loading and prediction util components).
- If applicable, show the DesktopApp possibly sending requests to the Django backend (WebApp) for additional data or actions.

##### Architectural Patterns and Design Principles
- Clearly demarcate layers: Input (camera stream via CameraSocket) → Processing (WebApp’s model handling and business logic) → Presentation (DesktopApp UI, along with static assets like fonts and images).
- Modularity by displaying separate blocks for UI components (DesktopApp’s components and screens), model management (both DesktopApp and WebApp hold model files and utility functions for handling models), and communication layers (the socket-based communication between CameraSocket and WebApp).
- That the project uses multiple languages/technologies (C/C++ for low-level module, Python for Django and DesktopApp) and involves version control branches for development in different components.

##### Relevant Technologies and Frameworks
- CameraSocket – Built in C/C++ for direct hardware interfacing and sending events.
- WebApp – Django framework; includes detection logic along with utility modules (helpers, visualization, keypoints_utils).
- DesktopApp – Python based application with custom UI components and configuration modules; includes local tests for various UI components and utilities.
- Pre-trained Models – Files such as best_model, label_encoder, and pose_classifier that are crucial to the body posture detection process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware/Communication Layer
    subgraph "Hardware and Communication Layer"
        CS["CameraSocket Module (C/C++)"]:::cameraSocket
    end

    %% Processing Layer (WebApp - Django)
    subgraph "Processing Layer (WebApp - Django)"
        WEH["Event & Frame Handler"]:::webapp
        MI["Model Inference Pipeline"]:::webapp
        WPU["Pre-trained Models & Utilities"]:::webapp
    end

    %% Presentation Layer (DesktopApp - Python)
    subgraph "Presentation Layer (DesktopApp - Python)"
        DC["Client Logic"]:::desktop
        UI["User Interface (Screens & Components)"]:::desktop
    end

    %% Data Flow
    CS -->|"camera_on_event"| WEH
    WEH -->|"send_frame"| MI
    MI -->|"utilize_models"| WPU
    MI -->|"prediction_result"| UI
    UI -->|"data_request"| WEH
    DC -->|"orchestrates"| UI

    %% Click Events
    click CS "https://github.com/dut-svbk36/qlda_22nh12_g3_svbk36/tree/main/CameraSocket/"
    click WEH "https://github.com/dut-svbk36/qlda_22nh12_g3_svbk36/tree/main/WebApp/"
    click MI "https://github.com/dut-svbk36/qlda_22nh12_g3_svbk36/tree/main/WebApp/"
    click WPU "https://github.com/dut-svbk36/qlda_22nh12_g3_svbk36/tree/main/WebApp/"
    click UI "https://github.com/dut-svbk36/qlda_22nh12_g3_svbk36/tree/main/DesktopApp/"
    click DC "https://github.com/dut-svbk36/qlda_22nh12_g3_svbk36/tree/main/DesktopApp/"

    %% Styles
    classDef cameraSocket fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef webapp fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef desktop fill:#FFB6C1,stroke:#000,stroke-width:2px;

    %% Legend (as annotation nodes)
    subgraph "Legend"
        L1["Hardware Module (C/C++)"]:::cameraSocket
        L2["Backend (Django)"]:::webapp
        L3["Frontend Client (Python)"]:::desktop
    end
    style L1 fill:#ADD8E6,stroke:#000,stroke-width:1px
    style L2 fill:#90EE90,stroke:#000,stroke-width:1px
    style L3 fill:#FFB6C1,stroke:#000,stroke-width:1px
    %% Hide legend boundaries
    class L1,L2,L3 legendStyle
    linkStyle default fill:none,stroke:#333,stroke-width:1px
```
