# zaemazmi/qurannexusmobile architecture

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

- Interactive diagram: https://gitdiagram.com/zaemazmi/qurannexusmobile
- Repository: https://github.com/zaemazmi/qurannexusmobile

## Overview

##### Main Components
- Mobile Application (Client): This is the Android app that includes multiple feature modules.
- Presentation/UI Layer: Activities, Fragments, and custom views defined in XML (e.g., MainActivity, SplashActivity, various fragments under features such as auth, quiz, home, recitation, etc.).
- ViewModel Layer: Located inside each feature (e.g., BookmarkWordsViewModel, QuizViewModel, HomepageStatisticsViewModel) responsible for the MVVM architecture.
- Domain/Business Logic: The core functionalities and utility classes (packages like core/utils, core/models, core/network) that implement business logic.
- Data Layer: Repositories (for bookmarks, prayer times, quizzes, etc.) along with network interfaces (ApiService, AuthApi, QuranApi, etc.) that interact with the backend.
- External Backend Services: The Laravel PHP backend (accessed via API calls) and the MongoDB database. Include AWS S3 integration for multimedia storage.
- Multimedia Services: Media3 ExoPlayer for audio playback integrated into the recitation features.
- Dependency Injection: Hilt is used across the layers for managing dependencies.

##### Architectural Relationships and Interactions
- The Presentation Layer interacts with ViewModels that, in turn, invoke Repositories.
- The Repositories are responsible for managing data sources, which include making API calls (using Retrofit or similar under the networking package) to the Laravel backend and fetching/storing multimedia content via AWS S3.
- All API responses and data manipulations are streamlined through the core/interfaces and utility packages.
- Additional auxiliary components include analytics, graphs (using MPAndroidChart), and navigation managed via the Jetpack Navigation Component.

##### Architectural Patterns and Tools
- MVVM Pattern: Clearly separate the UI (activities/fragments), the ViewModels (data & state management), and the data repositories.
- Feature-Based Modularity: Each major functionality (analysis, auth, bookmark, quiz, recitation, etc.) is encapsulated in its own package under the “features” directory.
- Dependency Injection with Hilt maintains a clean architecture across modules.
- Utilization of Jetpack Navigation along with custom views for dynamic UI rendering.
- Media Handling: Use of Media3 ExoPlayer for audio services.
- Graphical & Statistical Data: MPAndroidChart for visual representation.

