# mohamad-amen/chat-direct architecture

> Architecture diagram of the GitHub repository mohamad-amen/chat-direct, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamad-amen/chat-direct
- Repository: https://github.com/mohamad-amen/chat-direct

## Overview

##### Project type and purpose
- This is a client‐only, single‐page Flutter mobile application targeting Android.
- Purpose: let users enter a phone number (with country code) and launch a WhatsApp chat via a wa.me URL without saving the contact.

##### File structure
- Top‐level:
- android/ – native Android host and build scripts (Gradle, manifest, Kotlin MainActivity)
- lib/ – Flutter/Dart source code, subdivided into constants, data, models, providers, screens, widgets
- pubspec.yaml(.lock) – dependencies (e.g., hive, provider, url_launcher)
- devtools_options.yaml, analysis_options.yaml – lint & debugging configs
- lib breakdown:
- constants/ – hardcoded keys & defaults
- data/local_data.dart – Hive storage wrapper
- models/phone_code_model.dart – data representation of country code
- providers/phone_code_provider.dart – state management (selected code)
- screens/main_screen.dart – single UI screen entry point
- widgets/ – reusable UI components (dialog, fields, buttons, list)

##### README for additional insights
- Core features: country-code dialog, local persistence via Hive, auto-selection on field input, launching wa.me URL.
- No backend or external API beyond URL launch.

##### Elements
- UI → Provider (events)
- Provider ↔ Hive (read/write)
- UI → URL Launcher → wa.me
- State/Business logic (green)
- Data (orange)
- Platform & external (gray)

##### Detail without over-fragmentation
- Flutter sub‐layer (screens vs. widgets)
- Data model (PhoneCodeModel) flowing through provider
- Assets as an input to UI
- Android host only as the Flutter engine entry point

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        AppBootstrap["Flutter App Bootstrap\n(lib/main.dart)"]:::presentation
        MainScreen["MainScreen\n(lib/screens/main_screen.dart)"]:::presentation
        Assets["Assets\n(country phone codes.json, country phone codes.xlsx,\napp icons)"]:::presentation
        subgraph "Widgets"
            direction TB
            TopBar["Top Bar\n(lib/widgets/top_bar.dart)"]:::presentation
            PhoneNumberField["Phone Number Input Field\n(lib/widgets/phone_number_field.dart)"]:::presentation
            PhoneCodeField["Country Code Field\n(lib/widgets/phone_code_field.dart)"]:::presentation
            PhoneCodeDialogue["Country Code Selection Dialog\n(lib/widgets/phone_code_dialogue.dart)"]:::presentation
            PhoneCodeList["Country Code List\n(lib/widgets/phone_code_list_widget.dart)"]:::presentation
            PhoneCodeButton["Launch Chat Button\n(lib/widgets/phone_code_button.dart)"]:::presentation
        end
    end

    %% State Management Layer
    subgraph "State Management Layer"
        direction TB
        PhoneCodeProvider["PhoneCodeProvider\n(lib/providers/phone_code_provider.dart)"]:::state
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        LocalData["LocalData Wrapper\n(lib/data/local_data.dart)"]:::data
        PhoneCodeModel["PhoneCodeModel\n(lib/models/phone_code_model.dart)"]:::data
        Constants["App Constants & Defaults\n(lib/constants/constants.dart)"]:::data
    end

    %% Platform & Config
    subgraph "Platform & Config"
        direction TB
        AndroidHost["MainActivity\n(android/app/src/main/kotlin/com/mohamad/amen/chat_direct/MainActivity.kt)"]:::platform
        URLLauncherPlugin["URL Launcher Plugin\n(pubspec.yaml)"]:::platform
        PubspecLock["Lock File\n(pubspec.lock)"]:::platform
        AnalysisOptions["analysis_options.yaml"]:::platform
        DevtoolsOptions["devtools_options.yaml"]:::platform
    end

    %% External Service
    subgraph "External Service"
        direction TB
        WhatsApp["WhatsApp wa.me URL"]:::external
    end

    %% Connections
    AppBootstrap -->|starts| MainScreen
    MainScreen -->|renders| TopBar
    MainScreen -->|renders| PhoneNumberField
    MainScreen -->|renders| PhoneCodeField
    MainScreen -->|renders| PhoneCodeDialogue
    MainScreen -->|renders| PhoneCodeList
    MainScreen -->|renders| PhoneCodeButton
    Assets -->|provides data| PhoneCodeDialogue
    PhoneCodeField -->|reads selection| PhoneCodeProvider
    TopBar -->|displays title| MainScreen
    PhoneNumberField -->|updates number| PhoneCodeProvider
    PhoneCodeList -->|selects code| PhoneCodeProvider
    PhoneCodeButton -->|on tap| URLLauncherPlugin
    PhoneCodeButton -->|requests launch| WhatsApp
    PhoneCodeProvider -->|reads/writes| LocalData
    LocalData -->|stores model| PhoneCodeModel
    PhoneCodeProvider -->|uses| PhoneCodeModel
    MainScreen -->|runs on| AndroidHost

    %% Click Events
    click AndroidHost "https://github.com/mohamad-amen/chat-direct/blob/main/android/app/src/main/kotlin/com/mohamad/amen/chat_direct/MainActivity.kt"
    click AppBootstrap "https://github.com/mohamad-amen/chat-direct/blob/main/lib/main.dart"
    click MainScreen "https://github.com/mohamad-amen/chat-direct/blob/main/lib/screens/main_screen.dart"
    click TopBar "https://github.com/mohamad-amen/chat-direct/blob/main/lib/widgets/top_bar.dart"
    click PhoneNumberField "https://github.com/mohamad-amen/chat-direct/blob/main/lib/widgets/phone_number_field.dart"
    click PhoneCodeField "https://github.com/mohamad-amen/chat-direct/blob/main/lib/widgets/phone_code_field.dart"
    click PhoneCodeDialogue "https://github.com/mohamad-amen/chat-direct/blob/main/lib/widgets/phone_code_dialogue.dart"
    click PhoneCodeList "https://github.com/mohamad-amen/chat-direct/blob/main/lib/widgets/phone_code_list_widget.dart"
    click PhoneCodeButton "https://github.com/mohamad-amen/chat-direct/blob/main/lib/widgets/phone_code_button.dart"
    click PhoneCodeProvider "https://github.com/mohamad-amen/chat-direct/blob/main/lib/providers/phone_code_provider.dart"
    click LocalData "https://github.com/mohamad-amen/chat-direct/blob/main/lib/data/local_data.dart"
    click PhoneCodeModel "https://github.com/mohamad-amen/chat-direct/blob/main/lib/models/phone_code_model.dart"
    click Constants "https://github.com/mohamad-amen/chat-direct/blob/main/lib/constants/constants.dart"
    click URLLauncherPlugin "https://github.com/mohamad-amen/chat-direct/blob/main/pubspec.yaml"
    click PubspecLock "https://github.com/mohamad-amen/chat-direct/blob/main/pubspec.lock"
    click AnalysisOptions "https://github.com/mohamad-amen/chat-direct/blob/main/analysis_options.yaml"
    click DevtoolsOptions "https://github.com/mohamad-amen/chat-direct/blob/main/devtools_options.yaml"

    %% Styles
    classDef presentation fill:#E0F7FA,stroke:#006064,color:#006064
    classDef state fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef data fill:#FFF3E0,stroke:#EF6C00,color:#EF6C00
    classDef platform fill:#ECEFF1,stroke:#455A64,color:#455A64
    classDef external fill:#CFD8DC,stroke:#546E7A,color:#546E7A
```
