# muhammad-84/social-media-zego architecture

> Architecture diagram of the GitHub repository muhammad-84/social-media-zego, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/muhammad-84/social-media-zego
- Repository: https://github.com/muhammad-84/social-media-zego

## Overview

##### Project type and purpose
- This is a cross-platform Flutter social-media application (“social_media_zego”) that runs on Android, iOS, web, Windows, macOS, and Linux.
- It uses Firebase (for configuration and possibly authentication/database) and the Zego Cloud SDKs (ZIM for chat, ZEGOCLOUD for audio/video/live-stream) to implement real-time communication features.

##### File structure
- Top-level platform folders (android/, ios/, macos/, windows/, linux/, web/) contain the native runners, configs, and plugin registrants.
- lib/ holds all Dart code:
- main.dart (entry point)
- firebase_options.dart (Firebase config)
- consts/constants.dart (app constants)
- screens/… (UI screens grouped by feature: auth, home, chats, Zego cloud integrations, widgets)
- pubspec.yaml (package dependencies: flutter, firebase_core, zego_zim, zego_uikit_prebuilt_call, etc.)
- test/ for widget tests
- android/gradle and ios/macos runner projects for native builds

##### Additional README insights
- The README is the default Flutter template; it confirms a starter Flutter app, but doesn’t detail architecture.
- We infer a layered architecture:
- Presentation/UI layer (screens/widgets)
- Service layer (Firebase, Zego SDK wrappers)
- Platform & plugin layer (Flutter engine + native plugin code)
- External systems (Firebase backend, Zego Cloud backend)

