# fossifyorg/phone architecture

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

- Interactive diagram: https://gitdiagram.com/fossifyorg/phone
- Repository: https://github.com/fossifyorg/phone

## Overview

##### Main Components

a) User Interface Layer:
- Main Activities (MainActivity, DialerActivity, CallActivity, etc.)
- Fragments (ContactsFragment, FavoritesFragment, RecentsFragment)
- Adapters for list views and recycler views
- Dialog components for user interactions

b) Core Phone Functionality:
- CallManager for handling call operations
- CallService for background call handling
- CallNotificationManager for call notifications
- SimpleCallScreeningService for call screening

c) Data Management:
- RecentsHelper for call history
- Config for app configuration
- Models (CallContact, RecentCall, SpeedDial, etc.)

d) Support Systems:
- ToneGeneratorHelper for dial tones
- CallContactHelper for contact management
- Various extension functions

**[User Interface Layer]**

- [Activities]─────[Fragments]─────[Adapters]

- [Dialog System]

**[Core Phone Layer]**

- [Call Management]
- CallManager
- CallService
- CallNotificationManager

- [Contact System]
- CallContactHelper
- CallContactAvatarHelper

**[Data Layer]**

- [Models]
- CallContact
- RecentCall
- SpeedDial

- [Helpers]
- RecentsHelper
- Config
- Constants

**[System Integration]**

- [Android Phone API]
- [Contact Provider API]

##### Connection Types

- Double lines: Data flow

##### Important Details

- Flow of incoming/outgoing calls
- Privacy-focused features
- Where user preferences are stored and accessed
- Integration points with Android's telephony system
- Components handling contact data

##### Implementation Notes

- Use standard UML notation where appropriate
- Keep the abstraction level high enough to be understandable but detailed enough to be useful
- Version information and date
- A brief textual description of key components

Remember to include the relationship between the core phone functionality and Android's native telephony services, as this is crucial for understanding how the app functions as a phone dialer replacement.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef system fill:#9b59b6,stroke:#8e44ad,color:white
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef privacy fill:#e74c3c,stroke:#c0392b,color:white

    %% User Interface Layer
    subgraph UI["User Interface Layer"]
        subgraph Activities["Activities & UI Components"]
            MA["MainActivity<br>Main app navigation<br>Tab management"]:::ui
            DA["DialerActivity<br>Keypad & Dialing<br>Number input"]:::ui
            CA["CallActivity<br>Active call handling<br>Call controls"]:::ui
        end

        subgraph Fragments["Fragment Components"]
            CF["ContactsFragment<br>Contact list view<br>Search & Filter"]:::ui
            FF["FavoritesFragment<br>Speed dial mgmt<br>Quick access"]:::ui
            RF["RecentsFragment<br>Call history<br>Grouped calls"]:::ui
        end

        subgraph Adapters["Data Display Adapters"]
            ContA["ContactsAdapter<br>Contact list rendering<br>Avatar handling"]:::ui
            RCA["RecentCallsAdapter<br>Call history display<br>Timestamp formatting"]:::ui
            SDA["SpeedDialAdapter<br>Favorites management<br>Position handling"]:::ui
        end

        subgraph Dialogs["User Interaction Dialogs"]
            SSD["SelectSIMDialog<br>Multi-SIM support<br>Default SIM selection"]:::ui
            GCD["ShowGroupedCallsDialog<br>Call grouping<br>History organization"]:::ui
            SCD["SelectContactDialog<br>Contact picker<br>Search functionality"]:::ui
        end
    end

    %% Core Phone Layer
    subgraph Core["Core Phone Functionality"]
        subgraph CallMgmt["Call Management System"]
            CM["CallManager<br>Call state handling<br>Audio routing"]:::core
            CS["CallService<br>Background service<br>Call monitoring"]:::core
            CNM["CallNotificationManager<br>Call notifications<br>Status updates"]:::core
            SCSS["SimpleCallScreeningService<br>Call filtering<br>Spam protection"]:::privacy
        end

        subgraph ContactSys["Contact Management"]
            CCH["CallContactHelper<br>Contact operations<br>Data formatting"]:::core
            CCAH["CallContactAvatarHelper<br>Avatar loading<br>Cache management"]:::core
        end
    end

    %% Data Layer
    subgraph Data["Data Management"]
        subgraph Models["Data Models"]
            CC["CallContact<br>Contact information<br>Phone numbers"]:::data
            RC["RecentCall<br>Call records<br>Duration tracking"]:::data
            SD["SpeedDial<br>Quick dial settings<br>Position data"]:::data
        end

        subgraph Helpers["Support Utilities"]
            RH["RecentsHelper<br>History management<br>Call logging"]:::data
            Conf["Config<br>Settings storage<br>User preferences"]:::data
            TGH["ToneGeneratorHelper<br>DTMF generation<br>Audio feedback"]:::data
        end
    end

    %% System Integration
    subgraph System["Android System Integration"]
        PhoneAPI["Android Phone API<br>Telephony services<br>Call handling"]:::system
        ContactAPI["Contact Provider API<br>System contacts<br>Data access"]:::system
        PrivacyMgr["Privacy Manager<br>Data protection<br>Permission handling"]:::privacy
    end

    %% Relationships with detailed labels
    Core -- "Call events & states" --> System
    UI -- "User actions & display" --> Core
    Core -- "Data operations" --> Data
    UI -- "Data access & updates" --> Data
    System -- "System events" --> Core
    ContactSys -- "Contact sync" --> ContactAPI
    CallMgmt -- "Call handling" --> PhoneAPI
    PrivacyMgr -- "Access control" --> ContactAPI

    %% Click events [Previous click events remain the same]
    click MA "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/activities/MainActivity.kt"
    click DA "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/activities/DialerActivity.kt"
    click CA "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/activities/CallActivity.kt"
    click Activities "https://github.com/FossifyOrg/Phone/tree/master/app/src/main/kotlin/org/fossify/phone/activities/"
    click CF "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/fragments/ContactsFragment.kt"
    click FF "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/fragments/FavoritesFragment.kt"
    click RF "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/fragments/RecentsFragment.kt"
    click Fragments "https://github.com/FossifyOrg/Phone/tree/master/app/src/main/kotlin/org/fossify/phone/fragments/"
    click ContA "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/adapters/ContactsAdapter.kt"
    click RCA "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/adapters/RecentCallsAdapter.kt"
    click SDA "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/adapters/SpeedDialAdapter.kt"
    click CM "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/helpers/CallManager.kt"
    click CNM "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/helpers/CallNotificationManager.kt"
    click CS "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/services/CallService.kt"
    click SCSS "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/services/SimpleCallScreeningService.kt"
    click CC "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/models/CallContact.kt"
    click RC "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/models/RecentCall.kt"
    click SD "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/models/SpeedDial.kt"
    click TGH "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/helpers/ToneGeneratorHelper.kt"
    click CCH "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/helpers/CallContactHelper.kt"
    click RH "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/helpers/RecentsHelper.kt"
    click Conf "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/helpers/Config.kt"
    click SSD "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/dialogs/SelectSIMDialog.kt"
    click GCD "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/dialogs/ShowGroupedCallsDialog.kt"
    click SCD "https://github.com/FossifyOrg/Phone/blob/master/app/src/main/kotlin/org/fossify/phone/dialogs/SelectContactDialog.kt"
```
