# dji-sdk/dji-cloud-api-demo architecture

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

- Interactive diagram: https://gitdiagram.com/dji-sdk/dji-cloud-api-demo
- Repository: https://github.com/dji-sdk/dji-cloud-api-demo

## Overview

##### Main Components
a. Cloud SDK Module (found under “cloud-sdk”): This module is the core library. It houses the majority of Java source code and is organized by domain (for example, device, control, debug, flightarea, firmware, hms, interconnection, livestream, log, map, media, organization, property, storage, tsa, wayline, and more). It has configuration packages (including Spring configurations and MQTT related services) that define the main architectural patterns which drive the cloud API.
b. Sample Application Module (found under “sample”): This is a demonstrative, end-to-end implementation built on top of the cloud SDK. It contains controllers, service implementations, DAOs, and configuration files that illustrate the integration of the API in a full-stack Spring (or Spring Boot) application.
c. API Documentation and Tools (found under “api”): There are Postman collections and environments provided, which serve as testing and documentation tools to interact with the API.
d. SQL Scripts (in “sql” folder): Contains the SQL schema or sample data, indicating that a relational database plays a role in data persistence.
e. Docker Support: Hinted by the README (with a downloadable docker image), this shows that the project can be containerized for deployment.

##### Architectural Patterns & Interactions
- The cloud-sdk module is organized by functionality, which suggests a modular layered architecture. Each domain (e.g., device, control, media, etc.) likely represents a bounded context or sub-service, implemented as separate service classes (often with abstract base classes indicating common patterns).
- Communication with external systems is integrated through multiple mechanisms: HTTP/REST endpoints (as seen in sample controllers), MQTT for messaging (with a dedicated “mqtt” package tree), and WebSocket communication (evident from the “websocket” packages).
- There is clear use of configuration layers (Spring based) to wire together components like interceptors (for authentication, CORS), message queues, and database integrations (using Mybatis and Redis).
- The sample module provides a full-stack view of how the API is consumed by the front-facing services (controllers), business logic (services), persistence layers (DAO or repositories), and even media, wayline, and map management functionalities.

##### Technologies and Frameworks
– Java with Maven (pom.xml files at various levels)
– Spring / Spring Boot framework, given the numerous configuration and component classes
– Mybatis for ORM (sample has “mybatis” packages)
– MQTT and WebSocket integrations for real‐time messaging
– Docker containerization for deployment
– Database operations (SQL scripts provided) and possibly Redis for caching (noted by the “redis” component)
– Usage of Postman as documented in the “api” folder for testing/consuming the cloud API
– OSS integration (a specialized “oss” package) to work with various cloud storage solutions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Ext["External Clients"]:::external

    %% API Layer
    subgraph "API Layer"
        APIGateway["API Gateway / REST Controllers"]:::api
    end

    %% Cloud SDK Layer
    subgraph "Cloud SDK Layer"
        CloudSDK["Cloud SDK (Domain Services)\n(Device,Control,Media,Firmware,Organization,etc.)"]:::sdk
    end

    %% Integration Layer
    subgraph "Integration & Messaging Layer"
        MQTT["MQTT Messaging"]:::integration
        WS["WebSocket Messaging"]:::integration
        OSS["OSS Integration (Cloud Storage)"]:::integration
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        Database["SQL Database"]:::persistence
        Cache["Cache (Redis)"]:::persistence
    end

    %% Developer Tools
    subgraph "Developer Tools"
        APIDocs["API Documentation (Postman Collections)"]:::tools
        Docker["Docker Containerization"]:::tools
    end

    %% Relationships
    Ext -->|"HTTP_Request"| APIGateway
    APIGateway -->|"Service_call"| CloudSDK
    CloudSDK -->|"CRUD"| Database
    CloudSDK -->|"Cache_ops"| Cache
    CloudSDK -->|"Publish_MQTT"| MQTT
    CloudSDK -->|"Push_WebSocket"| WS
    CloudSDK -->|"Store_Media"| OSS
    Ext -->|"Testing"| APIDocs

    %% Click Events
    click CloudSDK "https://github.com/dji-sdk/dji-cloud-api-demo/tree/main/cloud-sdk/"
    click APIDocs "https://github.com/dji-sdk/dji-cloud-api-demo/tree/main/api/"
    click APIGateway "https://github.com/dji-sdk/dji-cloud-api-demo/tree/main/sample/"
    click Database "https://github.com/dji-sdk/dji-cloud-api-demo/tree/main/sql/"
    click MQTT "https://github.com/dji-sdk/dji-cloud-api-demo/tree/main/cloud-sdk/src/main/java/com/dji/sdk/mqtt/"
    click WS "https://github.com/dji-sdk/dji-cloud-api-demo/tree/main/cloud-sdk/src/main/java/com/dji/sdk/websocket/"
    click OSS "https://github.com/dji-sdk/dji-cloud-api-demo/tree/main/sample/src/main/java/com/dji/sample/component/oss/"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:2px;
    classDef api fill:#bbf,stroke:#333,stroke-width:2px;
    classDef sdk fill:#cfc,stroke:#333,stroke-width:2px;
    classDef integration fill:#ff9,stroke:#333,stroke-width:2px;
    classDef persistence fill:#fc9,stroke:#333,stroke-width:2px;
    classDef tools fill:#9ff,stroke:#333,stroke-width:2px;
```