##### Detailed guidance
1. Presentation Layer (Widgets & Screens)
2. Service Layer (FirebaseService, ZegoChatService, ZegoCallService)
3. Plugin Layer (auto-generated plugin registrants)
- Service Layer → Firebase Backend (labeled: Auth, Firestore, Storage)
- Service Layer → Zego Cloud Backend (labeled: ZIM Chat, Live Stream, Audio/Video Call)
- Blue for Flutter layers
- Green for external backends
- Grey for platform specifics

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Platforms" 
        direction TB
        AndroidRunner["Android Runner & Plugins"]:::plugin
        iOSRunner["iOS Runner & Plugins"]:::plugin
        WebRunner["Web Runner"]:::plugin
        LinuxMain["Linux Runner Main"]:::plugin
        LinuxPlugin["Linux Plugin Registrant"]:::plugin
        macOSMain["macOS Runner Main"]:::plugin
        macOSPlugin["macOS Plugin Registrant"]:::plugin
        WindowsMain["Windows Runner Main"]:::plugin
        WindowsPlugin["Windows Plugin Registrant"]:::plugin
    end

    subgraph "Client App (Flutter)" 
        direction TB
        subgraph "Presentation Layer" 
            direction TB
            LoginScreen["LoginScreen"]:::flutter
            SignUpScreen["SignUpScreen"]:::flutter
            HomeScreen["HomeScreen"]:::flutter
            CreatePostScreen["CreatePostScreen"]:::flutter
            SearchPage["SearchPage"]:::flutter
            ChatList["ChatList"]:::flutter
            ChatScreen["ChatScreen"]:::flutter
            BottomNav["BottomNavigation"]:::flutter
            DrawerWidget["DrawerWidget"]:::flutter
            ImagePostWidget["ImagePostWidget"]:::flutter
            TextPostWidget["TextPostWidget"]:::flutter
            PracticeHome["HomePracticeScreen"]:::flutter
            PracticeSearch["SearchPracticeScreen"]:::flutter

            ZimLogin["ZIM Login"]:::flutter
            ZimChatList["ZIM ChatList"]:::flutter
            ZimAudioCall["ZIM Audio Call"]:::flutter
            ZimVideoCall["ZIM Video Call"]:::flutter
            ZimGroupCall["ZIM Group Call"]:::flutter
            GroupCallScreen["GroupCallScreen"]:::flutter
            LiveStream["Live Stream"]:::flutter
        end

        subgraph "Service Layer"
            direction TB
            FirebaseService["FirebaseService"]:::flutter
            ZegoChatService["ZegoChatService (ZIM)"]:::flutter
            ZegoCallService["ZegoCallService (Audio/Video)"]:::flutter
        end

        subgraph "Plugin Layer"
            direction TB
            PluginRegistrar["Generated Plugin Registrant"]:::plugin
        end
    end

    subgraph "External Backends"
        direction TB
        FirebaseBackend["Firebase Backend"]:::external
        ZegoBackend["Zego Cloud Backend"]:::external
    end

    %% Relationships
    AndroidRunner --> PluginRegistrar
    iOSRunner --> PluginRegistrar
    WebRunner --> PluginRegistrar
    LinuxMain --> PluginRegistrar
    LinuxPlugin --> PluginRegistrar
    macOSMain --> PluginRegistrar
    macOSPlugin --> PluginRegistrar
    WindowsMain --> PluginRegistrar
    WindowsPlugin --> PluginRegistrar

    PluginRegistrar -->|uses| FirebaseService
    PluginRegistrar -->|uses| ZegoChatService
    PluginRegistrar -->|uses| ZegoCallService

    %% UI to Services
    LoginScreen -->|auth calls| FirebaseService
    SignUpScreen -->|auth calls| FirebaseService
    HomeScreen -->|data calls| FirebaseService
    CreatePostScreen -->|storage calls| FirebaseService
    SearchPage -->|queries| FirebaseService
    ChatList -->|chat init| ZegoChatService
    ChatScreen -->|chat messages| ZegoChatService
    BottomNav -->|navigation| HomeScreen
    DrawerWidget -->|UI| HomeScreen
    ImagePostWidget -->|renders| HomeScreen
    TextPostWidget -->|renders| HomeScreen
    PracticeHome -->|demo| FirebaseService
    PracticeSearch -->|demo| FirebaseService

    ZimLogin -->|login| ZegoChatService
    ZimChatList -->|list chats| ZegoChatService
    ZimAudioCall -->|audio call| ZegoCallService
    ZimVideoCall -->|video call| ZegoCallService
    ZimGroupCall -->|group call| ZegoCallService
    GroupCallScreen -->|UI| ZimGroupCall
    LiveStream -->|stream| ZegoCallService

    %% Services to Backends
    FirebaseService -->|Auth/Firestore/Storage| FirebaseBackend
    ZegoChatService -->|ZIM Chat API| ZegoBackend
    ZegoCallService -->|Audio/Video API| ZegoBackend

    %% Entry point and config
    EntryPoint["main.dart"]:::flutter --> FirebaseService
    EntryPoint --> ZegoChatService
    EntryPoint --> ZegoCallService

    FirebaseConfig["firebase_options.dart"]:::flutter --> FirebaseService
    Constants["constants.dart"]:::flutter --> EntryPoint

    %% Click events
    click AndroidRunner "https://github.com/muhammad-84/social-media-zego/blob/master/android/app/src/main/kotlin/com/example/social_media_zego/MainActivity.kt"
    click iOSRunner "https://github.com/muhammad-84/social-media-zego/blob/master/ios/Runner/AppDelegate.swift"
    click WebRunner "https://github.com/muhammad-84/social-media-zego/blob/master/web/index.html"
    click LinuxMain "https://github.com/muhammad-84/social-media-zego/blob/master/linux/runner/main.cc"
    click LinuxPlugin "https://github.com/muhammad-84/social-media-zego/blob/master/linux/flutter/generated_plugin_registrant.cc"
    click macOSMain "https://github.com/muhammad-84/social-media-zego/blob/master/macos/Runner/MainFlutterWindow.swift"
    click macOSPlugin "https://github.com/muhammad-84/social-media-zego/blob/master/macos/Flutter/GeneratedPluginRegistrant.swift"
    click WindowsMain "https://github.com/muhammad-84/social-media-zego/blob/master/windows/runner/main.cpp"
    click WindowsPlugin "https://github.com/muhammad-84/social-media-zego/blob/master/windows/flutter/generated_plugin_registrant.cc"

    click EntryPoint "https://github.com/muhammad-84/social-media-zego/blob/master/lib/main.dart"
    click FirebaseConfig "https://github.com/muhammad-84/social-media-zego/blob/master/lib/firebase_options.dart"
    click Constants "https://github.com/muhammad-84/social-media-zego/blob/master/lib/consts/constants.dart"

    click LoginScreen "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/auth/login-screen.dart"
    click SignUpScreen "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/auth/sign-up-screen.dart"
    click HomeScreen "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/home/home-screen.dart"
    click CreatePostScreen "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/home/create-post-screen.dart"
    click SearchPage "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/home/search-page.dart"
    click ChatList "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/chats/chat-list.dart"
    click ChatScreen "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/chats/chat-screen.dart"
    click BottomNav "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/bottom-navigaton-screen.dart"
    click DrawerWidget "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/widgets/drawer-widget.dart"
    click ImagePostWidget "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/widgets/PostWidgets/image-post-widget.dart"
    click TextPostWidget "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/widgets/PostWidgets/text-post-widget.dart"
    click PracticeHome "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/practiceFolder/home-practice-screen.dart"
    click PracticeSearch "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/practiceFolder/search-practice-screen.dart"

    click ZimLogin "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/ZegoCLoud/ZimAuth/zim-login.dart"
    click ZimChatList "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/ZegoCLoud/ZimChats/zim-chat-list.dart"
    click ZimAudioCall "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/ZegoCLoud/ZimChats/zim-audio-call.dart"
    click ZimVideoCall "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/ZegoCLoud/ZimChats/zim-video-call.dart"
    click ZimGroupCall "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/ZegoCLoud/ZimChats/zim-group-call.dart"
    click GroupCallScreen "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/ZegoCLoud/ZimChats/group-call-screen.dart"
    click LiveStream "https://github.com/muhammad-84/social-media-zego/blob/master/lib/screens/ZegoCLoud/ZimChats/zego-live-stream.dart"

    classDef flutter fill:#ADD8E6,stroke:#0000FF,color:#000
    classDef plugin fill:#D3D3D3,stroke:#666,color:#000
    classDef external fill:#90EE90,stroke:#008000,color:#000
```
