# code-hauptwache/dronedeck architecture

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

- Interactive diagram: https://gitdiagram.com/code-hauptwache/dronedeck
- Repository: https://github.com/code-hauptwache/dronedeck

## Overview

##### Project type and purpose
- This is a full‐stack desktop GUI application written in Java using Swing (FlatLaf) that follows an MVC pattern.
- It integrates with an external RESTful DroneSim API for live data but also supports a demo mode with mock data.
- Core features: data visualization (charts, dashboards), token‐based API access, local caching, multithreaded data refresh.

##### File structure
- Top‐level directories:
- src/main/java – main application code
- src/main/resources – configuration and manifest
- demo & drone_data.bin/drone_type_data.bin – demo assets & cached data
- test – JUnit tests mirroring the main packages
- Package breakdown under src/main/java:
- controllers – entry points for UI events
- services – business logic (API integration, data calculation, refresh, caching, search, geocoding, scrolling)
- dao – local data access layer reading/writing binary files
- entity/enums – domain models and helper types
- ui – view layer (components, pages, DTOs, themes)
- exceptions – custom error types
- examples – sample cards & charts

##### Extract additional insights from README
- Explicit MVC architecture: UI → Controller → Service → DataAccess → External API.
- Highlights multithreading in data refresh, token authentication, and local caching.

a. Main components
- UI Layer (Swing components, pages, dialogs)
- Controller Layer (DroneController + interfaces)
- Service Layer
- DroneApiService / MockDroneApiService (REST integration)
- ApiTokenService (authentication)
- DataRefreshService (multithreaded fetch)
- DroneDataCalculationService (geometry, metrics)
- DroneStatusService (status aggregation)
- LocalSearchService (offline search)
- ReverseGeocodeService (address lookup)
- ScrollPaneService (UI scrolling)
- Data Access Layer (LocalDroneDao, LocalDroneTypeDao reading/writing drone_data.bin)
- External Systems
- DroneSim REST API
- Local file storage (binary caches)

b. Relationships & interactions
1. UI events (button clicks, page navigation) → Controller
2. Controller → invokes Service Layer methods
3. Service Layer:
- checks token via ApiTokenService
- fetches remote data via DroneApiService (or mock)
- caches to local files via DAO
- retrieves cached data via DAO
- processes data (DroneDataCalculationService, DroneStatusService)
- optionally calls ReverseGeocodeService or LocalSearchService
4. Service returns DTOs → Controller → maps to UI DTOs → updates UI components
5. DataRefreshService runs on background threads, pushes updates to Controller/UI asynchronously

c. Architectural patterns & design principles
- MVC pattern separates UI, control flow, and business logic
- Dependency inversion via interfaces (IDroneApiService, IDroneController, IDroneDataCalculationService, etc.)
- Strategy/mocking for API (real vs. mock service)
- Single Responsibility: each service has a focused job
- Asynchronous processing for responsiveness

d. Relevant technologies/frameworks
- Java Swing + FlatLaf for UI
- Java Concurrency (ExecutorService) for DataRefreshService
- REST Client (e.g., HttpClient) for API calls
- JUnit5 for unit testing

