# valery3107/arquitectura_pc architecture

> Architecture diagram of the GitHub repository valery3107/arquitectura_pc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/valery3107/arquitectura_pc
- Repository: https://github.com/valery3107/arquitectura_pc

## Overview

1. **Repository shape**
   - This is a single-sketch ESP32 embedded application: `AZUL.ino` contains the firmware, and `README.md` describes the hardware and features.
   - The architecture is therefore mostly **monolithic at the source level**, but functionally split into independent runtime subsystems.

2. **Execution environment**
   - The target runtime is **Arduino-style firmware on an ESP32**.
   - The app depends on attached peripherals: TFT display, capacitive/resistive touch controller, microSD, DHT11 sensor, buzzer, and LED.

3. **Main orchestration layer**
   - The sketch likely has one central `setup()`/`loop()` lifecycle controlling initialization and then continuously polling the UI, touch input, sensor reads, storage access, and game state.
   - This is the top-level boundary that coordinates all features rather than delegating to separate services or processes.

4. **Display and UI subsystem**
   - The **ILI9341 TFT screen** is the main output surface.
   - The UI provides a **touch-driven menu system** with a “Midnight Emerald” theme, showing feature pages and status views.
   - This is the primary user-facing boundary: all major functions are selected and viewed through this screen.

5. **Touch input subsystem**
   - The **XPT2046 touch controller** is the interaction input channel.
   - Touch is used both for menu navigation and for the Snake game’s on-screen D-pad controls.
   - Input is thus shared between the shell-like menu and the game mode, making touch a cross-cutting dependency.

6. **Environmental sensing subsystem**
   - The **DHT11** provides temperature and humidity readings.
   - These readings are displayed in the UI as a live system-status page, so the sensor data flows from hardware into the display layer with no external storage or network involved.

7. **Storage/files subsystem**
   - The **microSD card** adds file-system-backed content browsing.
   - The app supports directory navigation, file viewing, and a notes reader for `notes.txt`.
   - This is the only persistent data source in the repo, and it is accessed locally on-device through the UI.

8. **Game subsystem**
   - The Snake game is an isolated runtime mode with its own game loop, score tracking, collision/game-over logic, and redraw behavior.
   - It uses the same display and touch input hardware as the main menu, but it is logically separate from the informational and file-browsing features.

9. **Audio and feedback subsystem**
   - The passive **buzzer** provides auditory feedback for interactions and game events.
   - The **LED** acts as a lightweight status indicator.
   - These are auxiliary outputs that reinforce state changes, selection actions, and gameplay events.

10. **System information / diagnostics view**
   - The README mentions a hardware/system info section showing peripheral state and pin configuration.
   - Architecturally, this is a read-only diagnostic page fed by the current runtime configuration rather than a separate subsystem.

11. **Data flow summary**
   - Hardware inputs come from **touch, DHT11, and SD**.
   - The sketch interprets those inputs in firmware, then renders results to the **TFT**, with side effects to **buzzer/LED**.
   - There is no cloud, no networking, and no inter-device messaging in the described architecture.

12. **Key architectural boundary**
   - The important separation for a diagram is between:
     - **Physical peripherals** on the ESP32 pins, and
     - **Feature modes** inside the firmware: menu, sensor view, SD browser, notes viewer, Snake game, and system info.
   - The repo is best drawn as a single embedded controller at the center, with all peripherals connected directly and all features multiplexed through the same UI loop.

