# alfonsorodr/empotrados architecture

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

- Interactive diagram: https://gitdiagram.com/alfonsorodr/empotrados
- Repository: https://github.com/alfonsorodr/empotrados

## Overview

##### Project type and purpose
- This is an embedded IoT security system (“caja fuerte inteligente”) split into two independent subsystems:
- Bloque 1: Safe‑control logic on an Arduino‑style board (keypad, fingerprint, motor lock, LCD, buzzer, PIR)
- Bloque 2: ESP32‑CAM based camera server with temperature monitoring (DHT11) and fan control
- The README confirms two activity flows: user authentication/unlock (block 1) and live video + cooling (block 2).

##### File structure
- Top‑level directories:
- Material de Apoyo: assorted example sketches (DHT11, fingerprint, IR, keypad, LCD, PIR)
- PracticaObligatoriaEmp: previous Arduino sketch
- Proyecto: your actual deliverable code, with subfolders:
– MainProgram: core safe‑control logic (.ino, .cpp/.h for fingerprint, motor lock, password manager, temperature‑fan)
– CameraWebServer: ESP32‑CAM HTTP server code (.ino + .cpp, headers, JSON, partitions)
– Password, PasswordResult, RemoteControl: standalone test/demo sketches
- No traditional backend/frontend folders—this is firmware and electronics.

##### README for additional insights
- The two “bloques” are explicitly independent: no serial or Wi‑Fi linkage between them
- Required materials (sensors, camera module) confirm hardware components

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Common Power Supply
    PowerSupply["5V / GND Power Rail"]:::power

    %% Bloque 1: Safe Controller
    subgraph "Bloque 1: Safe Controller MCU"
        direction TB
        SafeMCU["Safe Controller MCU"]:::controller
        subgraph "Firmware Modules (Bloque 1)"
            direction TB
            PasswordManager["PasswordManager"]:::module
            FingerprintImpl["FingerprintImpl"]:::module
            MotorLockMod["MotorLock"]:::module
            TemperatureFanController1["TemperatureFanController"]:::module
        end
    end

    %% Sensors and Actuators for Bloque 1
    Keypad["Keypad\n(4x4 Matrix)"]:::sensor -->|"digital I/O"| SafeMCU
    Fingerprint["Fingerprint Sensor\n(UART)"]:::sensor -->|"UART"| SafeMCU
    PIR["PIR Sensor"]:::sensor -->|"digital I/O"| SafeMCU

    SafeMCU -->|"uses"| PasswordManager
    SafeMCU -->|"uses"| FingerprintImpl
    SafeMCU -->|"uses"| MotorLockMod
    SafeMCU -->|"uses"| TemperatureFanController1

    SafeMCU -->|"digital I/O"| Motor["Motor Lock"]:::actuator
    SafeMCU -->|"I2C"| LCD["LCD Display\n(I2C)"]:::actuator
    SafeMCU -->|"digital I/O"| Buzzer["Buzzer/LEDs"]:::actuator

    %% Bloque 2: ESP32-CAM Camera Server
    subgraph "Bloque 2: ESP32-CAM Camera Server"
        direction TB
        CameraMCU["ESP32-CAM MCU"]:::controller
        subgraph "Camera Server Modules"
            direction TB
            app_httpd["app_httpd.cpp"]:::module
            camera_index["camera_index.h"]:::module
            camera_pins["camera_pins.h"]:::module
            ci_json["ci.json"]:::module
            partitions["partitions.csv"]:::module
        end
    end

    %% Sensors and Actuators for Bloque 2
    DHT11["DHT11 Sensor"]:::sensor -->|"digital I/O"| CameraMCU
    CameraMCU -->|"digital I/O"| Fan["Fan Control\n(Transistor)"]:::actuator
    CameraMCU -->|"runs"| app_httpd
    CameraMCU -->|"Wi-Fi"| WiFi["Wi-Fi Radio"]:::network
    Browser["User Browser"]:::network -->|"HTTP request/response"| WiFi

    %% Power connections
    PowerSupply --> SafeMCU
    PowerSupply --> CameraMCU

    %% Click Events
    click SafeMCU "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/MainProgram/MainProgram.ino"
    click PasswordManager "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/MainProgram/PasswordManager.h"
    click FingerprintImpl "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/MainProgram/FingerprintEsp.h"
    click MotorLockMod "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/MainProgram/MotorLock.h"
    click TemperatureFanController1 "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/MainProgram/TemperatureFanController.h"
    click CameraMCU "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/CameraWebServer/CameraWebServer.ino"
    click app_httpd "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/CameraWebServer/app_httpd.cpp"
    click camera_index "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/CameraWebServer/camera_index.h"
    click camera_pins "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/CameraWebServer/camera_pins.h"
    click ci_json "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/CameraWebServer/ci.json"
    click partitions "https://github.com/alfonsorodr/empotrados/blob/main/Proyecto/CameraWebServer/partitions.csv"

    %% Styles
    classDef sensor fill:#ADD8E6,stroke:#000,color:#000;
    classDef actuator fill:#90EE90,stroke:#000,color:#000;
    classDef controller fill:#FFA500,stroke:#000,color:#000;
    classDef network fill:#D3D3D3,stroke:#000,color:#000;
    classDef module fill:#FFFACD,stroke:#000,color:#000;
    classDef power fill:#CCCCCC,stroke:#000,color:#000;
```
