# andyporras/osmtracker-android architecture

> Architecture diagram of the GitHub repository andyporras/osmtracker-android, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/andyporras/osmtracker-android
- Repository: https://github.com/andyporras/osmtracker-android

## Overview

##### Project Type & Overall Purpose
- This is a mobile Android application (client) that logs GPS data and integrates multimedia functionalities.
- Its purpose is to capture and annotate GPS tracks, support custom button layouts, and eventually upload or export data (e.g., to OpenStreetMap).

##### Main Components
a. User Interface (UI):
- Activities (e.g., About, DisplayTrack, TrackLogger, TrackManager) represent the front-end where users interact.
- Layout definitions in res/layout and custom components such as “DisablableTableLayout.”
- Resources for internationalization/localization as seen in the extensive res/values directories.
b. Data Persistence & Database:
- Database classes under db/ (DataHelper, DatabaseHelper) and the ContentProvider (TrackContentProvider) illustrate where track and waypoint data is stored locally.
c. Services & Background Processes:
- GPS services and listeners (found under service/gps, e.g., GPSLogger, GPSLoggerServiceConnection)
- Tasks for exporting GPX files and integrating with external storage (gpx-related tasks).
d. Sensor & Input Handling:
- Various listeners for sensors (PressureListener, SensorListener) and button click listeners.
- Activities and components for multimedia handling (voice recording, image capture).
e. Utility & Helper Modules:
- Utility classes for file system, network URL creation, layout customization, and Mercator Projection conversions.
f. External Integrations & Build Infrastructure:
- Integration with external services such as OpenStreetMap (e.g., UploadToOpenStreetMapTask).
- Build and continuous integration configurations (Gradle build files, GitHub Actions, Travis CI, Transifex integration for translations).

##### Relationships & Interactions
- User interactions in the Activities (UI layer) call listener classes and in turn invoke service methods (GPS service and GPX export tasks).
- The UI triggers database operations through the DatabaseHelper and ContentProvider.
- There is a clear interaction between the services (like GPSLogger) and the data persistence layer, where sensor data is logged and later processed.
- Modular dependencies (for instance, the separation between UI handling, background services, and database layers aligns with a layered or MVC-inspired architecture).

##### Architectural Patterns and Key Design Principles
- The project loosely follows a modular separation that can be mapped to an MVC or MVVM-like structure:
- Model: Database models (e.g., Track, TrackPoint, WayPoint) and helper classes.
- View: Activities and associated layouts along with custom UI components.
- Controller/Service: Activities delegate tasks to background services (for GPS and media capture) and utility classes.
- Use of dependency separation and clearly defined roles for classes (e.g., the GPX export flow is isolated in its own package).

##### Technologies, Frameworks, and Tools
- Android SDK components (Activities, Services, Broadcast Receivers, Content Providers).
- Gradle for build management and continuous integration (with provided CI configs in .github/workflows and .travis.yml).
- Testing modules in app/src/test and app/src/androidTest indicate robust testing infrastructure.
- Localization and resource management is paramount given the several resource directories (res/values-*).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer – Activities & Layouts"
        UIActivities["Activities (About,DisplayTrack,TrackLogger,TrackManager)"]:::ui
        UILayouts["Layouts & Resources"]:::ui
    end

    subgraph "Sensor & Input Layer"
        Sensor["Sensor & Input Handling (PressureListener,SensorListener,StillImageOnClickListener)"]:::sensor
    end

    subgraph "Service Layer – Services & Background Processes"
        GPS["GPS Services (GPSLogger,GPSLoggerServiceConnection)"]:::service
        GPX["GPX Export (ExportToStorageTask,ExportToTempFileTask,ExportTrackTask)"]:::service
        OSM["External Integrations (UploadToOpenStreetMapTask)"]:::service
    end

    subgraph "Database Layer"
        DB["Data Persistence & Database (DataHelper,DatabaseHelper,TrackContentProvider)"]:::db
    end

    subgraph "Utility Modules"
        Utils["Utility & Helper Modules (FileSystemUtils,URLCreator,MercatorProjection)"]:::utility
    end

    subgraph "Build & CI"
        Build["Build & CI (Gradle,GitHubActions,TravisCI)"]:::build
    end

    %% Connections
    UIActivities -->|"triggers"| Sensor
    UIActivities -->|"startTracking"| GPS
    UIActivities -->|"databaseOps"| DB
    Sensor -->|"sendData"| GPS
    GPS -->|"storeData"| DB
    GPS -->|"generateGPX"| GPX
    GPX -->|"uploadGPX"| OSM
    UIActivities -->|"utilSupport"| Utils
    GPS -->|"utilSupport"| Utils
    GPX -->|"utilSupport"| Utils
    Build -->|"buildUI"| UIActivities
    Build -->|"buildUI"| UILayouts
    Build -->|"buildServices"| GPS
    Build -->|"buildDB"| DB

    %% Click Events
    click UIActivities "https://github.com/andyporras/osmtracker-android/tree/master/app/src/main/java/net/osmtracker/activity"
    click UILayouts "https://github.com/andyporras/osmtracker-android/tree/master/app/src/main/res/layout"
    click DB "https://github.com/andyporras/osmtracker-android/tree/master/app/src/main/java/net/osmtracker/db"
    click GPS "https://github.com/andyporras/osmtracker-android/tree/master/app/src/main/java/net/osmtracker/service/gps"
    click GPX "https://github.com/andyporras/osmtracker-android/tree/master/app/src/main/java/net/osmtracker/gpx"
    click OSM "https://github.com/andyporras/osmtracker-android/tree/master/app/src/main/java/net/osmtracker/osm"
    click Sensor "https://github.com/andyporras/osmtracker-android/tree/master/app/src/main/java/net/osmtracker/listener"
    click Utils "https://github.com/andyporras/osmtracker-android/tree/master/app/src/main/java/net/osmtracker/util"
    click Build "https://github.com/andyporras/osmtracker-android/tree/master/.github/workflows"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px
    classDef service fill:#90EE90,stroke:#000,stroke-width:2px
    classDef db fill:#FFD700,stroke:#000,stroke-width:2px
    classDef sensor fill:#FFB6C1,stroke:#000,stroke-width:2px
    classDef utility fill:#D3D3D3,stroke:#000,stroke-width:2px
    classDef build fill:#F08080,stroke:#000,stroke-width:2px
```