- At the top level, show the Android App divided into layers: Presentation, ViewModel, and Data/Repository.
- Under the Data/Repository layer, detail which components interact with the External Backend (Laravel API) and external storage (AWS S3).
- Intersperse the feature-based modules as sub-components within each layer (for example “Features: Auth, Bookmark, Quiz, Recitation, Words, etc.”).
- Dependency injection (Hilt) as an overarching mechanism present in every layer.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Android App Main Container
    subgraph "Android App"
        %% Presentation/UI Layer
        subgraph "Presentation/UI Layer"
            UI_Activities["Activities (MainActivity, TestActivity)"]:::ui
            UI_Fragments["Fragments (Auth, Home, Recitation)"]:::ui
            UI_CustomViews["Custom Views"]:::ui
        end

        %% ViewModel Layer
        subgraph "ViewModel Layer"
            VM_Bookmark["BookmarkWordsViewModel"]:::vm
            VM_Prayer["PrayerTimesViewModel"]:::vm
            VM_Statistics["HomepageStatisticsViewModel"]:::vm
            VM_Quiz["QuizViewModel"]:::vm
        end

        %% Domain/Business Logic
        subgraph "Domain/Business Logic"
            Domain_Utils["Core Utilities & Business Logic"]:::domain
        end

        %% Data/Repository Layer
        subgraph "Data/Repository Layer"
            Data_BookmarkRepo["Bookmark Repository"]:::data
            Data_PrayerRepo["Prayer Times Repository"]:::data
            Data_QuizRepo["Quiz Repository"]:::data
            Data_ApiInterfaces["API Interfaces (AuthApi, QuranApi, QuizApi)"]:::data
            Data_ApiService["API Service (Retrofit)"]:::data
        end
    end

    %% External Backend Services
    External_Laravel["Laravel API (Backend)"]:::external
    External_Mongo["MongoDB Database"]:::external
    External_AWSS3["AWS S3 Storage"]:::external

    %% Multimedia Services
    Multimedia_Media3["Media3 ExoPlayer (Audio Playback)"]:::multimedia

    %% Dependency Injection
    subgraph "Dependency Injection"
        DI_Hilt["Hilt"]:::di
        DI_Prayer["PrayerTimes Module"]:::di
        DI_Quiz["Quiz Module"]:::di
        DI_Word["Words Module"]:::di
    end

    %% Graphical & Statistical Data
    subgraph "Graphical & Statistical Data"
        Charts_Statistics["Statistics & Charts (MPAndroidChart)"]:::charts
        Charts_GraphRenderer["Graph Rendering"]:::charts
    end

    %% Connections between layers within Android App
    UI_Activities -->|"triggers"| VM_Bookmark
    UI_Fragments -->|"triggers"| VM_Prayer
    UI_Fragments -->|"triggers"| VM_Statistics
    UI_CustomViews -->|"triggers"| VM_Quiz

    VM_Bookmark -->|"fetches data"| Data_BookmarkRepo
    VM_Prayer -->|"fetches data"| Data_PrayerRepo
    VM_Quiz -->|"fetches data"| Data_QuizRepo
    VM_Statistics -->|"pulls data"| Data_ApiInterfaces

    Data_BookmarkRepo -->|"calls"| Data_ApiService
    Data_PrayerRepo -->|"calls"| Data_ApiService
    Data_QuizRepo -->|"calls"| Data_ApiService
    Data_ApiInterfaces -->|"defines"| Data_ApiService

    Data_ApiService -->|"REST calls"| External_Laravel
    External_Laravel -->|"DB access"| External_Mongo
    External_Laravel -->|"media retrieval"| External_AWSS3

    %% Multimedia connection (Recitation feature)
    UI_Fragments -->|"handles audio"| Multimedia_Media3

    %% Domain layer connection (used by ViewModels & Repositories)
    VM_Bookmark ---|"utilizes"| Domain_Utils
    VM_Prayer ---|"utilizes"| Domain_Utils
    VM_Statistics ---|"utilizes"| Domain_Utils
    VM_Quiz ---|"utilizes"| Domain_Utils
    Data_BookmarkRepo ---|"utilizes"| Domain_Utils
    Data_PrayerRepo ---|"utilizes"| Domain_Utils
    Data_QuizRepo ---|"utilizes"| Domain_Utils

    %% Dependency Injection integration
    DI_Hilt ---|"injects into"| UI_Activities
    DI_Hilt ---|"injects into"| VM_Bookmark
    DI_Hilt ---|"injects into"| VM_Prayer
    DI_Hilt ---|"injects into"| VM_Statistics
    DI_Hilt ---|"injects into"| VM_Quiz
    DI_Hilt ---|"injects into"| Data_BookmarkRepo
    DI_Hilt ---|"injects into"| Data_PrayerRepo
    DI_Hilt ---|"injects into"| Data_QuizRepo
    DI_Hilt ---|"configures"| DI_Prayer
    DI_Hilt ---|"configures"| DI_Quiz
    DI_Hilt ---|"configures"| DI_Word

    %% Graphical & Statistical Data integration
    VM_Statistics -->|"renders"| Charts_Statistics
    Charts_Statistics -->|"processed by"| Charts_GraphRenderer

    %% Click Events
    click UI_Activities "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/core/activities"
    click UI_Fragments "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/auth"
    click UI_CustomViews "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/core/customViews"
    click VM_Bookmark "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/bookmark/viewmodels"
    click VM_Prayer "https://github.com/zaemazmi/qurannexusmobile/blob/master/app/src/main/java/com/example/qurannexus/features/prayerTimes/PrayerTimesViewModel.kt"
    click VM_Statistics "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/statistics/viewmodels"
    click VM_Quiz "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/quiz/models"
    click Domain_Utils "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/core/utils"
    click Data_BookmarkRepo "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/bookmark/repositories"
    click Data_PrayerRepo "https://github.com/zaemazmi/qurannexusmobile/blob/master/app/src/main/java/com/example/qurannexus/features/prayerTimes/PrayerTimesRepository.kt"
    click Data_QuizRepo "https://github.com/zaemazmi/qurannexusmobile/blob/master/app/src/main/java/com/example/qurannexus/features/quiz/repository/QuizRepository.kt"
    click Data_ApiInterfaces "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/core/interfaces"
    click Data_ApiService "https://github.com/zaemazmi/qurannexusmobile/blob/master/app/src/main/java/com/example/qurannexus/core/network/ApiService.java"
    click Multimedia_Media3 "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/recitation/audio"
    click DI_Prayer "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/prayerTimes/di"
    click DI_Quiz "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/quiz/di"
    click DI_Word "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/words/di"
    click Charts_Statistics "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/statistics"
    click Charts_GraphRenderer "https://github.com/zaemazmi/qurannexusmobile/tree/master/app/src/main/java/com/example/qurannexus/features/graphs"

    %% Styles
    classDef ui fill:#ffadad,stroke:#000,stroke-width:2px;
    classDef vm fill:#ffd6a5,stroke:#000,stroke-width:2px;
    classDef data fill:#fdffb6,stroke:#000,stroke-width:2px;
    classDef domain fill:#caffbf,stroke:#000,stroke-width:2px;
    classDef external fill:#9bf6ff,stroke:#000,stroke-width:2px;
    classDef multimedia fill:#a0c4ff,stroke:#000,stroke-width:2px;
    classDef di fill:#bdb2ff,stroke:#000,stroke-width:2px;
    classDef charts fill:#ffc6ff,stroke:#000,stroke-width:2px;
```
