# codewithmurli/real-time-chat-app architecture

> Architecture diagram of the GitHub repository codewithmurli/real-time-chat-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codewithmurli/real-time-chat-app
- Repository: https://github.com/codewithmurli/real-time-chat-app

## Overview

##### Project type and purpose
- This is a cross-platform real-time chat application built with Flutter.
- It targets mobile (Android, iOS), desktop (Windows, Mac, Linux), and web.
- It uses Firebase for authentication, real-time data (Cloud Firestore or RTDB), storage, and Cloud Functions for server-side logic (e.g., push notifications).

##### File structure
- Top-level “android”, “ios”, “web”, “linux”, “macos”, “windows”: native runners for each platform, auto-generated by Flutter.
- lib/main.dart: application entry point.
- lib/core: app-wide constants and reusable UI widgets.
- lib/models: data models for User, Chat, Message.
- lib/providers: state-management layer (AuthProvider, ChatProvider, ThemeProvider) using Provider.
- lib/services: wrappers around Firebase SDKs (auth_service, chat_service, storage_service, notification_service).
- functions/: Node.js Cloud Functions for server-side tasks (index.js), likely handling push notifications.

##### (empty) README for architectural hints
- Although empty here, we know from file names that the app uses Firebase services heavily and follows a Provider-based MVVM pattern.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Flutter Application Platforms
    subgraph "Flutter App"
        direction TB
        Platforms["Android / iOS / Web / Linux / macOS / Windows"]:::flutter
        Main["lib/main.dart"]:::flutter
        click Main "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/main.dart"

        %% Presentation Layer
        subgraph "Presentation Layer" 
            direction TB
            Widgets["UI Widgets"]:::flutter
            click Widgets "https://github.com/codewithmurli/real-time-chat-app/tree/main/lib/core/widgets/"
            Constants["App Constants"]:::flutter
            click Constants "https://github.com/codewithmurli/real-time-chat-app/tree/main/lib/core/constants/"

            subgraph "Screens"
                direction TB
                AuthScreens["Authentication Screens"]:::flutter
                click AuthScreens "https://github.com/codewithmurli/real-time-chat-app/tree/main/lib/screens/auth/"
                ChatScreens["Chat Screens"]:::flutter
                click ChatScreens "https://github.com/codewithmurli/real-time-chat-app/tree/main/lib/screens/chat/"
                ProfileScreen["Profile Screen"]:::flutter
                click ProfileScreen "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/screens/profile/profile_screen.dart"
            end
        end

        %% State Layer
        subgraph "State Layer (Providers)"
            direction TB
            AuthProvider["AuthProvider"]:::flutter
            click AuthProvider "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/providers/auth_provider.dart"
            ChatProvider["ChatProvider"]:::flutter
            click ChatProvider "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/providers/chat_provider.dart"
            ThemeProvider["ThemeProvider"]:::flutter
            click ThemeProvider "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/providers/theme_provider.dart"
        end

        %% Domain Layer
        subgraph "Domain Layer (Models)"
            direction TB
            UserModel["UserModel"]:::flutter
            click UserModel "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/models/user_model.dart"
            ChatModel["ChatModel"]:::flutter
            click ChatModel "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/models/chat_model.dart"
            MessageModel["MessageModel"]:::flutter
            click MessageModel "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/models/message_model.dart"
        end

        %% Data Layer - Services
        subgraph "Data Layer (Services)"
            direction TB
            AuthService["AuthService"]:::flutter
            click AuthService "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/services/auth_service.dart"
            ChatService["ChatService"]:::flutter
            click ChatService "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/services/chat_service.dart"
            StorageService["StorageService"]:::flutter
            click StorageService "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/services/storage_service.dart"
            NotificationService["NotificationService"]:::flutter
            click NotificationService "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/services/notification_service.dart"
            FirebaseConfig["firebase_options.dart"]:::flutter
            click FirebaseConfig "https://github.com/codewithmurli/real-time-chat-app/blob/main/lib/firebase_options.dart"
        end
    end

    %% Firebase Cloud Services
    subgraph "Firebase Cloud" 
        direction TB
        Auth["Firebase Auth"]:::firebase
        Firestore["Cloud Firestore / RTDB"]:::firebase
        Storage["Firebase Storage"]:::firebase
        FCM["Firebase Cloud Messaging"]:::firebase
    end

    %% Cloud Functions
    CloudFunctions["Cloud Functions (Node.js)"]:::cloudfunc
    click CloudFunctions "https://github.com/codewithmurli/real-time-chat-app/blob/main/functions/index.js"
    CloudPkg["functions/package.json"]:::cloudfunc
    click CloudPkg "https://github.com/codewithmurli/real-time-chat-app/blob/main/functions/package.json"
    CloudESLint["functions/.eslintrc.js"]:::cloudfunc
    click CloudESLint "https://github.com/codewithmurli/real-time-chat-app/blob/main/functions/.eslintrc.js"

    %% Data Flows
    Widgets -->|"calls"| AuthProvider
    Widgets -->|"calls"| ChatProvider
    Widgets -->|"calls"| ThemeProvider

    AuthProvider -->|"uses"| AuthService
    ChatProvider -->|"uses"| ChatService
    ThemeProvider -->|"uses"| StorageService
    ChatProvider -->|"uses"| NotificationService

    AuthService -->|"↔"| Auth
    ChatService -->|"read/write"| Firestore
    StorageService -->|"upload/download"| Storage
    NotificationService -->|"push via"| FCM

    %% Domain usage
    AuthProvider -->|"models"| UserModel
    ChatProvider -->|"models"| ChatModel
    ChatProvider -->|"models"| MessageModel

    %% Firebase triggers Cloud Functions
    Firestore -.->|"onWrite trigger"| CloudFunctions
    CloudFunctions -->|"send via"| FCM

    %% Styling
    classDef flutter fill:#D0E8FF,stroke:#0066CC
    classDef firebase fill:#E0FFE0,stroke:#009900
    classDef cloudfunc fill:#FFE8D0,stroke:#CC6600
```
