# shinkaym/trao_doi_do_app architecture

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

- Interactive diagram: https://gitdiagram.com/shinkaym/trao_doi_do_app
- Repository: https://github.com/shinkaym/trao_doi_do_app

## Overview

##### Project Type and Purpose
- This is a multi-platform Flutter application (“trao_doi_do_app”) targeting Android, iOS, Web, Linux, macOS, and Windows.
- It follows a client-side architecture: Dart code, Flutter framework, and platform-specific embedding. No backend code is present in this repo, but the UI screens (login, register, OTP, forgot password) imply consumption of external authentication APIs.

##### File-Structure Analysis
- Top-level platform folders: android, ios, linux, macos, windows, web.
- Core application code lives under lib/:
- core/config (flavors, theme mode)
- core/constants (navigation bar, etc.)
- core/di (dependency injection setup)
- core/router (application routing)
- presentation (common screens, feature folders for auth, custom widgets)
- theme (app theme definitions and extensions)
- main.dart and app.dart bootstrap the Flutter app.
- Build and IDE configurations: pubspec.yaml, analysis_options.yaml, Gradle, Xcode, CMake files.

##### Key Architectural Patterns
- Layered modular structure:
- Presentation layer (UI screens & widgets)
- Core layer (configuration, DI, router)
- Platform embedding (native runners per OS)
- Dependency Injection (likely using get_it or injectable) to decouple services.
- Centralized Router for navigation (auto_route or similar pattern).
- Theming and flavor configuration abstracted into core/config and theme modules.

- Platform Layer (six platform embedders + Flutter Engine)
- Flutter Framework & Dart Runtime
- Application Layer:
- Bootstrap (main.dart → App widget)
- Core/Config & Flavor Manager
- Dependency Injector
- Router (navigation graph)
- Theme Manager
- Presentation modules:
– Auth feature (login, register, OTP, forgot password screens)
– Common screens (not_found)
– Shared widgets (buttons, text fields, scaffold)
- External Services (REST API for authentication)
- (Optional) Local Storage or Secure Storage for tokens

##### Relationships and Data Flows
- App bootstrap loads DI, config, and router → renders initial screen.
- User interactions on Presentation Widgets → routed by AppRouter → screens obtain services via DI.
- Presentation invokes core services (e.g., AuthService) → sends HTTP requests to External Auth API → returns responses → UI updates.
- Theme Manager provides theme data to widgets.
- Each platform embedder hosts the Flutter engine and routes OS events to the Dart layer.

