# its-serah/explavision-hardware-component architecture

> Architecture diagram of the GitHub repository its-serah/explavision-hardware-component, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/its-serah/explavision-hardware-component
- Repository: https://github.com/its-serah/explavision-hardware-component

## Overview

##### Project type and purpose
- This is a hybrid IoT-enabled full-stack application. It integrates an ESP8266 microcontroller (edge device) with a Node.js backend and AWS S3 cloud storage.
- Purpose: monitor motion via an IR sensor, trigger a webcam capture on the server, upload the image to S3, and notify the microcontroller.

##### File structure
- Top-level
– README.md: project overview and setup
– ServerCam/: Node.js server code
- index.js (server entrypoint)
- captures/: local folder for saved images
- package.json, package-lock.json, .gitignore
– microcontroller/: ESP8266 Arduino sketch (CircuitCode.ino)
- Key observations
– “ServerCam/index.js” implies an Express-based HTTP endpoint (likely /capture).
– “captures” directory: local persistence before S3 upload.
– Arduino sketch uses HTTPClient to call the server.
– AWS credentials and S3 interactions live in Node.js code (node-fetch or AWS SDK).

##### README for additional insights
- Node.js server uses express, fs, path, node-webcam, node-fetch.
- ESP8266 code includes ESP8266WiFi.h and ESP8266HTTPClient.h.
- Workflow: IR sensor → ESP8266 triggers HTTP → server takes webcam photo → save to local → upload to AWS S3 → respond to ESP8266.

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef device fill:#cce5ff,stroke:#000;
    classDef server fill:#d4edda,stroke:#000;
    classDef cloud fill:#fff3cd,stroke:#000;
    classDef external fill:#eeeeee,stroke:#000;

    subgraph "IoT Edge Device"
        IRsensor((IR Sensor)):::device
        ESP8266["ESP8266 + IR sensor\n(ESP8266WiFi, ESP8266HTTPClient)"]:::device
    end

    subgraph "Local Server"
        NodeServer["Node.js Server\nExpress (/capture)\nPort 3000\nnode-webcam, node-fetch/AWS SDK"]:::server
        Storage["Local Storage\n/ServerCam/captures"]:::server
        Dependencies["Server Dependencies\npackage.json"]:::server
    end

    S3[(AWS S3 Bucket)]:::cloud
    README["README.md"]:::external

    IRsensor -->|"detect motion"| ESP8266
    ESP8266 -->|"POST /capture"| NodeServer
    NodeServer -->|"capture image"| Storage
    NodeServer -->|"upload image"| S3
    S3 -->|"200 OK"| NodeServer
    NodeServer -->|"200 OK"| ESP8266
    README --> NodeServer

    click ESP8266 "https://github.com/its-serah/explavision-hardware-component/blob/main/microcontroller/CircuitCode.ino"
    click NodeServer "https://github.com/its-serah/explavision-hardware-component/blob/main/ServerCam/index.js"
    click Storage "https://github.com/its-serah/explavision-hardware-component/tree/main/ServerCam/captures/"
    click Dependencies "https://github.com/its-serah/explavision-hardware-component/blob/main/ServerCam/package.json"
    click README "https://github.com/its-serah/explavision-hardware-component/blob/main/README.md"
```
