# mindinventory/flutter_web_rtc_with_call_kit architecture

> Architecture diagram of the GitHub repository mindinventory/flutter_web_rtc_with_call_kit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mindinventory/flutter_web_rtc_with_call_kit
- Repository: https://github.com/mindinventory/flutter_web_rtc_with_call_kit

## Overview

1. This is a Flutter mobile app for peer-to-peer audio/video calling, with native call UX on iOS via CallKit and Android/iOS platform setup for the Flutter runtime. The app is not a backend service; most application logic lives in the Flutter layer, with Firebase used as the cloud dependency for auth, signaling, and push notifications.

2. The architecture is split into three main planes:
   - UI/presentation in `lib/features/presentation/pages`
   - state management in `lib/features/presentation/bloc`
   - shared infrastructure/utilities in `lib/core` and dependency wiring in `lib/di`
   Native platform shells sit in `android/` and `ios/` to enable WebRTC, push, and call UI integrations.

3. Authentication is a distinct subsystem. The pages `authentication_page.dart`, `login_page.dart`, and `sign_up_page.dart` are backed by `auth_bloc`, which likely coordinates Firebase auth and user session state. After sign-in, the user is routed to `home_page.dart`, which acts as the app’s main control surface for initiating or receiving calls.

4. The calling subsystem is centered on WebRTC signaling plus media session handling. `signaling_bloc` indicates the app separates call/session events from general authentication. The app pages `audio_call_page.dart` and `video_call_page.dart` represent the in-call UI, while signaling logic likely exchanges SDP/ICE information through Firebase rather than a bespoke server.

5. Firebase is the main cloud boundary in this repo. The presence of `firebase_core`, `cloud_firestore`, `firebase_messaging`, `firebase_options.dart`, and `firebase.json` indicates the app depends on Firebase for:
   - app bootstrap/configuration
   - persistent user/call metadata
   - signaling message exchange or call state storage
   - push notifications for incoming calls

6. Incoming call handling is split between cloud messaging and native call presentation. `lib/core/utils/fcm_helper.dart` and `lib/core/utils/callkit_helper.dart` suggest FCM wakes or notifies the device, then CallKit presents the system-level incoming-call UI. The user’s accept/decline action then flows back into Flutter to continue or terminate the WebRTC session.

7. The data model layer is lightweight and generated from JSON serializable models. `user.dart` and `notification_payload.dart` with their `.g.dart` companions imply the app serializes Firestore/notification data into strongly typed Dart objects. This layer is the boundary between cloud payloads and BLoC/UI logic.

8. `lib/core/utils` contains cross-cutting infrastructure rather than feature logic. It includes navigation, shared preferences, general helpers, and platform/service wrappers. `shared_prefs.dart` plus `shared_prefs_constants.dart` indicate local persistence for session flags or lightweight app settings, while `app_navigator.dart` centralizes route transitions.

9. `lib/core/widgets` is a shared UI component library used across the feature pages. Components like custom buttons, text fields, image loading, app bars, and loading indicators keep the feature screens thin and consistent, which matters when diagramming the UI layer as composed of reusable primitives rather than duplicated page-specific widgets.

10. Dependency injection is explicit in `lib/di/injector.dart`. That file is the composition root for service and bloc wiring, so the app’s runtime dependencies are assembled centrally before UI pages consume them. This is important for the architecture diagram because it separates construction of services from their use in pages/blocs.

11. Platform code is minimal but necessary. Android uses a standard Flutter host with `MainActivity.kt` and Gradle configuration, while iOS includes `AppDelegate.swift`, a bridged header, CocoaPods setup, and Xcode workspace/project files. The native layer mainly exists to enable Flutter embedding, permissions, push notifications, and the CallKit integration required by the calling flow.

12. The repo is dependency-heavy on mobile communication libraries: `flutter_webrtc` for media transport and peer connection, `flutter_callkit_incoming` for system incoming-call presentation, and Firebase SDKs for cloud services. These libraries define the main external boundaries in the architecture more than any custom server code does.

13. The expected runtime flow is: app starts -> Firebase initializes -> auth state determines entry point -> user reaches home -> user initiates or receives a call -> signaling data is exchanged through Firebase -> WebRTC establishes media transport -> in-call pages render the session -> ending the call tears down both the peer connection and any active native call UI.

