# 4nubhav/whatsdeleted architecture

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

- Interactive diagram: https://gitdiagram.com/4nubhav/whatsdeleted
- Repository: https://github.com/4nubhav/whatsdeleted

## Overview

##### Main Components

a. Core Application Components:
- MainActivity (Entry point)
- NotificationListener Service
- MediaObserverService
- MsgLogViewerActivity
- Storage Components (Internal & External)

b. External Integrations:
- WhatsApp Application
- Signal Private Messenger
- Android System Notifications
- Android File System

##### Component Relationships

**┌─────────────────────────────────────────────────────────────┐**
- User Interface Layer                     │
- ┌─────────────────┐            ┌────────────────────────┐  │
- MainActivity  │──────────▶ │  MsgLogViewerActivity  │  │
- ┘            └────────────────────────┘  │
- ┬─────────────────────────────┬──────────────┘

**┌───────────────▼─────────────┐   ┌──────────▼──────────────┐**
- NotificationListener      │   │    MediaObserver         │
- Service                  │   │    Service               │
- ┬─────────────┘   └──────────┬──────────────┘

**┌───────────────▼─────────────────────────────▼──────────────┐**
- Storage Layer                           │
- ┌─────────────────┐            ┌────────────────────────┐ │
- Internal       │            │  External              │ │
- Storage        │            │  Storage               │ │
- (Message Logs) │            │  (Media Files)         │ │
- ┘            └────────────────────────┘ │
- ┘

##### Important Elements to Highlight

a. Data Flow:
- How notifications flow from WhatsApp through the NotificationListener
- Media file monitoring path through MediaObserver
- Storage paths for both messages and media

b. Service Architecture:
- Background services running continuously
- Separation between UI and service layers

##### Technical Details

- Android-specific components (Services, Activities)
- File system interactions
- Notification listener implementation
- Storage access patterns

##### Implementation Notes

- Clear separation between notification handling and media observation
- Where user permissions are required
- Backup mechanism for both messages and media

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#e74c3c,stroke:#c0392b,color:white
    classDef permission fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Main UI Components
    MainActivity["MainActivity"]:::ui
    MsgLogViewer["MsgLogViewerActivity"]:::ui
    AlertDialog["Alert Dialog Helper"]:::ui

    %% Services
    NotifListener["NotificationListener Service"]:::service
    MediaObserver["MediaObserver Service"]:::service

    %% Storage Components
    subgraph Storage
        Internal["Internal Storage<br/>(Message Logs)"]:::storage
        External["External Storage<br/>(Media Files)"]:::storage
    end

    %% External Systems
    subgraph ExternalSystems
        WhatsApp["WhatsApp App"]:::external
        Signal["Signal App"]:::external
        AndroidNotif["Android Notifications"]:::external
        FileSystem["Android File System"]:::external
    end

    %% Permissions
    subgraph Permissions
        NotifPerm["Notification Access"]:::permission
        StoragePerm["Storage Access"]:::permission
    end

    %% Relationships
    MainActivity --> MsgLogViewer
    MainActivity --> AlertDialog
    MainActivity --> NotifPerm
    MainActivity --> StoragePerm
    
    NotifPerm --> NotifListener
    StoragePerm --> MediaObserver
    
    NotifListener --> Internal
    MediaObserver --> External
    
    WhatsApp --> AndroidNotif
    Signal --> AndroidNotif
    AndroidNotif --> NotifListener
    FileSystem --> MediaObserver

    %% Click events
    click MainActivity "https://github.com/4nubhav/WhatsDeleted/blob/master/app/src/main/java/com/gmail/anubhavdas54/whatsdeleted/MainActivity.kt"
    click MsgLogViewer "https://github.com/4nubhav/WhatsDeleted/blob/master/app/src/main/java/com/gmail/anubhavdas54/whatsdeleted/MsgLogViewerActivity.kt"
    click NotifListener "https://github.com/4nubhav/WhatsDeleted/blob/master/app/src/main/java/com/gmail/anubhavdas54/whatsdeleted/NotificationListener.kt"
    click MediaObserver "https://github.com/4nubhav/WhatsDeleted/blob/master/app/src/main/java/com/gmail/anubhavdas54/whatsdeleted/MediaObserverService.kt"
    click AlertDialog "https://github.com/4nubhav/WhatsDeleted/blob/master/app/src/main/java/com/gmail/anubhavdas54/whatsdeleted/AlertDialogHelper.kt"

    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        Service["Service"]:::service
        Store["Storage"]:::storage
        Ext["External System"]:::external
        Perm["Permission"]:::permission
    end
```
