# 1061700625/raspberrypi-magicmirror architecture

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

- Interactive diagram: https://gitdiagram.com/1061700625/raspberrypi-magicmirror
- Repository: https://github.com/1061700625/raspberrypi-magicmirror

## Overview

##### Main Components
- Hardware/Sensors: Represent the physical inputs including the camera for face and emotion detection, temperature/humidity sensors (as indicated by DHT11 files and GPIO usage), and microphone/speaker components for voice interaction.
- Core Processing Layer (Python Project):
- UI & Display: The mirror UI scripts (mirrorUI.py, mirrorUI.ui) and the layout design which drive the actual display on the mirror.
- Recognition & Interaction: Modules for face detection (face.py, haarcascades data), voice processing/speech (speech.py, snowboydecoder.py), and emotional analysis.
- Utility & Sensor Integration: Files like the GPIO usage table and DHT11 C file indicate sensor readings are integrated here.
- Mobile/Remote Interface:
- Android App: Present inside the AndroidStudioProjects directory, which likely communicates with the Raspberry Pi (via an API or socket connection) to push usage information and exchange commands.
- Web Interface:
- WebProject: Contains a picture viewer and PHP scripts (upload_file.php) indicating some web-based interaction, possibly for monitoring or additional content display.
- External Documentation/Deployment:
- Various Markdown files (e.g., “第三方库的安装.md”, “服务器部署.md”) and flowcharts (in the “各模块大致流程图” directory) suggest additional deployment and operational framing for the system.

##### Relationships and Data Flow
- The Core Processing Layer will process data (e.g., face recognition, sensor readings) and update the UI display module.
- Parallel channels: Voice interaction and emotion/speech modules communicate with both the display and with external endpoints.
- Remote Interaction:
- Data communication between the Android app and the Core Processing Layer (to receive push notifications or control signals).
- The Web interface, which might be used for uploading or viewing data (e.g., picture uploads, status monitoring), connects to the backend via standard web protocols.

##### Architectural Patterns and Technologies
- Modular Design: Separate functionality into discrete modules such as sensor handling, UI rendering, recognition processing, and network communication.
- Full-stack Integration: Combining local processing on the Raspberry Pi (using Python) with distributed interfaces (Android app, Web UI).
- Communication Protocols: Identify and visually annotate any protocols (e.g., HTTP/REST for web communication, possibly WebSocket or similar for real-time control) if details are known.
- Interaction Patterns: Show how user inputs (via voice or remote app) generate feedback on the mirror display.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware & Sensors
    subgraph "Hardware & Sensors"
        H1["Camera (Face Detection)"]:::hardware
        H2["DHT11 Sensor (Temp/Humidity)"]:::hardware
        H3["Microphone/Speaker (Voice)"]:::hardware
    end

    %% Core Processing (Python)
    subgraph "Core Processing (Python)"
        subgraph "UI & Display"
            CP1["mirrorUI.py / mirrorUI.ui"]:::ui
            CP2["mirrorUI_1260_800.py / mirrorUI_1260_800.ui"]:::ui
        end
        subgraph "Face Recognition & Emotion"
            CP3["face.py"]:::face
            CP4["haarcascades (Face Data)"]:::face
        end
        subgraph "Voice/Speech Interaction"
            CP5["speech.py"]:::voice
            CP6["snowboydecoder.py"]:::voice
        end
        subgraph "Utility & Others"
            CP7["MagicMirror.py"]:::util
            CP8["MagicMirror_1260_800.py"]:::util
            CP9["qttest.py"]:::util
            CP10["test.py"]:::util
            CP11["GPIO Table (GPIO使用表.txt)"]:::util
            CP12["DHT11 Integration (dht11.c)"]:::util
        end
    end

    %% Mobile/Remote Interface
    subgraph "Mobile/Remote Interface"
        MA["Android App"]:::mobile
    end

    %% Web Interface
    subgraph "Web Interface"
        WB["Picture Viewer / Web UI"]:::web
    end

    %% Documentation/Deployment
    subgraph "Documentation/Deployment"
        DOC1["Markdown Docs & Flowcharts"]:::doc
    end

    %% Data Flows from Hardware to Core Processing
    H1 -->|"video_feed"| CP3
    H1 -->|"uses"| CP4
    H2 -->|"sensor_data"| CP12
    H3 -->|"audio_input"| CP5

    %% Internal Processing Connections
    CP3 -->|"face_result"| CP1
    CP5 -->|"voice_data"| CP1
    CP6 -->|"voice_event"| CP5

    %% External Interfaces Connections (bidirectional)
    MA <-->|"control_notification"| CP1
    WB <-->|"upload_view"| CP1

    %% Documentation Connection (informational)
    DOC1 ---|"guides"| CP7

    %% Click Events for Hardware/Sensors
    click CP12 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/dht11/dht11.c"
    click CP11 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/GPIO使用表.txt"
    click CP4 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/data/haarcascades/haarcascade_frontalface_alt.xml"

    %% Click Events for Core Processing UI & Display
    click CP1 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/mirrorUI.py"
    click CP1 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/mirrorUI.ui"
    click CP2 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/mirrorUI_1260_800.py"
    click CP2 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/mirrorUI_1260_800.ui"

    %% Click Events for Face Recognition & Emotion
    click CP3 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/face.py"

    %% Click Events for Voice/Speech Interaction
    click CP5 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/speech.py"
    click CP6 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/snowboydecoder.py"

    %% Click Events for Utility & Other Scripts
    click CP7 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/MagicMirror.py"
    click CP8 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/MagicMirror_1260_800.py"
    click CP9 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/qttest.py"
    click CP10 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/PythonProject/test.py"

    %% Click Events for Mobile/Remote Interface
    click MA "https://github.com/1061700625/raspberrypi-magicmirror/tree/master/AndroidStudioProjects"

    %% Click Events for Web Interface
    click WB "https://github.com/1061700625/raspberrypi-magicmirror/tree/master/WebProject"

    %% Click Events for Documentation/Deployment
    click DOC1 "https://github.com/1061700625/raspberrypi-magicmirror/blob/master/3、第三方库的安装.md"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef ui fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef face fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef voice fill:#FFDAB9,stroke:#000,stroke-width:2px;
    classDef util fill:#FFC0CB,stroke:#000,stroke-width:2px;
    classDef mobile fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef web fill:#F08080,stroke:#000,stroke-width:2px;
    classDef doc fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
