# dexterfury/flutter_chat_pro architecture

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

- Interactive diagram: https://gitdiagram.com/dexterfury/flutter_chat_pro
- Repository: https://github.com/dexterfury/flutter_chat_pro

## Overview

##### Project type and purpose
- This is a cross-platform chat application built in Flutter, targeting Android, iOS, web, Linux, macOS, and Windows.
- It uses Firebase as its backend (Authentication, Firestore real-time database, and Storage).
- The app implements screens for login, user profile setup, one-to-one chat, group chat, friend management, and media (audio/video) messages.

##### File structure
- Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web”: platform folders generated by Flutter.
- “lib” folder: the heart of the app.
- lib/main.dart: app entry point.
- lib/authentication: login, onboarding, user info screens.
- lib/main_screen: all chat UI (home, chats list, groups, profile, settings).
- lib/models: Data classes (UserModel, MessageModel, GroupModel, etc.).
- lib/providers: State management using the Provider package (AuthenticationProvider, ChatProvider, GroupProvider).
- lib/streams: Data layer abstraction over Firestore streams (ChatsStream, SearchStream).
- lib/widgets: Reusable UI components (chat bubbles, app bars, message list, audio/video player).
- Configuration files: pubspec.yaml (dependencies), firebase_options_sample.dart (Firebase setup placeholder).

##### README for additional insights
- Describes the requirement to supply your own Firebase configuration files.
- Calls out Firebase services (Authentication, Firestore, Storage).

##### Main components
a. Client Application (Flutter)
- UI Layer: Widgets and Screens.
- State Management Layer: Providers (AuthProvider, ChatProvider, GroupProvider).
- Data Stream Layer: ChatsStream, SearchStream.
b. Firebase (Cloud)
- Authentication Service: email/password, phone, etc.
- Firestore Database: “users,” “chats,” “groups,” “messages” collections.
- Storage: media files (images, audio, video) linked in messages.
- (Optional) Cloud Functions: for advanced server-side logic (not present in code but common extension).
c. External Services
- Push Notifications (Firebase Cloud Messaging).
- Analytics / Crashlytics (if integrated).

##### Relationships and interactions
- UI triggers actions (e.g., “send message”) via Provider.
- Provider calls Data Stream which invokes Firestore API.
- Firestore returns snapshots to Streams, which update Providers.
- Providers notify UI of state changes (new messages, friend requests).
- Storage used by Providers to upload/download media.
- Authentication Provider handles sign-in/up via Firebase Auth.
- Optional: FCM pushes notifications to the Flutter App.

##### Architectural patterns and design principles
- MVVM-style separation:
- View = Flutter Widgets
- ViewModel = Providers
- Model = Data classes + Streams
- Reactive data flow using Firestore real-time listeners.
- Dependency injection via Provider package.
- Single source of truth in Firestore; offline persistence handled by SDK.

