# soulee-dev/kdone architecture

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

- Interactive diagram: https://gitdiagram.com/soulee-dev/kdone
- Repository: https://github.com/soulee-dev/kdone

## Overview

##### Project Type Analysis
This is a Python API wrapper library that interfaces with Navien's home network system, focusing on IoT device control and elevator systems. It's a middleware/integration project that serves as a bridge between client applications and Navien's home network infrastructure.

##### Main Components

A. Client Layer:
- External Applications (using the KDOne library)
- Example Web Application (from examples folder)

B. KDOne Library Core:
- API Module (api.py)
- Models Layer
- Utils Layer

C. External Systems:
- Navien Home Network Backend
- IoT Devices (lights, elevator, etc.)

**[Client Applications] → [KDOne Library] → [Navien Home Network]**
- ↘ [IoT Devices]

##### Important Details

A. Authentication Layer:
- [Login] → [Complex Selection] → [Certification] → [Token Generation]

B. Device Control Layer:
- [Device Discovery] → [Device Type Selection] → [Control Commands]

##### Implementation Notes

- The modular structure (api, models, utils)
- The authentication flow's multiple steps
- The device type enumeration system
- The separation between authentication and device control

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        App[Client Applications]
        WebApp["Example Web Application"]:::example
    end

    subgraph KDOne["KDOne Library"]
        API["KDOne API Core"]:::core
        
        subgraph Models["Models Layer"]
            ComplexModel["Complex Model"]:::model
            DeviceModel["Device Model"]:::model
        end
        
        subgraph Utils["Utils Layer"]
            Encryption["Encryption Utils"]:::util
        end
        
        subgraph Auth["Authentication Flow"]
            Login["Login Process"]
            ComplexSelect["Complex Selection"]
            Cert["Certification"]
            Token["Token Generation"]
        end
        
        subgraph DeviceControl["Device Control"]
            Discovery["Device Discovery"]
            TypeSelect["Device Type Selection"]
            Control["Control Commands"]
        end
    end

    subgraph External["External Systems"]
        NavienBackend["Navien Home Network"]:::external
        IoTDevices["IoT Devices"]:::external
    end

    %% Relationships
    App --> API
    WebApp --> API
    API --> Login
    Login --> ComplexSelect
    ComplexSelect --> Cert
    Cert --> Token
    API --> Discovery
    Discovery --> TypeSelect
    TypeSelect --> Control
    
    API <--> NavienBackend
    Control --> IoTDevices
    
    %% Component Interactions
    API --> ComplexModel
    API --> DeviceModel
    API --> Encryption

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef model fill:#4CAF50,stroke:#388E3C,color:white
    classDef util fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef external fill:#9E9E9E,stroke:#616161,color:white
    classDef example fill:#FF9800,stroke:#F57C00,color:white

    %% Click Events
    click API "https://github.com/soulee-dev/KDOne/blob/main/KDOne/api.py"
    click ComplexModel "https://github.com/soulee-dev/KDOne/blob/main/KDOne/models/complex.py"
    click DeviceModel "https://github.com/soulee-dev/KDOne/blob/main/KDOne/models/device.py"
    click Encryption "https://github.com/soulee-dev/KDOne/blob/main/KDOne/utils/encryption.py"
    click WebApp "https://github.com/soulee-dev/KDOne/blob/main/examples/main.py"
    click Models "https://github.com/soulee-dev/KDOne/tree/main/KDOne/models/"
    click Utils "https://github.com/soulee-dev/KDOne/tree/main/KDOne/utils/"

    %% Legend
    subgraph Legend
        L1["API Core"]:::core
        L2["Models"]:::model
        L3["Utils"]:::util
        L4["External Systems"]:::external
        L5["Example Apps"]:::example
    end
```
