# alexcao194/grammar_polisher architecture

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

- Interactive diagram: https://gitdiagram.com/alexcao194/grammar_polisher
- Repository: https://github.com/alexcao194/grammar_polisher

## Overview

##### Main Components
- Mobile Application Core – Highlight the Flutter framework as the foundation.
- UI Layer – Represented by the “lib/ui” directory. Illustrate multiple screens (e.g., home, grammar, vocabulary, onboarding, notifications, streak, review) and common widgets. Emphasize usability features like custom dialogs, themed components, and the use of common assets (images, fonts, lottie animations).
- Business Logic Layer – Represent the BLoC modules within “lib/ui/blocs” and individual screen-specific business logic (e.g., translate, grammar, notifications, settings, streak, vocabulary).
- Data Layer – Show components under “lib/data” (data_sources, models, repositories). Include data sources like asset JSON files, local storage (using Hive in lib/configs/hive), and perhaps remote APIs. Indicate repositories that coordinate data access and transformation for the UI and BLoC layers.
- Configuration & Services – Include “lib/configs” which hosts dependency injection (di.dart), Dio configuration (for network requests with logging and connectivity interception), and Hive configurations.
- Navigation – Represent “lib/navigation” with routing and route paths, showcasing how the application navigates between screens.
- External Integrations – Illustrate links to external services:
- Firebase (as seen by the requirement for google-services.json and GoogleService-Info.plist).
- Ad services with integrations in “lib/ui/commons/ads” and utility files in “lib/utils/ad”.
- Third-party plugins and libraries (Flutter, Dart, Fastlane for Android/iOS builds).

##### Relationships and Interactions
- That the data repositories abstract multiple data sources (local asset files, Hive, remote APIs) and pass the data back to the BLoC.
- Configuration components (dependency injection, Dio interceptors) as shared services accessible by BLoC and repositories.

##### Architectural Patterns and Design Principles
- Use of the BLoC pattern for state management and separation of concerns.
- Repository/interface segregation design where domain-specific repositories (e.g., oxford_words_repository, lesson_repository, notifications_repository) serve as data brokers.
- Dependency injection (lib/configs/di.dart) to enable modular design and ease of testing.
- Asset management (assets folder) and code generation aspects (via build_runner for generated files in lib/generated).

##### Relevant Technologies and Frameworks
- Flutter and Dart as the core development framework.
- Hive for local data storage; Dio for network communication.
- BLoC for state management (supported by Flutter Bloc plugins).
- Fastlane (with dedicated files and configuration) for CI/CD on Android and iOS.
- Native mobile platform configurations, such as Gradle for Android and Xcode/Cocoapods for iOS.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Application Core
    MA["Mobile Application Core (main.dart)"]:::core

    %% UI Layer
    subgraph "UI Layer (Screens & Widgets)"
        UI["UI (lib/ui)"]:::ui
        S["Screens: Grammar, Vocabulary, Onboarding, Notifications, Streak, Review"]:::ui
        W["Common Widgets & Assets"]:::ui
    end

    %% Business Logic Layer (BLoC Modules)
    subgraph "Business Logic (BLoC Modules)"
        BLC["General BLoC (lib/ui/blocs)"]:::logic
        GB["Screen-specific BLoCs: Grammar, Notifications, Settings, Streak, Vocabulary"]:::logic
    end

    %% Data Layer (Repositories & Data Sources)
    subgraph "Data Layer (Repositories & Data Sources)"
        REP["Repositories (lib/data/repositories)"]:::data
        DS["Data Sources (lib/data/data_sources)"]:::data
        MOD["Models (lib/data/models)"]:::data
    end

    %% Configuration & Services
    subgraph "Configuration & Services"
        DI["Dependency Injection (di.dart)"]:::config
        DIO["Dio Setup (lib/configs/dio)"]:::config
        HIVE["Hive Config (lib/configs/hive)"]:::config
    end

    %% Navigation
    subgraph "Navigation"
        NAV["Routing & Route Paths (lib/navigation)"]:::nav
    end

    %% External Integrations
    subgraph "External Integrations"
        ADS["Ad Services (lib/ui/commons/ads)"]:::external
        ADUTIL["Ad Utilities (lib/utils/ad)"]:::external
        FIRE["Firebase & Mobile Configurations"]:::external
    end

    %% Build/Deployment & Environment Configurations
    subgraph "Build/Deployment & Environment Configurations"
        ENV["Environment Files (.env.example, .env.example/development.json)"]:::build
        FAST_AND["Fastlane (Android)"]:::build
        FAST_IOS["Fastlane (iOS)"]:::build
        NP_AND["Android Project (android/)"]:::build
        NP_IOS["iOS Project (ios/)"]:::build
    end

    %% Relationships
    MA -->|"initializes"| DI
    MA --> UI
    MA --> NAV

    UI -->|"triggers"| BLC
    BLC -->|"fetches/updates"| REP
    BLC -->|"accesses"| DS

    DI -->|"injects into"| BLC
    DI -->|"provides to"| REP
    DIO --> REP
    HIVE --> REP

    UI -->|"navigates via"| NAV

    REP -->|"aggregates from"| DS
    REP -->|"manages"| MOD

    REP -->|"integrates with"| FIRE
    DS -->|"sourced by"| FIRE

    UI -->|"displays ads"| ADS
    ADS --> ADUTIL

    %% External flow to Build/Deployment (configuration chain)
    FIRE --> FAST_AND
    FIRE --> FAST_IOS
    FAST_AND --> NP_AND
    FAST_IOS --> NP_IOS

    %% Class Definitions (Styles)
    classDef core fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef logic fill:#d1ffd1,stroke:#155724,stroke-width:2px;
    classDef data fill:#ffe6cc,stroke:#856404,stroke-width:2px;
    classDef config fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef nav fill:#e6ccff,stroke:#4a148c,stroke-width:2px;
    classDef external fill:#ffffcc,stroke:#8a6d3b,stroke-width:2px;
    classDef build fill:#ccffff,stroke:#0c5460,stroke-width:2px;

    %% Click Events
    click MA "https://github.com/alexcao194/grammar_polisher/blob/master/lib/main.dart"
    click UI "https://github.com/alexcao194/grammar_polisher/tree/master/lib/ui"
    click BLC "https://github.com/alexcao194/grammar_polisher/tree/master/lib/ui/blocs"
    click REP "https://github.com/alexcao194/grammar_polisher/tree/master/lib/data"
    click DI "https://github.com/alexcao194/grammar_polisher/blob/master/lib/configs/di.dart"
    click DIO "https://github.com/alexcao194/grammar_polisher/tree/master/lib/configs/dio"
    click HIVE "https://github.com/alexcao194/grammar_polisher/tree/master/lib/configs/hive"
    click NAV "https://github.com/alexcao194/grammar_polisher/tree/master/lib/navigation"
    click ADS "https://github.com/alexcao194/grammar_polisher/tree/master/lib/ui/commons/ads"
    click ADUTIL "https://github.com/alexcao194/grammar_polisher/tree/master/lib/utils/ad"
    click FAST_AND "https://github.com/alexcao194/grammar_polisher/tree/master/android/fastlane"
    click FAST_IOS "https://github.com/alexcao194/grammar_polisher/tree/master/ios/fastlane"
    click NP_AND "https://github.com/alexcao194/grammar_polisher/tree/master/android/"
    click NP_IOS "https://github.com/alexcao194/grammar_polisher/tree/master/ios/"
    click ENV "https://github.com/alexcao194/grammar_polisher/blob/master/.env.example"
    click ENV "https://github.com/alexcao194/grammar_polisher/blob/master/.env.example/development.json"
```
