# cedced19/garage-doors-opener architecture

> Architecture diagram of the GitHub repository cedced19/garage-doors-opener, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cedced19/garage-doors-opener
- Repository: https://github.com/cedced19/garage-doors-opener

## Overview

##### Project type and purpose
- This is an IoT-based, full-stack garage-door opener system.
- Hardware layer: ESP8266/NodeMCU (with or without Arduino Uno), optional Raspberry Pi.
- Backend/microservices:
- util-clock (Node.js scheduling service with web admin UI)
- watch-over (Dockerized monitoring service)
- Mobile frontends: two React Native apps (“mobile” and “mobile-new”).
- Purpose: remotely toggle and monitor garage doors via HTTP(S), optionally schedule tasks or continuous monitoring.

##### File structure
- Top-level folders by function:
- arduino-esp8266 / arduino-ethernet / nodemcu* / little-door – firmware sketches for different hardware setups
- raspberry – Python script + systemd service for Pi-based version
- util-clock – Node.js cron task manager + Express/EJS-based admin UI + REST-style garage APIs
- watch-over – Docker+Node.js service for monitoring endpoints
- mobile, mobile-new – two React Native app variants, each with Android/iOS projects plus shared JS/TS code
- Configuration and deployment files:
- docker-compose.yml and Dockerfile in watch-over
- garage-doors-opener.service files (systemd) in raspberry and watch-over
- Build scripts: gulpfile.js in util-clock, gradle files in mobile-new/android, Buck/Gradle in mobile/android.

##### README for additional insights
- Core API routes:
- GET /garage/{id}/toggle/{password}
- GET /garage/{id}/status/{password}
- Emphasis on using a reverse proxy (e.g., Caddy) for HTTPS.
- Three hardware schemas (Arduino+ESP8266, NodeMCU, Arduino+Ethernet, Raspberry Pi).
- Demo credentials and URLs for testing.

##### Elements
- Clear, descriptive labels for each component (e.g., “ESP8266 HTTP Server”, “Caddy HTTPS Proxy”, “util-clock Scheduler”).
- Clients → Proxy → Device/Service
- Services → Device API
- Device → Sensor data → Service or direct client fetch
- Hardware (e.g., orange rectangles)
- Microservices (e.g., green hexagons)
- Clients (e.g., purple rounded rectangles)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Public Internet and Proxy
    Internet["Public Internet"]:::internet
    Caddy["Caddy HTTPS Proxy"]:::proxy
    Internet --> Caddy
    Caddy --> Router

    %% Home Router
    Router["Home Router<br/>Port Forwarding"]:::network

    %% IoT Devices Layer
    subgraph "IoT Devices" 
        direction TB
        ESPUno["ESP8266 + Arduino UNO HTTP Server"]:::hardware
        ESP8266Only["ESP8266-Only (NodeMCU) HTTP Server"]:::hardware
        Ethernet["Arduino + Ethernet Shield HTTP Server"]:::hardware
        LittleFinal["Little-Door Relay+Sensor"]:::hardware
        LittleRelay["Little-Door Relay Only"]:::hardware
        LittleSensor["Little-Door Sensor Only"]:::hardware
        TestSketches["Other Little-Door Test Sketches"]:::hardware
        NodeMCUWFM["NodeMCU WiFiManager Sketch"]:::hardware
        NodeMCU1WFM["NodeMCU 1-Door (WiFiManager) Sketch"]:::hardware
        NodeMCU1["NodeMCU 1-Door Sketch"]:::hardware
        BaseNodeMCU["Base NodeMCU Sketch"]:::hardware
    end

    Router --> IoTDevices

    %% Backend Services Layer
    subgraph "Backend Services"
        direction TB
        utilClock["util-clock Scheduler & Admin UI"]:::service
        watchOver["watch-over Monitoring Service"]:::service
        Raspi["Raspberry Pi Controller"]:::service
    end

    Router --> utilClock
    Router --> watchOver
    Router --> Raspi

    %% Clients Layer
    subgraph "Clients"
        direction TB
        mobileLegacy["Mobile App (React Native)"]:::client
        mobileNew["Mobile-New App (React Native TS)"]:::client
        webAdmin["Web Admin UI"]:::client
    end

    mobileLegacy -->|HTTPS| Internet
    mobileNew -->|HTTPS| Internet
    webAdmin -->|HTTPS| Internet

    %% Service Interactions
    utilClock -->|"/garage/{id}/toggle/{pwd}"| IoTDevices
    utilClock -->|"/garage/{id}/status/{pwd}"| IoTDevices
    watchOver -->|Health Check HTTP| IoTDevices
    Raspi -->|Local HTTP Calls| IoTDevices

    %% Click Events
    click ESPUno "https://github.com/cedced19/garage-doors-opener/blob/master/arduino-esp8266/arduino/arduino.ino"
    click ESP8266Only "https://github.com/cedced19/garage-doors-opener/blob/master/arduino-esp8266/esp8266/esp8266.ino"
    click Ethernet "https://github.com/cedced19/garage-doors-opener/blob/master/arduino-ethernet/arduino-ethernet.ino"
    click LittleFinal "https://github.com/cedced19/garage-doors-opener/blob/master/little-door/final_version/final_version.ino"
    click LittleRelay "https://github.com/cedced19/garage-doors-opener/blob/master/little-door/only_relay/only_relay.ino"
    click LittleSensor "https://github.com/cedced19/garage-doors-opener/blob/master/little-door/read_sensor/read_sensor.ino"
    click TestSketches "https://github.com/cedced19/garage-doors-opener/tree/master/little-door/test_*"
    click NodeMCUWFM "https://github.com/cedced19/garage-doors-opener/blob/master/nodemcu-wifimanager/nodemcu-wifimanager.ino"
    click NodeMCU1WFM "https://github.com/cedced19/garage-doors-opener/blob/master/nodemcu-1-door-wifimanager/nodemcu-1-door-wifimanager.ino"
    click NodeMCU1 "https://github.com/cedced19/garage-doors-opener/blob/master/nodemcu-1-door/nodemcu-1-door.ino"
    click BaseNodeMCU "https://github.com/cedced19/garage-doors-opener/blob/master/nodemcu/nodemcu.ino"
    click Raspi "https://github.com/cedced19/garage-doors-opener/blob/master/raspberry/index.py"
    click utilClock "https://github.com/cedced19/garage-doors-opener/blob/master/util-clock/app.js"
    click watchOver "https://github.com/cedced19/garage-doors-opener/blob/master/watch-over/app/index.js"
    click mobileLegacy "https://github.com/cedced19/garage-doors-opener/blob/master/mobile/App.js"
    click mobileNew "https://github.com/cedced19/garage-doors-opener/blob/master/mobile-new/app/index.tsx"
    click webAdmin "https://github.com/cedced19/garage-doors-opener/blob/master/util-clock/public/views/index.html"

    %% Styles
    classDef hardware fill:#f9c784,stroke:#e67e22,color:#000
    classDef network fill:#aed6f1,stroke:#3498db,color:#000
    classDef proxy fill:#85c1e9,stroke:#21618c,color:#fff
    classDef service fill:#abebc6,stroke:#28b463,color:#000
    classDef client fill:#d7bde2,stroke:#8e44ad,color:#000
    classDef internet fill:#d5dbdb,stroke:#7f8c8d,color:#000
```
