# raj-pavara/word-wave architecture

> Architecture diagram of the GitHub repository raj-pavara/word-wave, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raj-pavara/word-wave
- Repository: https://github.com/raj-pavara/word-wave

## Overview

##### Project type and purpose
- Word Wave is a full-stack mobile chat application (Android client) that leverages Firebase for backend services (Authentication, Firestore, Realtime Database, Storage) and ZegoCloud for audio/video calling.
- The app is organized around five user-facing sections: Authentication, Profile Initialization/Edit, Main Activity (with Chat List, Photo Status, Profile Info, Search User), Individual Chat, and Individual User Info.

##### File structure
- Top-level “app” module contains all Android code and resources.
- src/main/java/com/example/wordwave: Activities (Authentication, ForgetPassword, OTP_Verification, PhoneNumber_Authentication, Splash_Screen, MainActivity, IndividualChat, IndividualUserInfo, PhotoStatus, ProfileFragment, StatusFragment, ChatsFragment), helper classes (MessageModel, ToastMaker), adapters (RecyclerAdapter*, Custom_Viewpager_Adapter), dialogs (ProfilePicDialog)
- Build scripts: Gradle Kotlin DSL (build.gradle.kts, settings.gradle.kts, libs.versions.toml)
- No custom backend code—push/pull goes to Firebase and ZegoCloud SDKs.

##### README for architecture insights
- Authentication via Firebase Auth (Google, Email/Password, Phone/OTP).
- User profile data in Firebase Firestore; profile images in Firebase Storage.
- Chat messages and user status (“online” flag, last seen) in Firebase Realtime Database.
- Photo status files also in Realtime Database + Storage.
- ZegoCloud SDK used for in-app audio/video calls.
- UI flows orchestrated by Activities + Fragments + RecyclerViews.

##### Main components
a. Android Client
- UI Layer: Activities & Fragments (Authentication screens, Profile Init/Edit, MainActivity tabs, IndividualChat, IndividualUserInfo)
- Presentation/Adapter Layer: RecyclerView Adapters, Custom Viewpager Adapter, Dialogs
- Domain/Model Layer: MessageModel, user-status models, utilities (ToastMaker)
- Service Layer: Firebase SDK clients, ZegoCloud SDK client
b. Firebase Backend Services
- Authentication Service (OAuth & custom email/phone)
- Firestore (user profile collection)
- Realtime Database (chat messages, status, photo statuses)
- Storage (profile pictures, status images)
c. ZegoCloud Audio/Video Calling Service
d. External Services
- Google Sign-In API
- Device notifications (if applicable)

##### Relationships and data flows
- User opens Android app → UI Layer (Activity/Fragment)
- App calls Firebase Auth to sign in/up → Auth Service
- On successful auth → Firestore read/write for profile init/edit; Storage uploads images
- In MainActivity:
- Chat List & Search User → reads chat partners from Realtime DB → displays via RecyclerView
- Photo Status → reads/writes status entries (image URLs) in Realtime DB & Storage
- Profile Info → reads user document from Firestore
- Individual Chat → two-way streaming with Realtime DB for messages and user status flags
- Audio/Video Call buttons → invoke ZegoCloud SDK APIs → stream peer-to-peer or via ZegoCloud servers
- External Google Sign-In flow delegates back to Firebase Auth

