# yorick-xy/destis architecture

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

- Interactive diagram: https://gitdiagram.com/yorick-xy/destis
- Repository: https://github.com/yorick-xy/destis

## Overview

##### Project Type and Purpose
- Destis is a hybrid robotics + home-automation application with an AI/ML component. It is neither a classic web full-stack app nor a pure library: it integrates
- an autonomous robot (navigation, obstacle avoidance, motor control, sensors)
- a home-automation subsystem (device control via MQTT, voice commands)
- AI/ML modules (chatbot, NLP, vision, speech)
- a CLI interface (src/main.py) for orchestration and user interaction

##### File‐Structure Analysis
- Top‐level scripts & configs:
- setup.py, requirements.txt – packaging and dependencies
- scripts/ – deploy.sh, format_code.sh, run_tests.sh
- data/ – potential datasets or simulation logs
- architecture.txt – placeholder for existing architectural notes
- Source tree (src/): four main packages:
- ai/ – chatbot.py, core.py, models.py, NLP, speech_recognition/synthesis, vision, etc.
- home_automation/ – mqtt_client.py, device_control.py, routines.py
- robot/ – sensors.py, navigation.py, obstacle_avoidance.py, motor_control.py, mock_gpio.py
- utils/ – config readers (YAML), database, logger, exception_handler
- Entry point: src/main.py ties everything together
- tests/ – unit tests for each subsystem

##### README Insights
- Features: autonomous navigation, obstacle avoidance, device control via voice/MQTT, AI conversational engine
- Simulation constraints: hardware calls are mocked, only chatbot is fully functional
- Relies on DialoGPT (via PyTorch) for conversation

a. Main Components
- User Interface (CLI)
- Orchestrator (main.py)
- AI Subsystem
– Data Preprocessing
– Models (DialoGPT, vision, speech)
– NLP, SpeechRecognition, SpeechSynthesis
- Home Automation Subsystem
– Routines Engine
– MQTT Client
– Device Control
- Robot Control Subsystem
– Sensor Interface
– Obstacle Avoidance
– Navigation Planner
– Motor Control / GPIO (mocked)
- Utility Services
– Configuration Loader (YAML)
– Logging & Exception Handling
– Database (local state, logs)
- External Services & Hardware
– MQTT Broker
– Sensors & Actuators (motors, distance sensors)
– (Optionally) DialoGPT Cloud or Local Model

b. Relationships & Data Flows
1. User issues a command at the CLI → main.py
2. main.py parses input → dispatches to AI Subsystem (for voice/NLP) or to Control Subsystems
3. AI Subsystem may call Data Preprocessing → Models → returns intent/response
4. If home-automation intent: orchestrator → home_automation.routines → mqtt_client → external MQTT Broker → devices
5. If robot intent: orchestrator → robot.sensors (reads) → obstacle_avoidance → navigation → motor_control → actuators
6. Throughout, utils/logger logs events; utils/database persists state; utils/config supplies parameters

c. Architectural Patterns & Principles
- Modular layering: clear separation between AI, control, utils
- Dependency injection via utils/config
- Mocking hardware in tests (mock_gpio) for CI
- Single entry point (main.py) orchestrates modules

d. Key Technologies & Frameworks
- Python 3.7+
- PyTorch / HuggingFace (DialoGPT)
- paho-mqtt (or similar) for MQTT client
- YAML for configuration
- unittest/pytest for tests

