# gotify/android architecture

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

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

## Overview

Based on our review of the file tree and README, this is an Android mobile client for Gotify (which works together with the gotify/server). The project is split into two subprojects. The “app” component contains the core Android application (written largely in Kotlin) and handles UI displays, notifications, message listing/deletion, login, logging, settings, and background services (like maintaining a WebSocket connection for notifications). The “client” subproject is a Swagger-generated API client (written in Java) that abstracts the network calls to the backend server and manages the REST API interactions.

##### Main Components
- Mobile App (Android Client)
– User Interface Layer: Consisting of various activities (e.g., LoginActivity, MessagesActivity, LogsActivity, ShareActivity) and layout resources.
– API Module: Represented by packages under “api” (both on the app side and as part of the client subproject) that handle REST API calls to gotify/server.
– Messaging Module: Contains classes to process and display messages (e.g., MessagesModel, MessageFacade, MessageRequester, ListMessageAdapter, etc.).
– Notification & Service Modules: Components related to push notifications and background tasks (WebSocketConnection, WebSocketService, NotificationSupport, etc.).
– Settings & Miscellaneous: Includes settings activities, utility classes, logging functionality (with LoggerHelper & UncaughtExceptionHandler), and resource files.

- API Client (Swagger-Generated Client)
– This module encapsulates network operations, API endpoints, authentication classes (like OAuth, API Key authentication modules), and models for data communication.

- External Gotify Server

##### Relationships and Interactions
- That the Messaging Module interacts with both the UI and API Client modules to fetch, display, and delete messages.
- Optionally, indicate background logging and crash handling as a separate feature that streams exceptions to a local Log Activity.

##### Architectural Patterns and Technologies
- Modularity. The separation into “app” (UI, background services, notification handling) and “client” (API interface) suggests a clear separation of concerns, which is beneficial for unit testing and maintainability.
- Use of Android-specific architectural components (Activities, BroadcastReceivers like BootCompletedReceiver, services for WebSocket, etc.).
- Usage of the Swagger-codegen approach in the client submodule – which abstracts much of the boilerplate for API communication.
- External libraries if desired (e.g., Coil for image loading, Markwon for markdown processing, etc.) as supporting technologies.

##### Final Assembly
- Client subproject as either a separate module within the mobile app or as a shared library that interfaces with the Gotify Server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile App Subgraph
    subgraph "Mobile App"
        UI_Layer["User Interface Layer"]:::ui
        API_Module["API Module"]:::api
        Messaging_Module["Messaging Module"]:::messaging
        Notification_Service["Notification & Service Modules"]:::service
        Settings_Misc["Settings & Miscellaneous"]:::settings
    end

    %% Separate API Client and External Gotify Server
    API_Client["API Client (Swagger Generated)"]:::apiClient
    External_Server["External Gotify Server"]:::external

    %% Relationships and Data Flow
    UI_Layer -->|"userActions"| API_Module
    API_Module -->|"HTTP/REST_call"| API_Client
    API_Client -->|"GET/POST_messages"| External_Server
    API_Client -->|"fetchMessages"| Messaging_Module
    UI_Layer -->|"displayMessages"| Messaging_Module
    Notification_Service -->|"pushNotification"| UI_Layer
    Settings_Misc -->|"logErrors"| UI_Layer

    %% Click Events
    click UI_Layer "https://github.com/gotify/android/tree/master/app/src/main/kotlin/com/github/gotify/login"
    click API_Module "https://github.com/gotify/android/tree/master/app/src/main/kotlin/com/github/gotify/api"
    click Messaging_Module "https://github.com/gotify/android/tree/master/app/src/main/kotlin/com/github/gotify/messages"
    click Notification_Service "https://github.com/gotify/android/tree/master/app/src/main/kotlin/com/github/gotify/service"
    click Settings_Misc "https://github.com/gotify/android/tree/master/app/src/main/kotlin/com/github/gotify/settings"
    click API_Client "https://github.com/gotify/android/tree/master/client/"
    
    %% Styles
    classDef ui fill:#F8B195,stroke:#000,stroke-width:2px;
    classDef api fill:#F67280,stroke:#000,stroke-width:2px;
    classDef messaging fill:#C06C84,stroke:#000,stroke-width:2px;
    classDef service fill:#6C5B7B,stroke:#000,stroke-width:2px;
    classDef settings fill:#355C7D,stroke:#000,stroke-width:2px;
    classDef apiClient fill:#99B898,stroke:#000,stroke-width:2px;
    classDef external fill:#2A363B,stroke:#fff,stroke-width:2px,fill-opacity:0.7;
```