##### Final Checklist
- Clear component labels matching file/folder names
- Presentation layer
- Core/config layer
- Platform embedders & Flutter engine
- External services
- Callouts or notes for key architectural patterns (DI, Router, Flavor)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Embedding Layer
    subgraph "Platform Embedding"
        direction TB
        Android{{"Android\n(android/)"}}
        iOS{{"iOS\n(ios/)"}}
        Web{{"Web\n(web/)"}}
        Linux{{"Linux\n(linux/)"}}
        macOS{{"macOS\n(macos/)"}}
        Windows{{"Windows\n(windows/)"}}
        FlutterEngine{{"Flutter Engine"}}:::platform
    end

    %% Application Layer
    subgraph "Flutter Framework & App Code"
        direction TB
        Main["main.dart\n(lib/main.dart)"]:::core
        AppWidget["App Widget\n(lib/app.dart)"]:::core
        subgraph Core["Core Layer"]
            direction TB
            FlavorConfig["Flavor Config\n(lib/core/config/flavor.dart)"]:::core
            ThemeModeProv["Theme Mode Provider\n(lib/core/config/theme_mode_provider.dart)"]:::core
            NavBarConsts["NavBar Constants\n(lib/core/constants/nav_bar_constants.dart)"]:::core
            DIContainer["DI Container\n(lib/core/di/dependency_injection.dart)"]:::core
            Router["App Router\n(lib/core/router/app_router.dart)"]:::core
        end
        subgraph Theme["Theme Module"]
            direction TB
            AppTheme["App Theme\n(lib/theme/app_theme.dart)"]:::core
            ThemeExt["Theme Extensions\n(lib/theme/extensions/app_theme_extension.dart)"]:::core
        end
        subgraph Presentation["Presentation Layer"]
            direction TB
            subgraph Auth["Auth Feature"]
                direction TB
                LoginScreen("Login Screen\n(lib/presentation/features/auth/screens/login_screen.dart)"):::presentation
                RegisterScreen("Register Screen\n(lib/presentation/features/auth/screens/register_screen.dart)"):::presentation
                OTPScreen("OTP Screen\n(lib/presentation/features/auth/screens/otp_screen.dart)"):::presentation
                ForgotPass("Forgot Password\n(lib/presentation/features/auth/screens/forgot_password_screen.dart)"):::presentation
            end
            NotFound("Not Found Screen\n(lib/presentation/common/screens/not_found_screen.dart)"):::presentation
            subgraph SharedWidgets["Shared Widgets"]
                direction TB
                CustomText("Custom Text Field\n(lib/presentation/widgets/custom_text_field.dart)"):::presentation
                PrimaryBtn("Primary Button\n(lib/presentation/widgets/primary_button.dart)"):::presentation
                SecondaryBtn("Secondary Button\n(lib/presentation/widgets/secondary_button.dart)"):::presentation
                ScaffoldNav("Scaffold w/ NavBar\n(lib/presentation/widgets/scaffold_with_navbar.dart)"):::presentation
            end
        end
    end

    %% External Services
    ExternalAuthAPI[("External Auth API")]:::external

    %% Relationships
    Android --> FlutterEngine
    iOS --> FlutterEngine
    Web --> FlutterEngine
    Linux --> FlutterEngine
    macOS --> FlutterEngine
    Windows --> FlutterEngine

    FlutterEngine --> Main
    Main --> AppWidget
    AppWidget --> FlavorConfig
    AppWidget --> ThemeModeProv
    AppWidget --> DIContainer
    AppWidget --> Router
    AppWidget --> AppTheme
    AppWidget --> ThemeExt

    Router --> LoginScreen
    Router --> RegisterScreen
    Router --> OTPScreen
    Router --> ForgotPass
    Router --> NotFound

    LoginScreen --> DIContainer
    RegisterScreen --> DIContainer
    OTPScreen --> DIContainer
    ForgotPass --> DIContainer

    DIContainer --> ExternalAuthAPI
    ExternalAuthAPI --> DIContainer

    AppWidget --> CustomText
    AppWidget --> PrimaryBtn
    AppWidget --> SecondaryBtn
    AppWidget --> ScaffoldNav

    ThemeExt --> AppTheme

    %% Click Events
    click Android "https://github.com/shinkaym/trao_doi_do_app/tree/main/android/"
    click iOS "https://github.com/shinkaym/trao_doi_do_app/tree/main/ios/"
    click Web "https://github.com/shinkaym/trao_doi_do_app/tree/main/web/"
    click Linux "https://github.com/shinkaym/trao_doi_do_app/tree/main/linux/"
    click macOS "https://github.com/shinkaym/trao_doi_do_app/tree/main/macos/"
    click Windows "https://github.com/shinkaym/trao_doi_do_app/tree/main/windows/"
    click Main "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/main.dart"
    click AppWidget "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/app.dart"
    click FlavorConfig "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/core/config/flavor.dart"
    click ThemeModeProv "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/core/config/theme_mode_provider.dart"
    click NavBarConsts "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/core/constants/nav_bar_constants.dart"
    click DIContainer "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/core/di/dependency_injection.dart"
    click Router "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/core/router/app_router.dart"
    click AppTheme "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/theme/app_theme.dart"
    click ThemeExt "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/theme/extensions/app_theme_extension.dart"
    click LoginScreen "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/presentation/features/auth/screens/login_screen.dart"
    click RegisterScreen "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/presentation/features/auth/screens/register_screen.dart"
    click OTPScreen "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/presentation/features/auth/screens/otp_screen.dart"
    click ForgotPass "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/presentation/features/auth/screens/forgot_password_screen.dart"
    click NotFound "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/presentation/common/screens/not_found_screen.dart"
    click CustomText "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/presentation/widgets/custom_text_field.dart"
    click PrimaryBtn "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/presentation/widgets/primary_button.dart"
    click SecondaryBtn "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/presentation/widgets/secondary_button.dart"
    click ScaffoldNav "https://github.com/shinkaym/trao_doi_do_app/blob/main/lib/presentation/widgets/scaffold_with_navbar.dart"

    %% Styles
    classDef core fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef presentation fill:#E6F4EA,stroke:#2C7A0E,color:#2C7A0E,shape:round;
    classDef external fill:#FFE5B4,stroke:#D2691E,color:#D2691E;
    classDef platform fill:#F0E6FF,stroke:#8A2BE2,color:#8A2BE2;
    class LoginScreen,RegisterScreen,OTPScreen,ForgotPass,NotFound,CustomText,PrimaryBtn,SecondaryBtn,ScaffoldNav presentation
    class Android,iOS,Web,Linux,macOS,Windows,FlutterEngine platform
```