##### Final Advice
- Incrementally refine: add utils/config & database as supporting services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User & Orchestrator
    subgraph "User & Orchestrator"
        UI["User Terminal"]:::ui
        Main["Orchestrator"]:::ui
    end
    UI -->|"command"| Main
    click Main "https://github.com/yorick-xy/destis/blob/main/src/main.py"

    %% AI Subsystem
    subgraph "AI Subsystem"
        CP["Data Preprocessing"]:::ai
        Models["Models"]:::ai
        NLP["NLP Module"]:::ai
        SR["Speech Recognition"]:::ai
        SS["Speech Synthesis"]:::ai
        Vision["Vision Processing"]:::ai
        CoreEng["Core Engine"]:::ai
        Chatbot["Chatbot Core"]:::ai
        ConfigAI["Config"]:::ai
    end
    Main -->|"intent|voice"| CP
    CP --> Models
    Models --> CoreEng
    CoreEng --> Chatbot
    Chatbot --> NLP
    NLP --> SR
    NLP --> SS
    NLP --> Vision
    CP -->|"params"| ConfigAI

    click CP "https://github.com/yorick-xy/destis/blob/main/src/ai/data_preprocessing.py"
    click Models "https://github.com/yorick-xy/destis/blob/main/src/ai/models.py"
    click NLP "https://github.com/yorick-xy/destis/blob/main/src/ai/nlp.py"
    click SR "https://github.com/yorick-xy/destis/blob/main/src/ai/speech_recognition.py"
    click SS "https://github.com/yorick-xy/destis/blob/main/src/ai/speech_synthesis.py"
    click Vision "https://github.com/yorick-xy/destis/blob/main/src/ai/vision.py"
    click CoreEng "https://github.com/yorick-xy/destis/blob/main/src/ai/core.py"
    click Chatbot "https://github.com/yorick-xy/destis/blob/main/src/ai/chatbot.py"
    click ConfigAI "https://github.com/yorick-xy/destis/blob/main/src/ai/config.py"

    %% Home Automation Subsystem
    subgraph "Home Automation Subsystem"
        Routines["Routines Engine"]:::control
        MQTT["MQTT Client"]:::control
        Device["Device Control"]:::control
    end
    Main -->|"home intent"| Routines
    Routines --> MQTT
    MQTT --> Device
    Device -->|"MQTT publish"| ExternalBroker

    click Routines "https://github.com/yorick-xy/destis/blob/main/src/home_automation/routines.py"
    click MQTT "https://github.com/yorick-xy/destis/blob/main/src/home_automation/mqtt_client.py"
    click Device "https://github.com/yorick-xy/destis/blob/main/src/home_automation/device_control.py"

    %% Robot Control Subsystem
    subgraph "Robot Control Subsystem"
        Sensors["Sensor Interface"]:::control
        Obstacle["Obstacle Avoidance"]:::control
        Navigation["Navigation Planner"]:::control
        Motor["Motor Control"]:::control
        GPIOMock["GPIO Mock (Simulation)"]:::control
    end
    Main -->|"robot intent"| Sensors
    Sensors --> Obstacle
    Obstacle --> Navigation
    Navigation --> Motor
    Motor -->|"drive signal"| ExternalHardware
    Motor --> GPIOMock

    click Sensors "https://github.com/yorick-xy/destis/blob/main/src/robot/sensors.py"
    click Obstacle "https://github.com/yorick-xy/destis/blob/main/src/robot/obstacle_avoidance.py"
    click Navigation "https://github.com/yorick-xy/destis/blob/main/src/robot/navigation.py"
    click Motor "https://github.com/yorick-xy/destis/blob/main/src/robot/motor_control.py"
    click GPIOMock "https://github.com/yorick-xy/destis/blob/main/src/robot/mock_gpio.py"

    %% Utility Services
    subgraph "Utility Services"
        ConfigLoader["Configuration Loader"]:::utils
        Database["Database"]:::utils
        Logger["Logger"]:::utils
        Exception["Exception Handler"]:::utils
    end
    Main --> ConfigLoader
    Main --> Logger
    Main --> Database
    Main --> Exception
    ConfigLoader --> CP
    ConfigLoader --> Routines
    ConfigLoader --> Sensors
    Logger -->|"logs"| Database

    click ConfigLoader "https://github.com/yorick-xy/destis/blob/main/src/utils/config.py"
    click Database "https://github.com/yorick-xy/destis/blob/main/src/utils/database.py"
    click Logger "https://github.com/yorick-xy/destis/blob/main/src/utils/logger.py"
    click Exception "https://github.com/yorick-xy/destis/blob/main/src/utils/exception_handler.py"

    %% External Systems & Hardware
    subgraph "External Systems & Hardware"
        ExternalBroker["MQTT Broker"]:::external
        ExternalHardware["Sensors & Actuators"]:::external
        DialoGPT["DialoGPT Model Service"]:::external
    end
    CoreEng -->|"model call"| DialoGPT

    click ExternalBroker "https://github.com/yorick-xy/destis/tree/main/ExternalBroker"
    click ExternalHardware "https://github.com/yorick-xy/destis/tree/main/ExternalHardware"
    click DialoGPT "https://github.com/yorick-xy/destis/tree/main/DialoGPT"

    %% Styles
    classDef ui fill:#DAD2E0,stroke:#8C6A9E,color:#000
    classDef ai fill:#CCE5FF,stroke:#66B2FF,color:#000
    classDef control fill:#D4EDDA,stroke:#28A745,color:#000
    classDef utils fill:#E2E3E5,stroke:#6C757D,color:#000
    classDef external fill:#FFE5CC,stroke:#FF9900,color:#000
```
