# viethantrinh/go_linguage_client_app architecture

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

- Interactive diagram: https://gitdiagram.com/viethantrinh/go_linguage_client_app
- Repository: https://github.com/viethantrinh/go_linguage_client_app

## Overview

##### Project Type and Purpose
- This is a Flutter mobile application built with a strong emphasis on modularity.
- The project follows a Clean Architecture or layered architecture pattern where each feature (e.g., auth, home, lesson, payment, setting, subject, user_info) is split into subdirectories for data, domain, and presentation.
- The README indicates it’s a starting point for a Flutter project, but the rich file structure shows that it integrates multiple functionalities such as authentication, lesson management, payment processing, and subject handling.

##### Analyzing the File Structure
- Top-Level Directories:
- Android: Contains native configurations, Gradle scripts, and other Android-specific resources.
- lib: The main codebase which is further divided into two main parts:
▪ core: Contains shared utilities, constants, network clients (using Dio), error handling, theme, routing, logging, and dependency injection (via the init_dependencies.dart file).
▪ features: Contains feature-specific modules (auth, home, lesson, payment, search, setting, subject, user_info, and main). Each feature is further divided into layers (data, domain, and presentation), indicating adherence to a Clean Architecture.

##### Key Components
a. Mobile Application Layer:
- Flutter Application Entry Point (lib/main.dart)
- Android Native Configurations (android/ directory)

b. Core Infrastructure:
- Core services such as network (dio_client.dart), connectivity (connectivity_bloc and service), error handling, logging, theming, routing, and secret management.
- Shared widgets and constants.

c. Feature Modules:
- Each feature (e.g., auth, home, lesson, payment, etc.) should be depicted as a separate module.
- Within each module, show layers dividing into:
- Data Layer: Repositories, remote/local data sources, and models.
- Domain Layer: Entities, business logic (use cases), and repository interfaces.
- Presentation Layer: Flutter pages, BLoC (Business Logic Components for state management), and UI widgets.
- For example, the “auth” feature folder contains:
- Data: datasources, models, and repository implementations.
- Domain: entities, repository definitions, and use cases (like signIn, signUp, googleAuth, etc.).
- Presentation: BLoC for managing state and pages/widgets for the UI.

d. External Interactions:
- API interactions (network, remote data sources).
- Payment integrations or subscriptions, if these are connected to external services.
- Notification services as indicated by the notification_service.dart.