##### Relevant technologies/frameworks
- Flutter (Dart)
- Provider (state management)
- Firebase SDK: firebase_auth, cloud_firestore, firebase_storage, firebase_messaging
- Dart Streams for real-time updates.
- Platform adapters auto-generated under “android”, “ios”, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
  Entry["App Entry Point"]:::entry
  subgraph "UI Layer"
    subgraph "Authentication Screens"
      Landing["Landing Screen"]:::ui
      Login["Login Screen"]:::ui
      Opt["OTP Screen"]:::ui
      UserInfo["User Info Screen"]:::ui
    end
    subgraph "Main Chat Screens"
      Home["Home Screen"]:::ui
      MyChats["My Chats Screen"]:::ui
      Chat["Chat Screen"]:::ui
      Groups["Groups Screen"]:::ui
      CreateGroup["Create Group Screen"]:::ui
      PrivateGroup["Private Group Screen"]:::ui
      PublicGroup["Public Group Screen"]:::ui
      GroupInfo["Group Info Screen"]:::ui
      GroupSettings["Group Settings Screen"]:::ui
      FriendReq["Friend Requests Screen"]:::ui
      Friends["Friends Screen"]:::ui
      People["People Screen"]:::ui
      Profile["Profile Screen"]:::ui
    end
    Widgets["Reusable Widgets"]:::ui
  end

  subgraph "State Management Layer"
    AuthProv["AuthProvider"]:::provider
    ChatProv["ChatProvider"]:::provider
    GroupProv["GroupProvider"]:::provider
  end

  subgraph "Data Streams Layer"
    ChatsStream["ChatsStream"]:::stream
    SearchStream["SearchStream"]:::stream
  end

  subgraph "Configuration & Utilities"
    Config["Firebase Options"]:::config
    Constants["App Constants"]:::config
    Utilities["Utilities"]:::config
    Assets["Assets"]:::config
  end

  subgraph "Cloud Services"
    Auth["Firebase Auth"]:::cloud
    Firestore["Firestore\n(users, chats, groups, messages)"]:::database
    Storage["Firebase Storage"]:::cloud
    FCM["FCM (Push Notifications)"]:::cloud
  end

  Entry -->|starts app| Landing
  Landing -->|User Action| AuthProv
  Login -->|User Action| AuthProv
  UserInfo -->|User Action| AuthProv
  Home -->|User Action| ChatProv
  Groups -->|User Action| GroupProv
  Widgets -->|Used by Screens| Landing

  AuthProv -->|authenticate| Auth
  AuthProv -->|fetch user| Firestore
  ChatProv -->|fetch/send data| ChatsStream
  GroupProv -->|fetch/send data| SearchStream

  ChatsStream -->|snapshot listener| Firestore
  SearchStream -->|snapshot listener| Firestore
  ChatProv -->|upload media| Storage

  FCM -->|push notifications| Landing
  FCM -->|push notifications| Home

  %% Click Events
  click Entry "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main.dart"
  click Landing "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/authentication/landing_screen.dart"
  click Login "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/authentication/login_screen.dart"
  click Opt "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/authentication/opt_screen.dart"
  click UserInfo "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/authentication/user_information_screen.dart"
  click Home "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/home_screen.dart"
  click MyChats "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/my_chats_screen.dart"
  click Chat "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/chat_screen.dart"
  click Groups "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/groups_screen.dart"
  click CreateGroup "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/create_group_screen.dart"
  click PrivateGroup "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/private_group_screen.dart"
  click PublicGroup "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/public_group_screen.dart"
  click GroupInfo "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/group_information_screen.dart"
  click GroupSettings "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/group_settings_screen.dart"
  click FriendReq "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/friend_requests_screen.dart"
  click Friends "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/friends_screen.dart"
  click People "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/people_screen.dart"
  click Profile "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/main_screen/profile_screen.dart"
  click Widgets "https://github.com/dexterfury/flutter_chat_pro/tree/main/lib/widgets/"
  click AuthProv "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/providers/authentication_provider.dart"
  click ChatProv "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/providers/chat_provider.dart"
  click GroupProv "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/providers/group_provider.dart"
  click ChatsStream "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/streams/chats_stream.dart"
  click SearchStream "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/streams/search_stream.dart"
  click Config "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/firebase_options_sample.dart"
  click Constants "https://github.com/dexterfury/flutter_chat_pro/blob/main/lib/constants.dart"
  click Utilities "https://github.com/dexterfury/flutter_chat_pro/tree/main/lib/utilities/"
  click Assets "https://github.com/dexterfury/flutter_chat_pro/tree/main/assets/images/"

  classDef ui fill:#D6EAF8,stroke:#3498DB,color:#1B4F72
  classDef provider fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
  classDef stream fill:#E8DAEF,stroke:#9B59B6,color:#4A235A
  classDef database fill:#D5F5E3,stroke:#27AE60,color:#145A32
  classDef cloud fill:#FADBD8,stroke:#E74C3C,color:#641E16
  classDef entry fill:#EBDEF0,stroke:#BB8FCE,color:#4A235A
  classDef config fill:#F2F3F4,stroke:#95A5A6,color:#2C3E50
```