##### Architectural patterns and design principles
- Separation of Concerns:
- UI Components (Activities/Fragments) only handle user interaction
- Adapters handle data binding for RecyclerViews
- Service Layer (Firebase & ZegoCloud clients) encapsulates network calls
- Model classes encapsulate data structures
- Reactive / Event-Driven updates via Firebase Realtime listeners
- Stateless UI; state persists in Firebase services

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Android Client Layer
    subgraph "Android Client" 
        direction TB
        subgraph "UI Layer" 
            direction TB
            Auth["Authentication"]:::client
            FP["ForgetPassword"]:::client
            OTP["OTP_Verification"]:::client
            PNA["PhoneNumber_Authentication"]:::client
            Splash["Splash_Screen"]:::client
            MainAct["MainActivity"]:::client
            ChatUI["IndividualChat"]:::client
            UserInfoUI["IndividualUserInfo"]:::client
            PhotoStatusUI["PhotoStatus"]:::client
            ProfileFrag["ProfileFragment"]:::client
            StatusFrag["StatusFragment"]:::client
            ChatsFrag["ChatsFragment"]:::client
        end
        subgraph "Presentation / Adapter Layer"
            direction TB
            ViewPager["Custom_Viewpager_Adapter"]:::client
            ChatAdapter["RecyclerAdapterIndividualChat"]:::client
            PhotoAdapter["RecyclerAdapterPhotoStatus"]:::client
            SearchAdapter["RecyclerAdapterSearchBar"]:::client
            PicDialog["ProfilePicDialog"]:::client
        end
        subgraph "Domain / Model Layer"
            direction TB
            MsgModel["MessageModel"]:::client
            ToastUtil["ToastMaker"]:::client
        end
    end

    %% Service Clients Layer
    subgraph "Service Layer" 
        direction TB
        AuthClient["FirebaseAuth SDK"]:::service
        FirestoreClient["Firestore SDK"]:::service
        RealtimeClient["RealtimeDB SDK"]:::service
        StorageClient["Storage SDK"]:::service
        ZegoClient["ZegoCloud SDK"]:::service
    end

    %% Cloud Services Layer
    subgraph "Cloud Services"
        direction TB
        AuthService["Firebase Auth Service"]:::db
        FirestoreSrv["Firestore Database"]:::db
        RealtimeSrv["Realtime Database"]:::db
        StorageSrv["Firebase Storage"]:::db
        ZegoSrv["ZegoCloud Servers"]:::external
        GoogleAPI["Google Sign-In API"]:::external
    end

    %% Data Flows
    Auth -->|"signInWithEmail()"| AuthClient
    PNA -->|"signInWithPhone()"| AuthClient
    OTP -->|"verifyOTP()"| AuthClient
    AuthClient -->|"delegate"| GoogleAPI
    AuthClient -->|"onAuthSuccess()"| FirestoreClient
    AuthClient -->|"onAuthSuccess()"| RealtimeClient
    FirestoreClient -->|"read/write profile()"| FirestoreSrv
    StorageClient -->|"uploadProfilePic()"| StorageSrv
    MainAct -->|"loadTabs()"| ViewPager
    ChatsFrag -->|"listenForChats()"| RealtimeClient
    PhotoStatusUI -->|"postStatus()"| RealtimeClient
    PhotoStatusUI -->|"uploadImage()"| StorageClient
    StatusFrag -->|"listenStatus()"| RealtimeClient
    ChatsFrag -->|"bindData()"| ChatAdapter
    PhotoStatusUI -->|"bindData()"| PhotoAdapter
    MainAct -->|"searchUser()"| SearchAdapter
    MainAct -->|"openProfile()"| ProfileFrag
    MainAct -->|"openStatus()"| StatusFrag
    MainAct -->|"openChats()"| ChatsFrag
    ChatUI -->|"sendMessage()"| RealtimeClient
    ChatUI -->|"listenForMessages()"| RealtimeClient
    ChatUI -->|"bindMessages()"| ChatAdapter
    UserInfoUI -->|"loadUserInfo()"| FirestoreClient
    UserInfoUI -->|"loadUserStatus()"| RealtimeClient
    UserInfoUI -->|"showProfilePic()"| PicDialog
    MsgModel -.-> ToastUtil
    ChatUI ---> MsgModel
    UserInfoUI ---> MsgModel

    MainAct -->|"startCall()"| ZegoClient
    ZegoClient -->|"streamAV()"| ZegoSrv

    %% Click Events
    click Auth "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/Authentication.java"
    click FP "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/ForgetPassword.java"
    click OTP "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/OTP_Verification.java"
    click PNA "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/PhoneNumber_Authentication.java"
    click Splash "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/Splash_Screen.java"
    click MainAct "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/MainActivity.java"
    click ChatUI "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/IndividualChat.java"
    click UserInfoUI "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/IndividualUserInfo.java"
    click PhotoStatusUI "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/PhotoStatus.java"
    click ProfileFrag "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/ProfileFragment.java"
    click StatusFrag "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/StatusFragment.java"
    click ChatsFrag "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/ChatsFragment.java"
    click ViewPager "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/Custom_Viewpager_Adapter.java"
    click ChatAdapter "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/RecyclerAdapterIndividualChat.java"
    click PhotoAdapter "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/RecyclerAdapterPhotoStatus.java"
    click SearchAdapter "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/RecyclerAdapterSearchBar.java"
    click PicDialog "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/ProfilePicDialog.java"
    click MsgModel "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/MessageModel.java"
    click ToastUtil "https://github.com/raj-pavara/word-wave/blob/main/app/src/main/java/com/example/wordwave/ToastMaker.java"
    click StorageClient "https://github.com/raj-pavara/word-wave/blob/main/app/google-services.json"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef service fill:#FFD700,stroke:#000,stroke-width:1px
    classDef db fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
```