##### Final guidance
- Interfaces vs. implementations (e.g., IDroneApiService → DroneApiService & MockDroneApiService)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry Point
    Entry["DroneDeck (Entry Point)"]:::entry
    click Entry "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/DroneDeck.java"

    %% UI Layer
    subgraph "UI Layer"
        UIComp["UI Components"]:::frontend
        UIPages["UI Pages"]:::frontend
        UIDtos["UI DTOs"]:::frontend
        UIThemes["FlatLaf Themes"]:::frontend
    end
    click UIComp "https://github.com/code-hauptwache/dronedeck/tree/main/src/main/java/ui/components"
    click UIPages "https://github.com/code-hauptwache/dronedeck/tree/main/src/main/java/ui/pages"
    click UIDtos "https://github.com/code-hauptwache/dronedeck/tree/main/src/main/java/ui/dtos"
    click UIThemes "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/ui/themes/FlatLaf.properties"

    %% Controller Layer
    subgraph "Controller Layer"
        IController["IDroneController"]:::controller
        Controller["DroneController"]:::controller
    end
    click IController "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/controllers/IDroneController.java"
    click Controller "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/controllers/DroneController.java"

    %% Service Layer
    subgraph "Service Layer"
        subgraph "API Token"
            TokenService["ApiTokenService"]:::service
            TokenStoreService["ApiTokenStoreService"]:::service
            TokenStoreDto["ApiTokenStoreDto"]:::service
        end
        subgraph "Drone API Integration"
            IDroneApi["IDroneApiService"]:::service
            DroneApi["DroneApiService"]:::service
            MockApi["MockDroneApiService"]:::service
            ApiConfig["ApiModeConfig"]:::service
            ApiDtos["API DTOs"]:::service
        end
        DataRefresh["DataRefreshService"]:::service
        subgraph "Data Calculation"
            ICalc["IDroneDataCalculationService"]:::service
            Calc["DroneDataCalculationService"]:::service
            Coord["Coordinate"]:::service
            CalcRes["DataCalculationResult"]:::service
        end
        DroneStatus["DroneStatusService"]:::service
        subgraph "Local Search"
            ILocalSearch["ILocalSearchService"]:::service
            LocalSearch["LocalSearchService"]:::service
            LoadingListener["LoadingProgressListener"]:::service
        end
        subgraph "Reverse Geocoding"
            IGeo["IReverseGeocodeService"]:::service
            ReverseGeo["ReverseGeocodeService"]:::service
        end
        subgraph "Scroll Pane"
            Scroll["ScrollPaneService"]:::service
            AutoScroll["AutoScrollHandler"]:::service
        end
    end
    click TokenService "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/ApiToken/ApiTokenService.java"
    click TokenStoreService "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/ApiToken/ApiTokenStoreService.java"
    click TokenStoreDto "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/ApiToken/ApiTokenStoreDto.java"
    click IDroneApi "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DroneApi/IDroneApiService.java"
    click DroneApi "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DroneApi/DroneApiService.java"
    click MockApi "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DroneApi/MockDroneApiService.java"
    click ApiConfig "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DroneApi/ApiModeConfig.java"
    click ApiDtos "https://github.com/code-hauptwache/dronedeck/tree/main/src/main/java/services/DroneApi/dtos"
    click DataRefresh "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DataRefresh/DataRefreshService.java"
    click ICalc "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DroneDataCalculation/IDroneDataCalculationService.java"
    click Calc "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DroneDataCalculation/DroneDataCalculationService.java"
    click Coord "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DroneDataCalculation/Coordinate.java"
    click CalcRes "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DroneDataCalculation/DataCalculationResult.java"
    click DroneStatus "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/DroneStatus/DroneStatusService.java"
    click ILocalSearch "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/LocalSearch/ILocalSearchService.java"
    click LocalSearch "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/LocalSearch/LocalSearchService.java"
    click LoadingListener "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/LocalSearch/LoadingProgressListener.java"
    click IGeo "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/ReverseGeocode/IReverseGeocodeService.java"
    click ReverseGeo "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/ReverseGeocode/ReverseGeocodeService.java"
    click Scroll "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/ScrollPane/ScrollPaneService.java"
    click AutoScroll "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/services/ScrollPane/AutoScrollHandler.java"

    %% Data Access Layer
    subgraph "Data Access Layer"
        ILocalDroneDao["ILocalDroneDao"]:::dao
        LocalDroneDao["LocalDroneDao"]:::dao
        ILocalDroneTypeDao["ILocalDroneTypeDao"]:::dao
        LocalDroneTypeDao["LocalDroneTypeDao"]:::dao
    end
    click ILocalDroneDao "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/dao/ILocalDroneDao.java"
    click LocalDroneDao "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/dao/LocalDroneDao.java"
    click ILocalDroneTypeDao "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/dao/ILocalDroneTypeDao.java"
    click LocalDroneTypeDao "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/dao/LocalDroneTypeDao.java"

    %% Domain Models
    subgraph "Domain Models"
        DroneEntity["DroneEntity"]:::model
        DroneTypeEntity["DroneTypeEntity"]:::model
        CarriageType["CarriageType"]:::model
    end
    click DroneEntity "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/entity/DroneEntity.java"
    click DroneTypeEntity "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/entity/DroneTypeEntity.java"
    click CarriageType "https://github.com/code-hauptwache/dronedeck/blob/main/src/main/java/enums/CarriageType.java"

    %% External Systems
    subgraph "External Systems"
        DroneSimAPI["DroneSim REST API"]:::external
        LocalStorage["Local File Storage"]:::external
        DemoMedia["Demo Assets"]:::external
    end

    %% Connections
    Entry --> UIComp
    Entry --> UIPages
    Entry --> UIDtos
    Entry --> UIThemes

    UIComp --> Controller
    UIPages --> Controller
    UIDtos --> Controller
    UIThemes --> Controller

    Controller --> TokenService
    Controller --> DataRefresh
    Controller --> DroneStatus
    Controller --> LocalSearch
    Controller --> ReverseGeo
    Controller --> Scroll

    TokenService --> TokenStoreService
    TokenStoreService --> TokenStoreDto

    DataRefresh --> TokenService
    DataRefresh --> IDroneApi
    DataRefresh --> LocalDroneDao

    IDroneApi --> DroneApi
    IDroneApi --> MockApi
    DroneApi --> ApiConfig
    DroneApi --> ApiDtos
    MockApi --> ApiConfig
    MockApi --> ApiDtos

    Controller --> ICalc
    ICalc --> Calc
    Calc --> Coord
    Calc --> CalcRes

    Controller --> DroneStatus

    Controller --> ILocalSearch
    ILocalSearch --> LocalSearch
    LocalSearch --> LoadingListener

    Controller --> IGeo
    IGeo --> ReverseGeo

    Controller --> Scroll
    Scroll --> AutoScroll

    DroneApi --> LocalDroneDao
    LocalDroneDao --> LocalStorage
    LocalDroneTypeDao --> LocalStorage

    DroneSimAPI -.-> DroneApi
    DroneSimAPI -.-> MockApi
    DemoMedia -.-> MockApi
    LocalStorage -.-> ILocalDroneDao
    LocalStorage -.-> ILocalDroneTypeDao

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085;
    classDef controller fill:#d4edda,stroke:#155724;
    classDef service fill:#d1ecf1,stroke:#0c5460;
    classDef dao fill:#fff3cd,stroke:#856404;
    classDef external fill:#e2e3e5,stroke:#6c757d;
    classDef model fill:#f8d7da,stroke:#721c24;
    classDef entry fill:#f0f0f0,stroke:#999999;
```