##### Architectural Patterns and Design Principles
- Clean Architecture: Separation into Data, Domain, and Presentation layers for each feature.
- Modular Design: Each feature is self-contained, making the system extensible.
- State Management: Use of BLoC across features indicates a reactive programming approach, where events, states, and transitions are clearly modeled.
- Dependency Injection: The presence of an “init_dependencies.dart” suggests that cross-cutting concerns are managed in a centralized way.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level Mobile Application
    F["Mobile Application"]:::flutter
    F --> A["Flutter Application Entry Point"]:::flutter
    F --> B["Android Native Configuration"]:::android
    F --> G["Flutter Codebase"]:::flutter

    %% Flutter Codebase: Core Layer and Features Layer
    subgraph "Flutter Codebase"
        direction TB
        %% Core Layer Subgraph
        subgraph "Core Layer"
            direction TB
            core1["Network Client (Dio)"]:::core
            core2["Connectivity Service"]:::core
            core3["Dependency Injection"]:::core
            core4["Routing"]:::core
            core5["Theming"]:::core
            core6["Logging"]:::core
            core7["Error Handling"]:::core
            core8["Notification Service"]:::core
        end

        %% Features Layer Subgraph
        subgraph "Features Layer"
            direction TB
            %% Auth Feature Module
            subgraph "Auth Feature Module"
                direction TB
                authData["Data Layer"]:::feature_data
                authDomain["Domain Layer"]:::feature_domain
                authPres["Presentation Layer (BLoC, UI)"]:::feature_presentation
                authPres -->|"invokes"| authDomain
                authDomain -->|"fetchesFrom"| authData
            end

            %% Home Feature Module
            subgraph "Home Feature Module"
                direction TB
                homeData["Data Layer"]:::feature_data
                homeDomain["Domain Layer"]:::feature_domain
                homePres["Presentation Layer (BLoC, UI)"]:::feature_presentation
                homePres -->|"calls"| homeDomain
                homeDomain -->|"retrieves"| homeData
            end

            %% Lesson Feature Module
            subgraph "Lesson Feature Module"
                direction TB
                lessonData["Data Layer"]:::feature_data
                lessonDomain["Domain Layer"]:::feature_domain
                lessonPres["Presentation Layer (BLoC, UI)"]:::feature_presentation
                lessonPres -->|"triggers"| lessonDomain
                lessonDomain -->|"queries"| lessonData
            end

            %% Payment Feature Module
            subgraph "Payment Feature Module"
                direction TB
                paymentData["Data Layer"]:::feature_data
                paymentDomain["Domain Layer"]:::feature_domain
                paymentPres["Presentation Layer (BLoC, UI)"]:::feature_presentation
                paymentPres -->|"initiates"| paymentDomain
                paymentDomain -->|"processes"| paymentData
            end

            %% Search Feature Module
            subgraph "Search Feature Module"
                direction TB
                searchPres["Presentation Layer"]:::feature_presentation
            end

            %% Setting Feature Module
            subgraph "Setting Feature Module"
                direction TB
                settingPres["Presentation Layer"]:::feature_presentation
            end

            %% Subject Feature Module
            subgraph "Subject Feature Module"
                direction TB
                subjectData["Data Layer"]:::feature_data
                subjectDomain["Domain Layer"]:::feature_domain
                subjectPres["Presentation Layer (BLoC, UI)"]:::feature_presentation
                subjectPres -->|"requests"| subjectDomain
                subjectDomain -->|"accesses"| subjectData
            end

            %% User Info Feature Module
            subgraph "User Info Feature Module"
                direction TB
                userInfoPres["Presentation Layer"]:::feature_presentation
            end

            %% Main Feature Module
            subgraph "Main Feature Module"
                direction TB
                mainPres["Presentation Layer (BLoC, UI)"]:::feature_presentation
            end
        end
    end

    %% Cross-layer interactions (Clean Architecture flow)
    %% (These arrows illustrate typical data flow)
    authPres ---|"UI->UseCase"| authDomain
    authDomain ---|"Repository Call"| authData

    homePres ---|"UI->UseCase"| homeDomain
    homeDomain ---|"Repository Call"| homeData

    lessonPres ---|"UI->UseCase"| lessonDomain
    lessonDomain ---|"Repository Call"| lessonData

    paymentPres ---|"UI->UseCase"| paymentDomain
    paymentDomain ---|"Repository Call"| paymentData

    subjectPres ---|"UI->UseCase"| subjectDomain
    subjectDomain ---|"Repository Call"| subjectData

    %% Core services used by features (example connections)
    authPres ---|"navigates via"| core4
    lessonPres ---|"fetches data via"| core1
    paymentPres ---|"logs via"| core6

    %% Styles
    classDef flutter fill:#B3E5FC,stroke:#01579B,stroke-width:2px;
    classDef android fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef core fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef feature_data fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef feature_domain fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef feature_presentation fill:#FFECB3,stroke:#FFA000,stroke-width:2px;

    %% Click Events
    click A "https://github.com/viethantrinh/go_linguage_client_app/blob/main/lib/main.dart"
    click B "https://github.com/viethantrinh/go_linguage_client_app/tree/main/android/"
    click core1 "https://github.com/viethantrinh/go_linguage_client_app/blob/main/lib/core/network/dio_client.dart"
    click core2 "https://github.com/viethantrinh/go_linguage_client_app/blob/main/lib/core/network/connectivity_service.dart"
    click core3 "https://github.com/viethantrinh/go_linguage_client_app/blob/main/lib/init_dependencies.dart"
    click core4 "https://github.com/viethantrinh/go_linguage_client_app/blob/main/lib/core/route/app_route.dart"
    click core5 "https://github.com/viethantrinh/go_linguage_client_app/blob/main/lib/core/theme/app_theme.dart"
    click core6 "https://github.com/viethantrinh/go_linguage_client_app/blob/main/lib/core/log/log.dart"
    click core7 "https://github.com/viethantrinh/go_linguage_client_app/blob/main/lib/core/error/exceptions.dart"
    click core8 "https://github.com/viethantrinh/go_linguage_client_app/blob/main/lib/core/services/notification_service.dart"
    click authData "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/auth/data"
    click authDomain "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/auth/domain"
    click authPres "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/auth/presentation"
    click homeData "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/home/data"
    click homeDomain "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/home/domain"
    click homePres "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/home/presentation"
    click lessonData "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/lesson/data"
    click lessonDomain "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/lesson/domain"
    click lessonPres "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/lesson/presentation"
    click paymentData "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/payment/data"
    click paymentDomain "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/payment/domain"
    click paymentPres "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/payment/presentation"
    click searchPres "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/search/presentation"
    click settingPres "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/setting/presentation"
    click subjectData "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/subject/data"
    click subjectDomain "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/subject/domain"
    click subjectPres "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/subject/presentation"
    click userInfoPres "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/user_info/presentation"
    click mainPres "https://github.com/viethantrinh/go_linguage_client_app/tree/main/lib/features/main/presentation"
```
