# naveen-prakash-sk/nexora-smart-cabin-automation architecture

> Architecture diagram of the GitHub repository naveen-prakash-sk/nexora-smart-cabin-automation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/naveen-prakash-sk/nexora-smart-cabin-automation
- Repository: https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation

## Overview

Nexora is an embedded cabin-automation system: an ESP32-CAM detects motion and signals a main ESP32, which combines that confirmation with ultrasonic proximity and environmental readings to control lighting and fan speed. A separate camera-webserver sketch provides optional WiFi streaming; its HTTP handlers serve an embedded camera page and image streams. The main firmware implementation was not excerpted, so its documented behavior and links are based on the README, not direct source inspection.

Main entry points: [`firmware/camera_webserver/app_httpd.cpp`](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_webserver/app_httpd.cpp) (Camera HTTP server), [`firmware/main_controller/main_controller.ino`](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino) (Occupancy confirmation), [`firmware/camera_controller/camera_controller.ino`](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_controller/camera_controller.ino) (Camera motion detection), [`firmware/camera_webserver/camera_index.h`](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_webserver/camera_index.h) (Embedded camera page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presence["Occupancy Detection"]
  node_camera_motion["Camera motion detection"]
  node_camera_signal["Camera GPIO signal"]
  node_ultrasonic["Ultrasonic proximity"]
end

subgraph group_control["Cabin Control"]
  node_main_controller["Main controller"]
  node_environment["Environment sensing"]
  node_occupancy_logic["Occupancy confirmation"]
  node_light_control["Automatic lighting"]
  node_fan_control["Temperature fan control"]
end

subgraph group_streaming["Camera Streaming"]
  node_webserver["Camera HTTP server<br/>[app_httpd.cpp]"]
  node_camera_page["Embedded camera page<br/>[camera_index.h]"]
end

node_occupant(("Cabin occupant"))
node_lighting_load["Light load"]
node_fan_relays["Fan relays"]
node_camera["Camera hardware"]
node_browser(("Stream viewer"))

node_occupant -->|"moves before"| node_camera_motion
node_camera_motion -->|"signals presence"| node_camera_signal
node_camera_signal -->|"GPIO signal"| node_main_controller
node_occupant -->|"approaches sensor"| node_ultrasonic
node_ultrasonic -->|"reports distance"| node_occupancy_logic
node_main_controller -->|"combines signals"| node_occupancy_logic
node_main_controller -->|"reads conditions"| node_environment
node_environment -->|"provides brightness"| node_light_control
node_environment -->|"provides temperature"| node_fan_control
node_occupancy_logic -->|"gates lighting"| node_light_control
node_occupancy_logic -->|"gates fan"| node_fan_control
node_light_control -->|"switches"| node_lighting_load
node_fan_control -->|"sets speed"| node_fan_relays
node_browser -.->|"requests stream"| node_webserver
node_webserver -->|"captures frames"| node_camera
node_webserver -->|"serves embedded page"| node_camera_page
node_webserver -->|"streams MJPEG"| node_browser

click node_camera_motion "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_controller/camera_controller.ino"
click node_camera_signal "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_controller/camera_controller.ino"
click node_ultrasonic "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino"
click node_main_controller "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino"
click node_environment "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino"
click node_occupancy_logic "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino"
click node_light_control "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino"
click node_fan_control "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino"
click node_webserver "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_webserver/app_httpd.cpp"
click node_camera_page "https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_webserver/camera_index.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_camera_motion,node_camera_signal,node_ultrasonic,node_browser toneBlue
class node_main_controller,node_environment,node_occupancy_logic,node_light_control,node_fan_control toneAmber
class node_webserver,node_camera_page toneMint
class node_occupant,node_lighting_load,node_fan_relays,node_camera toneIndigo
```

## Components

### Occupancy Detection

- [Camera motion detection](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_controller/camera_controller.ino): `firmware/camera_controller/camera_controller.ino`
- [Camera GPIO signal](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_controller/camera_controller.ino): `firmware/camera_controller/camera_controller.ino`
- [Ultrasonic proximity](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino): `firmware/main_controller/main_controller.ino`

### Cabin Control

- [Main controller](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino): `firmware/main_controller/main_controller.ino`
- [Environment sensing](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino): `firmware/main_controller/main_controller.ino`
- [Occupancy confirmation](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino): `firmware/main_controller/main_controller.ino`
- [Automatic lighting](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino): `firmware/main_controller/main_controller.ino`
- [Temperature fan control](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/main_controller/main_controller.ino): `firmware/main_controller/main_controller.ino`

### Camera Streaming

- [Camera HTTP server](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_webserver/app_httpd.cpp): `firmware/camera_webserver/app_httpd.cpp`
- [Embedded camera page](https://github.com/naveen-prakash-sk/nexora-smart-cabin-automation/blob/main/firmware/camera_webserver/camera_index.h): `firmware/camera_webserver/camera_index.h`

### Other components

- **Cabin occupant**
- **Light load**
- **Fan relays**
- **Camera hardware**
- **Stream viewer**

## Connections

- Cabin occupant → Camera motion detection: moves before (evidence: `README.md`)
- Camera motion detection → Camera GPIO signal: signals presence (evidence: `README.md`)
- Camera GPIO signal → Main controller: GPIO signal (evidence: `README.md`)
- Cabin occupant → Ultrasonic proximity: approaches sensor (evidence: `README.md`)
- Ultrasonic proximity → Occupancy confirmation: reports distance (evidence: `README.md`)
- Main controller → Occupancy confirmation: combines signals (evidence: `README.md`)
- Main controller → Environment sensing: reads conditions (evidence: `README.md`)
- Environment sensing → Automatic lighting: provides brightness (evidence: `README.md`)
- Environment sensing → Temperature fan control: provides temperature (evidence: `README.md`)
- Occupancy confirmation → Automatic lighting: gates lighting (evidence: `README.md`)
- Occupancy confirmation → Temperature fan control: gates fan (evidence: `README.md`)
- Automatic lighting → Light load: switches (evidence: `README.md`)
- Temperature fan control → Fan relays: sets speed (evidence: `README.md`)
- Stream viewer → Camera HTTP server: requests stream (evidence: `README.md`)
- Camera HTTP server → Camera hardware: captures frames (evidence: `firmware/camera_webserver/app_httpd.cpp`)
- Camera HTTP server → Embedded camera page: serves embedded page (evidence: `firmware/camera_webserver/app_httpd.cpp`)
- Camera HTTP server → Stream viewer: streams MJPEG (evidence: `README.md`)
