# datdoan20/store_code_717 architecture

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

- Interactive diagram: https://gitdiagram.com/datdoan20/store_code_717
- Repository: https://github.com/datdoan20/store_code_717

## Overview

##### Main Components Identification

a. Mobile Application (Client-side)
- iOS App
- Android App
- React Native Core
- WebRTC Implementation
- Navigation System
- UI Components

b. Backend Services
- Firebase Firestore (Signaling Server)
- STUN Server (Google's public STUN server)

**┌─────────────────────────────────────────────────────────────┐**
- Client Applications                      │
- ┬────────────────────────┬──────────────────┤
- iOS App     │    React Native Core   │   Android App    │
- ┴────────────────────────┴──────────────────┘

- ┬──────┴───────┬──────────┘

- ┌───────────────────┐ ┌──────────────┐
- WebRTC Module    │ │   Firebase   │
- (Peer Connection) │ │   Firestore  │
- ┘ └──────────────┘

- ┌──────┴──────┐
- Signaling  │
- Server    │
- ┬──────┘

- ┌───────────────────────────────────────────┐
- STUN Server (Google)           │
- ┘

##### Key Flows

a. Signaling Flow:
**Caller → Firebase Firestore → Callee**
- Offer/Answer exchange
- ICE candidate exchange

b. Media Flow:
**Caller ←→ STUN Server ←→ Callee**
**(Direct P2P connection after successful signaling)**

##### Important Details

- WebRTC Configuration:
- ICE Servers configuration
- Peer Connection setup
- Stream handling

- Firebase Integration:
- Document structure for signaling
- Real-time updates
- Candidate collection

##### Component Interactions

Following key interactions:
- Initial call setup
- Stream exchange
- Signaling process
- Hangup procedure

##### Technical Stack Callouts

- React Native WebRTC (v1.92.1)
- Firebase Firestore
- React Native Firebase
- Native platform specifics (iOS/Android)

Remember to include notes about the asynchronous nature of the WebRTC connection process and how the signaling server (Firebase Firestore) facilitates the initial connection before P2P communication is established.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client_Layer
        iOS["iOS App"]:::ios
        Android["Android App"]:::android
        RNCore["React Native Core"]:::react
    end

    subgraph Communication_Layer
        WebRTC["WebRTC Module<br/>(Peer Connection)"]:::webrtc
        Firebase["Firebase Firestore"]:::firebase
    end

    subgraph Infrastructure_Layer
        Signaling["Signaling Server"]:::server
        STUN["STUN Server<br/>(Google)"]:::stun
    end

    subgraph Components_Layer
        Navigation["Navigation System"]:::component
        StreamHandler["Stream Handler"]:::component
        VideoUI["Video Call UI Components"]:::component
    end

    %% Connections
    iOS --> RNCore
    Android --> RNCore
    RNCore --> WebRTC
    RNCore --> Navigation
    RNCore --> StreamHandler
    RNCore --> VideoUI
    WebRTC <--> STUN
    WebRTC <--> Firebase
    Firebase <--> Signaling

    %% Click Events
    click iOS "https://github.com/DatDoan20/store_code_717/blob/master/ios/StoreCode717/AppDelegate.mm"
    click Android "https://github.com/DatDoan20/store_code_717/blob/master/android/app/src/main/java/com/nichietsu/storecode717/MainActivity.java"
    click RNCore "https://github.com/DatDoan20/store_code_717/blob/master/app/App.tsx"
    click Navigation "https://github.com/DatDoan20/store_code_717/blob/master/app/navigators/index.tsx"
    click WebRTC "https://github.com/DatDoan20/store_code_717/blob/master/app/screens/videoCall/videoCallWebRtc.tsx"
    click StreamHandler "https://github.com/DatDoan20/store_code_717/blob/master/app/utils/stream.ts"
    click VideoUI "https://github.com/DatDoan20/store_code_717/tree/master/app/screens/videoCall"

    %% Styles
    classDef ios fill:#a0d8ef
    classDef android fill:#a5d6a7
    classDef react fill:#61dafb
    classDef webrtc fill:#4caf50
    classDef firebase fill:#ffa000
    classDef server fill:#90a4ae
    classDef stun fill:#78909c
    classDef component fill:#ce93d8

    %% Legend
    subgraph Legend
        L1["iOS Components"]:::ios
        L2["Android Components"]:::android
        L3["React Native"]:::react
        L4["WebRTC"]:::webrtc
        L5["Firebase"]:::firebase
        L6["Server Components"]:::server
        L7["STUN/TURN"]:::stun
        L8["UI Components"]:::component
    end
```
