# mahmoud-azmy/ai-weather-app architecture

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

- Interactive diagram: https://gitdiagram.com/mahmoud-azmy/ai-weather-app
- Repository: https://github.com/mahmoud-azmy/ai-weather-app

## Overview

##### Project type and purpose
- This is a full-stack, cross-platform mobile application built with Flutter (Dart).
- Purpose: provide real-time weather updates, location-based forecasts, user authentication (via Firebase), and a custom ML-powered tennis prediction feature served by a Python backend.

##### File structure
- Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web” folders – platform shells generated by Flutter.
- “lib/” holds the Dart application code, structured by Clean Architecture:
– core/ (shared utilities, network services, error handling, DI)
– features/ (each feature broken into data, domain, presentation layers)
- “app.py” + “random_forest_model.pkl” at root – Python service for tennis predictions.
- Configuration and build scripts: pubspec.yaml, firebase.json, build.gradle, CMakeLists.txt, etc.

##### README for additional insights
- Tech stack: Flutter, Firebase Auth, Cubit (BLoC variant), external Weather API, Python ML service.
- Features: authentication flows, splash screen, dynamic UI, location services, get-prediction.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Flutter Client Layers
    subgraph "Flutter Client"
        direction TB
        subgraph "Core Services"
            direction TB
            ApiService["api_service.dart"]:::core
            ServiceLocator["service_locator.dart"]:::core
            Validators["validators.dart"]:::core
            DioErrors["dio_errors.dart"]:::core
            FirebaseErrors["firebase_errors.dart"]:::core
        end
        subgraph "Presentation Layer"
            direction TB
            LoginView["login_view.dart"]:::presentation
            RegisterView["register_view.dart"]:::presentation
            AuthCubit["auth_cubit.dart"]:::presentation
            AuthState["auth_state.dart"]:::presentation
            HomeView["home_view.dart"]:::presentation
            GetLocationView["get_location_view.dart"]:::presentation
            WeatherDataCubit["weather_data_cubit.dart"]:::presentation
            GetLocationCubit["get_location_cubit.dart"]:::presentation
        end
        subgraph "Domain Layer"
            direction TB
            LoginUseCase["login_user_use_case.dart"]:::domain
            SignUpUseCase["sign_up_user_use_case.dart"]:::domain
            UserEntity["user_entity.dart"]:::domain
            GetWeatherUseCase["get_weather_data_use_case.dart"]:::domain
            GetPredictionUseCase["get_tennis_prediction_use_case.dart"]:::domain
            WeatherEntity["weather_entity.dart"]:::domain
        end
        subgraph "Data Layer"
            direction TB
            AuthRemoteDS["remote_data_source.dart"]:::data
            AuthRepoImpl["auth_user_repo_impl.dart"]:::data
            HomeRemoteDS["remote_data_source.dart"]:::data
            WeatherRepoImpl["weather_repo_impl.dart"]:::data
            AuthUserModel["auth_user_model.dart"]:::data
            WeatherModel["weather_model.dart"]:::data
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FirebaseAuth["Firebase Auth"]:::external
        WeatherAPI["Weather API"]:::external
    end

    %% Python ML Service
    subgraph "Python ML Service"
        direction TB
        FlaskApp["app.py"]:::backend
        RFModel["random_forest_model.pkl"]:::backend
    end

    %% Flow
    LoginView -->|"triggers"| AuthCubit
    RegisterView -->|"triggers"| AuthCubit
    HomeView -->|"triggers"| WeatherDataCubit
    GetLocationView -->|"triggers"| GetLocationCubit

    AuthCubit -->|"calls"| LoginUseCase
    AuthCubit -->|"calls"| SignUpUseCase
    WeatherDataCubit -->|"calls"| GetWeatherUseCase
    GetLocationCubit -->|"calls"| GetPredictionUseCase

    LoginUseCase -->|"uses"| AuthRepoImpl
    SignUpUseCase -->|"uses"| AuthRepoImpl
    GetWeatherUseCase -->|"uses"| WeatherRepoImpl
    GetPredictionUseCase -->|"uses"| WeatherRepoImpl

    AuthRepoImpl -->|"fetch via"| AuthRemoteDS
    WeatherRepoImpl -->|"fetch via"| HomeRemoteDS

    AuthRemoteDS -->|"calls API"| ApiService
    HomeRemoteDS -->|"calls API"| ApiService

    ApiService -->|"POST /login, /signup"| FirebaseAuth
    ApiService -->|"GET /forecast"| WeatherAPI
    ApiService -->|"POST /predict"| FlaskApp

    FlaskApp -->|"loads model"| RFModel

    FirebaseAuth -->|"response"| ApiService
    WeatherAPI -->|"response"| ApiService
    FlaskApp -->|"response"| ApiService

    ApiService -->|"data"| AuthRemoteDS
    ApiService -->|"data"| HomeRemoteDS

    AuthRemoteDS -->|"data"| AuthRepoImpl
    HomeRemoteDS -->|"data"| WeatherRepoImpl

    AuthRepoImpl -->|"entity"| LoginUseCase
    WeatherRepoImpl -->|"entity"| GetWeatherUseCase

    LoginUseCase -->|"state"| AuthCubit
    GetWeatherUseCase -->|"state"| WeatherDataCubit

    AuthCubit -->|"update UI"| LoginView
    WeatherDataCubit -->|"update UI"| HomeView

    %% Click Events
    click ApiService "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/core/network/api_service.dart"
    click ServiceLocator "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/core/utils/service_locator.dart"
    click Validators "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/core/utils/validators.dart"
    click DioErrors "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/core/errors/dio_errors.dart"
    click FirebaseErrors "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/core/errors/firebase_errors.dart"
    click LoginView "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/presentation/views/login_view.dart"
    click RegisterView "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/presentation/views/register_view.dart"
    click AuthCubit "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/presentation/controllers/cubit/auth_cubit.dart"
    click AuthState "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/presentation/controllers/cubit/auth_state.dart"
    click HomeView "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/presentation/views/home_view.dart"
    click GetLocationView "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/presentation/views/get_location_view.dart"
    click WeatherDataCubit "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/presentation/controllers/get_weather_data_cubit/weather_data_cubit.dart"
    click GetLocationCubit "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/presentation/controllers/get_location_cubit/get_location_cubit.dart"
    click LoginUseCase "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/domain/usecases/login_user_use_case.dart"
    click SignUpUseCase "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/domain/usecases/sign_up_user_use_case.dart"
    click UserEntity "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/domain/entities/user_entity.dart"
    click GetWeatherUseCase "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/domain/use_cases/get_weather_data_use_case.dart"
    click GetPredictionUseCase "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/domain/use_cases/get_tennis_prediction_use_case.dart"
    click WeatherEntity "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/domain/entities/weather_entity.dart"
    click AuthRemoteDS "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/data/sources/remote_data_source.dart"
    click AuthRepoImpl "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/data/repos/auth_user_repo_impl.dart"
    click HomeRemoteDS "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/data/sources/remote_data_source.dart"
    click WeatherRepoImpl "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/data/repos/weather_repo_impl.dart"
    click AuthUserModel "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/auth/data/models/auth_user_model.dart"
    click WeatherModel "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/lib/features/home/data/models/weather_model/weather_model.dart"
    click FlaskApp "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/app.py"
    click RFModel "https://github.com/mahmoud-azmy/ai-weather-app/blob/master/random_forest_model.pkl"

    %% Styles
    classDef core fill:#D0E8FF,stroke:#02457A,color:#02457A;
    classDef presentation fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef domain fill:#FFF3E0,stroke:#E65100,color:#E65100;
    classDef data fill:#F1F8E9,stroke:#33691E,color:#33691E;
    classDef external fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32;
    classDef backend fill:#FFF8E1,stroke:#F57F17,color:#F57F17;
```
