# fbis251/linky architecture

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

- Interactive diagram: https://gitdiagram.com/fbis251/linky
- Repository: https://github.com/fbis251/linky

## Overview

##### Main Components

a. Client-Side (Android App):
- User Interface Layer
- Activities (LoginActivity, LinksListActivity, etc.)
- Fragments (SettingsFragment)
- Adapters (LinksAdapter, CategoriesArrayAdapter)
- UI Components (Material Design elements)

- Business Logic Layer
- Link Management
- Category Management
- Search/Sort Functionality
- Share Handler

- Data Layer
- Local Storage (Realm Database)
- API Communication
- Models (Link, LoginRequest, etc.)

b. Server-Side (External Component):
- Linky Server (separate system)
- REST API Endpoints

##### Component Relationships

- User Interface → Business Logic (action/event flow)
- Business Logic → Data Layer (data operations)
- Data Layer → Local Storage (persistence)
- Data Layer → Server API (remote communication)

##### Specific Implementation Details

- Activities (rectangles with rounded corners)
- Services (hexagons)
- External Systems (clouds)

##### Architecture Pattern Representation

MVP (Model-View-Presenter) or MVVM pattern:
- Views (Activities/Fragments)
- Models (Link, LoginRequest, etc.)
- Adapters/Presenters (data binding layer)

##### Key Technical Elements

Following components:
- Retrofit/OkHttp for API communication
- Realm for local storage
- Material Design UI components
- Share functionality integration

**┌─────────────────────────────────────────────────────┐**
- Presentation Layer                  │
- ┌─────────────┐ ┌─────────────┐ ┌─────────────┐    │
- Activities│ │  Fragments  │ │   Adapters  │    │
- ┘ └─────────────┘ └─────────────┘    │
- ┤
- Business Logic Layer                │
- ┌─────────────┐ ┌─────────────┐ ┌─────────────┐    │
- Link Manager │ │Share Handler│ │Utils/Helpers│    │
- ┘ └─────────────┘ └─────────────┘    │
- ┤
- Data Layer                       │
- ┌─────────────┐ ┌─────────────┐ ┌─────────────┐    │
- Realm Storage│ │ API Service │ │   Models    │    │
- ┘ └─────────────┘ └─────────────┘    │
- ┘
- ↕                 ↕
**┌─────────────────┐  ┌─────────────────┐**
- Local Storage  │  │   Linky Server  │
- ┘  └─────────────────┘

Important Elements to Highlight:

##### Privacy Features
- Self-hosted server connection
- Local data storage
- Secure communication

##### Data Flow
- Link sharing from external apps
- API communication patterns
- Local storage synchronization

##### User Interface Flow
- Navigation patterns
- Material Design implementation
- Search and filter functionality

- User interface components (blue)
- Data storage components (green)
- Network communication (orange)
- External systems (gray)

Remember to maintain a balance between detail and clarity, focusing on the key architectural decisions that make Linky unique, such as its privacy-focused design and integration with the Android sharing system.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#B3E0FF,stroke:#333
    classDef business fill:#FFE0B3,stroke:#333
    classDef data fill:#B3FFB3,stroke:#333
    classDef external fill:#E0E0E0,stroke:#333
    classDef storage fill:#D1C4E9,stroke:#333

    %% Presentation Layer
    subgraph PresentationLayer["Presentation Layer"]
        Activities["Activities"]:::ui
        Fragments["Fragments"]:::ui
        Adapters["Adapters"]:::ui
        UIComponents["UI Components"]:::ui
        LayoutResources["Layout Resources"]:::ui
    end

    %% Business Logic Layer
    subgraph BusinessLayer["Business Logic Layer"]
        LinkManager["Link Manager"]:::business
        ShareHandler["Share Handler"]:::business
        Utils["Utils/Helpers"]:::business
        AppConfig["App Configuration"]:::business
        AppEntry["Application Entry"]:::business
    end

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        LocalStorage["Realm Storage"]:::data
        APIService["API Service"]:::data
        DataModels["Data Models"]:::data
    end

    %% External Systems
    ExternalStorage[("Local Storage")]:::storage
    LinkyServer["Linky Server"]:::external

    %% Relationships
    Activities --> LinkManager
    Activities --> ShareHandler
    Fragments --> LinkManager
    Adapters --> DataModels
    UIComponents --> LayoutResources
    
    LinkManager --> LocalStorage
    LinkManager --> APIService
    ShareHandler --> APIService
    
    LocalStorage --> ExternalStorage
    APIService --> LinkyServer
    DataModels --> LocalStorage
    
    AppConfig --> BusinessLayer
    AppEntry --> BusinessLayer

    %% Click Events
    click Activities "https://github.com/fbis251/Linky/tree/master/app/src/main/java/com/fernandobarillas/linkshare/activities/"
    click Fragments "https://github.com/fbis251/Linky/tree/master/app/src/main/java/com/fernandobarillas/linkshare/fragments/"
    click Adapters "https://github.com/fbis251/Linky/tree/master/app/src/main/java/com/fernandobarillas/linkshare/adapters/"
    click UIComponents "https://github.com/fbis251/Linky/tree/master/app/src/main/java/com/fernandobarillas/linkshare/ui/"
    click ShareHandler "https://github.com/fbis251/Linky/blob/master/app/src/main/java/com/fernandobarillas/linkshare/utils/ShareHandler.java"
    click Utils "https://github.com/fbis251/Linky/tree/master/app/src/main/java/com/fernandobarillas/linkshare/utils/"
    click LocalStorage "https://github.com/fbis251/Linky/blob/master/app/src/main/java/com/fernandobarillas/linkshare/databases/LinkStorage.java"
    click APIService "https://github.com/fbis251/Linky/tree/master/app/src/main/java/com/fernandobarillas/linkshare/api/"
    click DataModels "https://github.com/fbis251/Linky/tree/master/app/src/main/java/com/fernandobarillas/linkshare/models/"
    click AppConfig "https://github.com/fbis251/Linky/blob/master/app/src/main/java/com/fernandobarillas/linkshare/configuration/AppPreferences.java"
    click LayoutResources "https://github.com/fbis251/Linky/tree/master/app/src/main/res/layout/"
    click AppEntry "https://github.com/fbis251/Linky/blob/master/app/src/main/java/com/fernandobarillas/linkshare/LinksApp.java"

    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        BL["Business Logic"]:::business
        DL["Data Component"]:::data
        EX["External System"]:::external
        ST["Storage"]:::storage
    end
```
