# merlos/ios-open-gpx-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/merlos/ios-open-gpx-tracker
- Repository: https://github.com/merlos/ios-open-gpx-tracker

## Overview

##### Main Components Overview
The system should be represented with these key components:

a) iOS Application (Main App)
- UI Layer (View Controllers)
- Core Components
- Data Management
- Services
- Location Services

b) WatchOS Application
- Watch UI
- Watch Extension
- Communication Layer

##### Detailed Component Breakdown

A. iOS Application Components:

- iOS Application                                      |

- UI Layer    |    |  Core Services  |    |    Data Management   |                |

- Main View      |    |- GPX Processing |    |- CoreData Storage    |                |
- Map View       |    |- Location Track |    |- File Management     |                |
- Settings       |    |- Map Cache      |    |- GPX Export/Import   |                |
- File Browser   |    |- GPS Services   |    |- Preferences         |                |
- ^--------+    +--------^--------+    +-----------^----------+                |

- v------------------v---v-------------------------v----------+                |
- Core Framework Layer                        |                |

- CoreGPX (GPX file handling)                                      |                |
- MapCache (Offline map support)                                   |                |
- CoreLocation (GPS services)                                      |                |

- ^

- v

- WatchOS Application                                    |

- Watch UI      |    | Extension Logic   |    |  Watch Data Handler  |              |

- Track Interface |    |- Location Track   |    |- Session Management  |              |
- GPS Status      |    |- Complication    |    |- File Transfer       |              |
- File List       |    |- Watch Delegate  |    |- State Sync          |              |

##### Key Interactions to Highlight

a) Data Flow:
- GPS Data → Location Services → GPX Processing → Storage
- Tile Requests → Map Cache → UI Display
- File Operations → CoreData/File System → UI Updates

b) Watch Communication:
- iOS App ↔ Watch Extension (bi-directional data sync)
- Watch GPS → Track Recording
- File Transfer between devices

##### Additional Elements

Supporting components:

- External Systems |

- Tile Servers     |
- GPS Satellites   |
- iCloud Storage   |

**→ : Data Flow**
**↔ : Two-way Communication**
**⟳ : Background Process**

##### Location Services: Illustrate GPS tracking and processing

This system design reflects the app's key features:
- GPS tracking
- Offline map support
- Watch OS integration
- GPX file handling
- Multi-language support
- Core location services
- Provider flexibility

The architecture emphasizes the app's focus on privacy (local data storage), offline capability, and cross-device functionality.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph iOS_Application
        subgraph UI_Layer
            MainView["Main View Controller"]:::ui
            MapView["Map View"]:::ui
            Settings["Settings View"]:::ui
            FileBrowser["File Browser"]:::ui
        end

        subgraph Core_Services
            GPXProcess["GPX Processing"]:::core
            LocationTrack["Location Tracking"]:::core
            MapCache["Map Cache"]:::core
            GPSServices["GPS Services"]:::core
        end

        subgraph Data_Management
            CoreData["CoreData Storage"]:::data
            FileManagement["File Management"]:::data
            GPXHandler["GPX Export/Import"]:::data
            Prefs["Preferences"]:::data
        end

        subgraph Core_Framework
            CoreGPX["CoreGPX Library"]:::framework
            MapCacheLib["MapCache Library"]:::framework
            CoreLocation["CoreLocation Services"]:::framework
        end
    end

    subgraph WatchOS_Application
        subgraph Watch_UI
            TrackInterface["Track Interface"]:::watchui
            GPSStatus["GPS Status"]:::watchui
            FileList["File List"]:::watchui
        end

        subgraph Watch_Extension
            LocationTrackWatch["Location Track"]:::watchext
            Complications["Complications"]:::watchext
            WatchDelegate["Watch Delegate"]:::watchext
        end

        subgraph Watch_Data
            SessionMgmt["Session Management"]:::watchdata
            FileTransfer["File Transfer"]:::watchdata
            StateSync["State Sync"]:::watchdata
        end
    end

    subgraph External_Systems
        TileServers["Tile Servers"]:::external
        GPSSatellites["GPS Satellites"]:::external
        iCloud["iCloud Storage"]:::external
    end

    %% Connections
    MainView --> MapView
    MainView --> Settings
    MainView --> FileBrowser
    MapView --> MapCache
    GPSServices --> LocationTrack
    LocationTrack --> GPXProcess
    GPXProcess --> CoreData
    MapCache --> CoreGPX
    FileManagement --> GPXHandler
    GPXHandler --> CoreData
    Settings --> Prefs

    %% Watch Connections
    TrackInterface --> LocationTrackWatch
    LocationTrackWatch --> SessionMgmt
    WatchDelegate --> StateSync
    FileList --> FileTransfer
    FileTransfer --> FileManagement
    StateSync --> CoreData

    %% External Connections
    TileServers --> MapCache
    GPSSatellites --> GPSServices
    GPSSatellites --> LocationTrackWatch
    FileManagement --> iCloud

    %% Styles
    classDef ui fill:#3498db
    classDef core fill:#2ecc71
    classDef data fill:#f1c40f
    classDef framework fill:#9b59b6
    classDef watchui fill:#e74c3c
    classDef watchext fill:#e67e22
    classDef watchdata fill:#1abc9c
    classDef external fill:#95a5a6

    %% Click Events
    click MainView "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker/ViewController.swift"
    click Settings "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker/PreferencesTableViewController.swift"
    click FileBrowser "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker/GPXFilesTableViewController.swift"
    click MapView "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker/GPXMapView.swift"
    click MapCache "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker/GPXTileServer.swift"
    click CoreData "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker/CoreDataHelper.swift"
    click FileManagement "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker/GPXFileManager.swift"
    click Prefs "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker/Preferences.swift"
    click CoreGPX "https://github.com/merlos/iOS-Open-GPX-Tracker/tree/master/Pods/CoreGPX/Classes/"
    click MapCacheLib "https://github.com/merlos/iOS-Open-GPX-Tracker/tree/master/Pods/MapCache/"
    click TrackInterface "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker-Watch/Base.lproj/Interface.storyboard"
    click WatchDelegate "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker-Watch Extension/ExtensionDelegate.swift"
    click Complications "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker-Watch Extension/ComplicationController.swift"
    click LocationTrackWatch "https://github.com/merlos/iOS-Open-GPX-Tracker/blob/master/OpenGpxTracker-Watch Extension/InterfaceController.swift"
```