Main entry points: [`AZUL.ino`](https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino) (Main loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Firmware"]
  node_sketch["AZUL.ino<br/>embedded sketch<br/>[AZUL.ino]"]
  node_runtime["Main loop<br/>orchestrator<br/>[AZUL.ino]"]
  node_menu["Touch menu<br/>ui shell<br/>[AZUL.ino]"]
  node_sensor_view["Sensor view<br/>status page<br/>[AZUL.ino]"]
  node_sd_browser["SD browser<br/>file browser<br/>[AZUL.ino]"]
  node_notes_viewer["Notes reader<br/>document view<br/>[AZUL.ino]"]
  node_snake_game["Snake game<br/>game mode<br/>[AZUL.ino]"]
  node_diagnostics["System info<br/>diagnostic page<br/>[AZUL.ino]"]
end

subgraph group_hardware["Hardware"]
  node_tft["TFT screen<br/>display output"]
  node_touch["Touch panel<br/>input device"]
  node_dht11(("DHT11<br/>sensor"))
  node_sdcard[("microSD<br/>storage")]
  node_buzzer(("Buzzer<br/>audio output"))
  node_led(("LED<br/>status light"))
  node_notes_file["notes.txt<br/>content file"]
end

node_sketch -->|"runs"| node_runtime
node_runtime -->|"opens"| node_menu
node_runtime -->|"routes"| node_sensor_view
node_runtime -->|"routes"| node_sd_browser
node_runtime -->|"routes"| node_notes_viewer
node_runtime -->|"routes"| node_snake_game
node_runtime -->|"routes"| node_diagnostics
node_menu -->|"uses"| node_touch
node_menu -->|"renders"| node_tft
node_sensor_view -->|"reads"| node_dht11
node_sensor_view -->|"renders"| node_tft
node_sd_browser -->|"reads"| node_sdcard
node_sd_browser -->|"renders"| node_tft
node_notes_viewer -->|"opens"| node_notes_file
node_notes_viewer -->|"reads"| node_sdcard
node_notes_viewer -->|"renders"| node_tft
node_snake_game -->|"controls"| node_touch
node_snake_game -->|"draws"| node_tft
node_snake_game -->|"signals"| node_buzzer
node_snake_game -->|"signals"| node_led
node_diagnostics -->|"renders"| node_tft
node_diagnostics -->|"reports"| node_touch
node_diagnostics -->|"reports"| node_dht11
node_diagnostics -->|"reports"| node_sdcard

click node_sketch "https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino"
click node_runtime "https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino"
click node_menu "https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino"
click node_sensor_view "https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino"
click node_sd_browser "https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino"
click node_notes_viewer "https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino"
click node_snake_game "https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino"
click node_diagnostics "https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino"

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_sketch,node_runtime,node_menu,node_sensor_view,node_sd_browser,node_notes_viewer,node_snake_game,node_diagnostics toneBlue
class node_tft,node_touch,node_dht11,node_sdcard,node_buzzer,node_led,node_notes_file toneAmber
```

## Components

### Firmware

Single ESP32 sketch and its runtime feature modes

- [AZUL.ino](https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino): embedded sketch · Single Arduino-style firmware entry point with setup/loop orchestration · `AZUL.ino`
- [Main loop](https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino): orchestrator · Initializes hardware and multiplexes menu, sensing, storage, and game modes · `AZUL.ino`
- [Touch menu](https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino): ui shell · Main navigation hub for feature pages and status views · `AZUL.ino`
- [Sensor view](https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino): status page · Displays live temperature and humidity readings · `AZUL.ino`
- [SD browser](https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino): file browser · Navigates directories and browses files from the microSD card · `AZUL.ino`
- [Notes reader](https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino): document view · Specialized viewer for notes.txt content · `AZUL.ino`
- [Snake game](https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino): game mode · Independent gameplay loop with score, collisions, and redraws · `AZUL.ino`
- [System info](https://github.com/valery3107/arquitectura_pc/blob/main/AZUL.ino): diagnostic page · Read-only hardware and pin-configuration overview · `AZUL.ino`

### Hardware

Directly attached peripherals and outputs

- **TFT screen**: display output · ILI9341 display surface for all UI, status, and game rendering
- **Touch panel**: input device · XPT2046 touch controller used for navigation and game input
- **DHT11**: sensor · Temperature and humidity source for the status page
- **microSD**: storage · Local file-system storage for directory browsing and notes
- **Buzzer**: audio output · Audible feedback for interactions and gameplay events
- **LED**: status light · Lightweight state indicator for feedback and status
- **notes.txt**: content file · Dedicated text note read by the notes viewer

## Connections

- AZUL.ino → Main loop: runs · Firmware entry point hands control to the main runtime
- Main loop → Touch menu: opens · Main loop presents the navigation shell
- Main loop → Sensor view: routes · Dispatches into live sensor/status rendering
- Main loop → SD browser: routes · Dispatches into SD browsing mode
- Main loop → Notes reader: routes · Dispatches into the notes reader
- Main loop → Snake game: routes · Dispatches into the Snake game loop
- Main loop → System info: routes · Dispatches into the hardware info page
- Touch menu → Touch panel: uses · Menu navigation is driven by touch input
- Touch menu → TFT screen: renders · Menu pages and themed UI are drawn to the display
- Sensor view → DHT11: reads · Fetches live temperature and humidity values
- Sensor view → TFT screen: renders · Shows sensor readings on screen
- SD browser → microSD: reads · Lists directories and opens files from storage
- SD browser → TFT screen: renders · Displays file and directory views
- Notes reader → notes.txt: opens · Loads the dedicated notes document
- Notes reader → microSD: reads · Sources note content from the SD card
- Notes reader → TFT screen: renders · Shows note text on the display
- Snake game → Touch panel: controls · Uses on-screen touch input as a D-pad
- Snake game → TFT screen: draws · Redraws the board, snake, and score
- Snake game → Buzzer: signals · Emits gameplay feedback sounds
- Snake game → LED: signals · Uses LED feedback during game events
- System info → TFT screen: renders · Shows peripheral and pin configuration
- System info → Touch panel: reports · Includes touch hardware state in diagnostics
- System info → DHT11: reports · Includes sensor presence or readings in diagnostics
- System info → microSD: reports · Includes storage state in diagnostics
