# ivancordova/smart-doorbell-api architecture

> Architecture diagram of the GitHub repository ivancordova/smart-doorbell-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ivancordova/smart-doorbell-api
- Repository: https://github.com/ivancordova/smart-doorbell-api

## Overview

Smart Doorbell is a multi-service ESP32-CAM doorbell: the API streams video, identifies visitors, records events, and serves a web panel; voice handles visitor announcements and wake-word commands; NLU interprets commands and returns spoken responses and actions. The documented command path runs from microphone/ASR through voice and NLU, consults API state for CHECK, then returns commands through the API to the camera relay. The API implementation is sampled only in part; unsampled capabilities and service links are included where the README documents them.

Main entry points: [`services/api/app/main.py`](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/main.py) (Video API), [`services/nlu/app/main.py`](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/main.py) (NLU orchestration), [`services/voice/app/voice_service.py`](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/voice/app/voice_service.py) (Voice orchestration), [`services/nlu/app/nlu_service.py`](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/nlu_service.py) (NLU HTTP adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_video["Video gateway"]
  node_api["Video API<br/>[main.py]"]
  node_vision["Face detection and recognition<br/>[main.py]"]
  node_visit_events[("Visit and event history<br/>[main.py]")]
  node_people[("People registry<br/>[main.py]")]
  node_web_panel["Web panel<br/>[home.html]"]
  node_registration_view["Registration view<br/>[register.html]"]
end

subgraph group_voice["Voice service"]
  node_voice_service["Voice orchestration<br/>[voice_service.py]"]
  node_asr["Audio capture and ASR<br/>[audio_asr.py]"]
  node_wake["Wake word and command FSM<br/>[voice_service.py]"]
  node_tts["Speech output<br/>[voice_service.py]"]
end

subgraph group_nlu["Language and access"]
  node_nlu_http["NLU HTTP adapter<br/>[nlu_service.py]"]
  node_nlu_orchestrator["NLU orchestration<br/>[main.py]"]
  node_preprocessor["Lexical normalization<br/>[preprocesador.py]"]
  node_syntax["Dependency analysis"]
  node_legacy_intents["Legacy intent matching<br/>[intents.py]"]
  node_ontology[("Access ontology<br/>[ontologia.py]")]
  node_actuator["Action executor<br/>[actuador.py]"]
end

subgraph group_hardware["Camera and access"]
  node_esp32["ESP32-CAM"]
  node_relay["Camera relay client<br/>[relay.py]"]
end

node_visitor(("Visitor"))
node_operator(("Panel user"))

node_visitor -->|"appears before"| node_esp32
node_esp32 -->|"sends MJPEG"| node_api
node_api -->|"processes frames"| node_vision
node_vision -->|"records events"| node_visit_events
node_vision -->|"matches registered faces"| node_people
node_api -->|"renders panel"| node_web_panel
node_api -->|"renders registration"| node_registration_view
node_operator -->|"uses"| node_web_panel
node_api -->|"announces visitors"| node_voice_service
node_voice_service -->|"uses recognizer"| node_asr
node_asr -->|"provides audio chunks"| node_wake
node_wake -->|"submits transcript"| node_nlu_http
node_nlu_http -->|"classifies text"| node_nlu_orchestrator
node_nlu_orchestrator -->|"normalizes text"| node_preprocessor
node_nlu_orchestrator -->|"analyzes syntax"| node_syntax
node_nlu_orchestrator -->|"checks compatibility"| node_legacy_intents
node_nlu_orchestrator -->|"resolves access"| node_ontology
node_nlu_orchestrator -->|"executes action"| node_actuator
node_actuator -->|"updates access state"| node_ontology
node_nlu_http -->|"reads CHECK context"| node_api
node_nlu_http -->|"returns command and reply"| node_voice_service
node_voice_service -->|"speaks response"| node_tts
node_voice_service -->|"sends voice command"| node_api
node_api -->|"dispatches relay action"| node_relay
node_relay -->|"calls relay endpoint"| node_esp32

click node_api "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/main.py"
click node_vision "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/main.py"
click node_visit_events "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/main.py"
click node_people "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/main.py"
click node_web_panel "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/templates/home.html"
click node_registration_view "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/templates/register.html"
click node_relay "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/relay.py"
click node_voice_service "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/voice/app/voice_service.py"
click node_asr "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/voice/app/audio_asr.py"
click node_wake "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/voice/app/voice_service.py"
click node_tts "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/voice/app/voice_service.py"
click node_nlu_http "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/nlu_service.py"
click node_nlu_orchestrator "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/main.py"
click node_preprocessor "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/preprocesador.py"
click node_syntax "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/analizador_sintactico.py"
click node_legacy_intents "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/intents.py"
click node_ontology "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/ontologia.py"
click node_actuator "https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/actuador.py"

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_api,node_vision,node_visit_events,node_people,node_web_panel,node_registration_view,node_operator toneBlue
class node_voice_service,node_asr,node_wake,node_tts toneAmber
class node_nlu_http,node_nlu_orchestrator,node_preprocessor,node_syntax,node_legacy_intents,node_ontology,node_actuator toneMint
class node_esp32,node_relay toneRose
class node_visitor toneIndigo
```

## Components

### Video gateway

- [Video API](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/main.py): `services/api/app/main.py`
- [Face detection and recognition](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/main.py): `services/api/app/main.py`
- [Visit and event history](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/main.py): `services/api/app/main.py`
- [People registry](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/main.py): `services/api/app/main.py`
- [Web panel](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/templates/home.html): `services/api/templates/home.html`
- [Registration view](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/templates/register.html): `services/api/templates/register.html`

### Voice service

- [Voice orchestration](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/voice/app/voice_service.py): `services/voice/app/voice_service.py`
- [Audio capture and ASR](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/voice/app/audio_asr.py): `services/voice/app/audio_asr.py`
- [Wake word and command FSM](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/voice/app/voice_service.py): `services/voice/app/voice_service.py`
- [Speech output](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/voice/app/voice_service.py): `services/voice/app/voice_service.py`

### Language and access

- [NLU HTTP adapter](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/nlu_service.py): `services/nlu/app/nlu_service.py`
- [NLU orchestration](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/main.py): `services/nlu/app/main.py`
- [Lexical normalization](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/preprocesador.py): `services/nlu/app/preprocesador.py`
- [Dependency analysis](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/analizador_sintactico.py): `services/nlu/app/analizador_sintactico.py`
- [Legacy intent matching](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/intents.py): `services/nlu/app/intents.py`
- [Access ontology](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/ontologia.py): `services/nlu/app/ontologia.py`
- [Action executor](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/nlu/app/actuador.py): `services/nlu/app/actuador.py`

### Camera and access

- **ESP32-CAM**
- [Camera relay client](https://github.com/ivancordova/smart-doorbell-api/blob/main/services/api/app/relay.py): `services/api/app/relay.py`

### Other components

- **Visitor**
- **Panel user**

## Connections

- Visitor → ESP32-CAM: appears before (evidence: `README.md`)
- ESP32-CAM → Video API: sends MJPEG (evidence: `README.md`)
- Video API → Face detection and recognition: processes frames (evidence: `README.md`)
- Face detection and recognition → Visit and event history: records events (evidence: `README.md`)
- Face detection and recognition → People registry: matches registered faces (evidence: `README.md`)
- Video API → Web panel: renders panel (evidence: `README.md`)
- Video API → Registration view: renders registration (evidence: `README.md`)
- Panel user → Web panel: uses (evidence: `README.md`)
- Video API → Voice orchestration: announces visitors (evidence: `README.md`)
- Voice orchestration → Audio capture and ASR: uses recognizer (evidence: `services/voice/app/voice_service.py`)
- Audio capture and ASR → Wake word and command FSM: provides audio chunks (evidence: `services/voice/app/voice_service.py`)
- Wake word and command FSM → NLU HTTP adapter: submits transcript (evidence: `README.md`)
- NLU HTTP adapter → NLU orchestration: classifies text (evidence: `services/nlu/app/nlu_service.py`)
- NLU orchestration → Lexical normalization: normalizes text (evidence: `services/nlu/app/main.py`)
- NLU orchestration → Dependency analysis: analyzes syntax (evidence: `services/nlu/app/main.py`)
- NLU orchestration → Legacy intent matching: checks compatibility (evidence: `services/nlu/app/main.py`)
- NLU orchestration → Access ontology: resolves access (evidence: `services/nlu/app/main.py`)
- NLU orchestration → Action executor: executes action (evidence: `services/nlu/app/main.py`)
- Action executor → Access ontology: updates access state (evidence: `services/nlu/app/actuador.py`)
- NLU HTTP adapter → Video API: reads CHECK context (evidence: `services/nlu/app/nlu_service.py`)
- NLU HTTP adapter → Voice orchestration: returns command and reply (evidence: `README.md`)
- Voice orchestration → Speech output: speaks response (evidence: `README.md`)
- Voice orchestration → Video API: sends voice command (evidence: `README.md`)
- Video API → Camera relay client: dispatches relay action (evidence: `services/api/app/main.py`)
- Camera relay client → ESP32-CAM: calls relay endpoint (evidence: `README.md`)