14. In diagram terms, the most important boundaries are:
   - Flutter UI versus BLoC/state management
   - BLoC versus Firebase/WebRTC service utilities
   - Flutter runtime versus native Android/iOS call/notification hooks
   - local persistence versus cloud-backed auth/signaling
   This repo is best understood as a client application orchestrating real-time media and push-driven call setup, not as a server-centric system.

Main entry points: [`lib/di/injector.dart`](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/di/injector.dart) (Injector), [`lib/features/presentation/bloc/signaling_bloc/signaling_bloc.dart`](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/bloc/signaling_bloc/signaling_bloc.dart) (Signaling BLoC), [`lib/core/widgets/custom_appbar.dart`](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/widgets/custom_appbar.dart) (Shared widgets), [`lib/features/presentation/bloc/auth_bloc/auth_bloc.dart`](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/bloc/auth_bloc/auth_bloc.dart) (Auth BLoC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_auth_bloc{{"Auth BLoC<br/>state bloc<br/>[auth_bloc.dart]"}}
  node_signaling_bloc{{"Signaling BLoC<br/>state bloc"}}
  node_authentication_page["Auth gate<br/>page"]
  node_login_page["Login<br/>page<br/>[login_page.dart]"]
  node_sign_up_page["Sign up<br/>page<br/>[sign_up_page.dart]"]
  node_home_page["Home<br/>page<br/>[home_page.dart]"]
  node_audio_call_page["Audio call<br/>page"]
  node_video_call_page["Video call<br/>page"]
end

subgraph group_core["Core"]
  node_main["App entry<br/>Flutter bootstrap<br/>[main.dart]"]
  node_firebase_options["Firebase opts<br/>Firebase config"]
  node_injector["Injector<br/>DI composition<br/>[injector.dart]"]
  node_app_navigator["Navigator<br/>routing helper<br/>[app_navigator.dart]"]
  node_shared_prefs[("Prefs<br/>local storage<br/>[shared_prefs.dart]")]
  node_fcm_helper["FCM helper<br/>push helper<br/>[fcm_helper.dart]"]
  node_callkit_helper["CallKit helper<br/>native call bridge"]
  node_shared_widgets["Shared widgets<br/>UI primitives<br/>[custom_appbar.dart]"]
end

subgraph group_data["Data"]
  node_user_model["User model<br/>serializable model<br/>[user.dart]"]
  node_notification_payload["Notif payload<br/>serializable model"]
end

subgraph group_native["Native"]
  node_android_shell["Android shell<br/>native host<br/>[MainActivity.kt]"]
  node_ios_shell["iOS shell<br/>native host<br/>[AppDelegate.swift]"]
end

subgraph group_external["External"]
  node_firebase[("Firebase<br/>cloud boundary")]
  node_webrtc{{"WebRTC<br/>media transport"}}
  node_callkit["CallKit<br/>system call UI"]
  node_fcm["FCM<br/>push service"]
  node_local_storage[("Local storage<br/>device persistence")]
end

node_main -->|"configures"| node_firebase_options
node_main -->|"builds"| node_injector
node_main -->|"runs on"| node_android_shell
node_main -->|"runs on"| node_ios_shell
node_injector -->|"wires"| node_auth_bloc
node_injector -->|"wires"| node_signaling_bloc
node_injector -->|"injects"| node_app_navigator
node_injector -->|"injects"| node_shared_prefs
node_injector -->|"injects"| node_fcm_helper
node_injector -->|"injects"| node_callkit_helper
node_authentication_page -->|"uses"| node_auth_bloc
node_login_page -->|"uses"| node_auth_bloc
node_sign_up_page -->|"uses"| node_auth_bloc
node_home_page -->|"uses"| node_signaling_bloc
node_home_page -->|"routes"| node_app_navigator
node_audio_call_page -->|"uses"| node_signaling_bloc
node_video_call_page -->|"uses"| node_signaling_bloc
node_auth_bloc -->|"authenticates"| node_firebase
node_auth_bloc -->|"maps"| node_user_model
node_signaling_bloc -->|"signals via"| node_firebase
node_signaling_bloc -->|"establishes"| node_webrtc
node_signaling_bloc -->|"maps"| node_notification_payload
node_fcm_helper -->|"listens to"| node_fcm
node_callkit_helper -->|"presents"| node_callkit
node_fcm_helper -->|"decodes"| node_notification_payload
node_shared_prefs -->|"reads/writes"| node_local_storage
node_android_shell -->|"enables"| node_fcm
node_ios_shell -->|"enables"| node_fcm
node_ios_shell -->|"enables"| node_callkit
node_shared_widgets -->|"used by"| node_authentication_page
node_shared_widgets -->|"used by"| node_login_page
node_shared_widgets -->|"used by"| node_sign_up_page
node_shared_widgets -->|"used by"| node_home_page
node_shared_widgets -->|"used by"| node_audio_call_page
node_shared_widgets -->|"used by"| node_video_call_page

click node_main "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/main.dart"
click node_firebase_options "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/firebase_options.dart"
click node_injector "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/di/injector.dart"
click node_app_navigator "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/utils/app_navigator.dart"
click node_shared_prefs "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/utils/shared_prefs.dart"
click node_fcm_helper "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/utils/fcm_helper.dart"
click node_callkit_helper "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/utils/callkit_helper.dart"
click node_shared_widgets "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/widgets/custom_appbar.dart"
click node_auth_bloc "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/bloc/auth_bloc/auth_bloc.dart"
click node_signaling_bloc "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/bloc/signaling_bloc/signaling_bloc.dart"
click node_authentication_page "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/authentication_page.dart"
click node_login_page "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/login_page.dart"
click node_sign_up_page "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/sign_up_page.dart"
click node_home_page "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/home_page.dart"
click node_audio_call_page "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/audio_call_page.dart"
click node_video_call_page "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/video_call_page.dart"
click node_user_model "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/data/model/user.dart"
click node_notification_payload "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/data/model/notification_payload.dart"
click node_android_shell "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/android/app/src/main/kotlin/com/example/flutter_web_rtc_with_call_kit/MainActivity.kt"
click node_ios_shell "https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/ios/Runner/AppDelegate.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_auth_bloc,node_signaling_bloc,node_authentication_page,node_login_page,node_sign_up_page,node_home_page,node_audio_call_page,node_video_call_page toneBlue
class node_main,node_firebase_options,node_injector,node_app_navigator,node_shared_prefs,node_fcm_helper,node_callkit_helper,node_shared_widgets toneAmber
class node_user_model,node_notification_payload toneMint
class node_android_shell,node_ios_shell toneRose
class node_firebase,node_webrtc,node_callkit,node_fcm,node_local_storage toneIndigo
```

## Components

### Presentation

Flutter pages and BLoC state flow

- [Auth BLoC](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/bloc/auth_bloc/auth_bloc.dart): state bloc · Session and authentication state management · `lib/features/presentation/bloc/auth_bloc/auth_bloc.dart`
- [Signaling BLoC](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/bloc/signaling_bloc/signaling_bloc.dart): state bloc · Call session and signaling state management · `lib/features/presentation/bloc/signaling_bloc/signaling_bloc.dart`
- [Auth gate](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/authentication_page.dart): page · Entry screen that routes into auth flow · `lib/features/presentation/pages/authentication_page.dart`
- [Login](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/login_page.dart): page · User sign-in screen · `lib/features/presentation/pages/login_page.dart`
- [Sign up](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/sign_up_page.dart): page · Account creation screen · `lib/features/presentation/pages/sign_up_page.dart`
- [Home](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/home_page.dart): page · Main control surface for calls · `lib/features/presentation/pages/home_page.dart`
- [Audio call](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/audio_call_page.dart): page · In-call audio UI · `lib/features/presentation/pages/audio_call_page.dart`
- [Video call](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/presentation/pages/video_call_page.dart): page · In-call video UI · `lib/features/presentation/pages/video_call_page.dart`

### Core

Shared utilities, widgets, and dependency wiring

- [App entry](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/main.dart): Flutter bootstrap · Initializes the app runtime and wiring · `lib/main.dart`
- [Firebase opts](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/firebase_options.dart): Firebase config · Generated Firebase initialization options · `lib/firebase_options.dart`
- [Injector](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/di/injector.dart): DI composition · Central dependency wiring for blocs and services · `lib/di/injector.dart`
- [Navigator](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/utils/app_navigator.dart): routing helper · Centralized route transitions and page navigation · `lib/core/utils/app_navigator.dart`
- [Prefs](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/utils/shared_prefs.dart): local storage · Wrapper for lightweight persisted app state · `lib/core/utils/shared_prefs.dart`
- [FCM helper](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/utils/fcm_helper.dart): push helper · Device push and incoming-call wakeup handling · `lib/core/utils/fcm_helper.dart`
- [CallKit helper](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/utils/callkit_helper.dart): native call bridge · System incoming-call presentation bridge · `lib/core/utils/callkit_helper.dart`
- [Shared widgets](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/core/widgets/custom_appbar.dart): UI primitives · Reusable buttons, fields, loaders, and app bars · `lib/core/widgets/custom_appbar.dart`

### Data

Serializable models and cloud payloads

- [User model](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/data/model/user.dart): serializable model · Typed user/session payload boundary · `lib/features/data/model/user.dart`
- [Notif payload](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/lib/features/data/model/notification_payload.dart): serializable model · Push notification/call payload boundary · `lib/features/data/model/notification_payload.dart`

### Native

Android and iOS host shells

- [Android shell](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/android/app/src/main/kotlin/com/example/flutter_web_rtc_with_call_kit/MainActivity.kt): native host · Flutter Android embedding and Gradle setup · `android/app/src/main/kotlin/com/example/flutter_web_rtc_with_call_kit/MainActivity.kt`
- [iOS shell](https://github.com/mindinventory/flutter_web_rtc_with_call_kit/blob/main/ios/Runner/AppDelegate.swift): native host · Flutter iOS embedding and CallKit-capable host · `ios/Runner/AppDelegate.swift`

### External

Cloud, media, and OS integrations

- **Firebase**: cloud boundary · Auth, Firestore, messaging, and app config backplane
- **WebRTC**: media transport · Peer connection and real-time audio/video transport
- **CallKit**: system call UI · Native incoming-call presentation on iOS
- **FCM**: push service · Cloud push notifications for incoming calls
- **Local storage**: device persistence · On-device app preferences and session flags

## Connections

- App entry → Firebase opts: configures · Bootstraps Firebase before the app runs
- App entry → Injector: builds · Creates the dependency graph
- App entry → Android shell: runs on · Uses the Android host runtime
- App entry → iOS shell: runs on · Uses the iOS host runtime
- Injector → Auth BLoC: wires · Registers authentication state management
- Injector → Signaling BLoC: wires · Registers call signaling state management
- Injector → Navigator: injects · Provides centralized navigation services
- Injector → Prefs: injects · Provides local persistence access
- Injector → FCM helper: injects · Provides push notification helper
- Injector → CallKit helper: injects · Provides native call UI bridge
- Auth gate → Auth BLoC: uses · Entry flow delegates to auth state
- Login → Auth BLoC: uses · Login form dispatches auth events
- Sign up → Auth BLoC: uses · Sign-up form dispatches auth events
- Home → Signaling BLoC: uses · Home screen starts and receives calls
- Home → Navigator: routes · Moves between auth, home, and call screens
- Audio call → Signaling BLoC: uses · Reflects active audio session state
- Video call → Signaling BLoC: uses · Reflects active video session state
- Auth BLoC → Firebase: authenticates · Relies on Firebase-backed user session data
- Auth BLoC → User model: maps · Converts cloud user data into typed state
- Signaling BLoC → Firebase: signals via · Uses Firebase as call signaling backplane
- Signaling BLoC → WebRTC: establishes · Coordinates peer connection lifecycle
- Signaling BLoC → Notif payload: maps · Converts push/call metadata into typed state
- FCM helper → FCM: listens to · Receives incoming call notifications
- CallKit helper → CallKit: presents · Shows system-level call UI
- FCM helper → Notif payload: decodes · Parses push payloads into app state
- Prefs → Local storage: reads/writes · Persists lightweight client settings
- Android shell → FCM: enables · Hosts Android push and runtime integration
- iOS shell → FCM: enables · Hosts iOS push integration
- iOS shell → CallKit: enables · Supports native incoming-call presentation
- Shared widgets → Auth gate: used by · Supports auth screens
- Shared widgets → Login: used by · Supports login screens
- Shared widgets → Sign up: used by · Supports sign-up screens
- Shared widgets → Home: used by · Supports main control surface
- Shared widgets → Audio call: used by · Supports call UI
- Shared widgets → Video call: used by · Supports call UI
