# openconsultinggroup/taxi-app architecture

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

- Interactive diagram: https://gitdiagram.com/openconsultinggroup/taxi-app
- Repository: https://github.com/openconsultinggroup/taxi-app

## Overview

##### Project type and purpose
- This is a full-stack (mobile) application built with Flutter. It targets Android and iOS, and implements state management using the BLoC pattern.
- Purpose: a taxi-booking UI prototype that shows map markers, animations, polylines, and simulates booking flow while managing state centrally.

##### File structure
- Top-level mobile platforms:
- android/ – Gradle scripts, AndroidManifest, Kotlin MainActivity, Firebase config
- ios/ – Xcode project, Swift AppDelegate, CocoaPods, iOS asset catalogs
- Core Flutter code under lib/:
- main.dart – entry point
- screens/ – UI pages
- widgets/ – reusable UI components
- bloc/ – BLoC classes (events, states, bloc)
- controllers/ – application logic (wrap BLoC or handle side effects)
- models/ – data structures (taxi, user, booking, etc.)
- storage/ – local persistence (e.g., taxi_booking_storage.dart)
- pubspec.yaml lists dependencies: google_maps_flutter, flutter_bloc, bloc, equatable, shimmer, location.

##### Key architecture insights from README
- Uses BLoC for state management (“central place” for data and events).
- Integrates with Google Maps API and location plugin.
- Encourages separation of concerns: UI only displays, BLoC handles events & state, controllers handle business logic.

##### Main components
a. Frontend/UI Layer
– Flutter Screens (home_screen.dart)
– Widgets (map view, booking flow, animations)
b. State Management Layer
– BLoCs (taxi_booking_bloc)
– Events & States
c. Controllers / Services Layer
– location_controller
– taxi_controller
– payment_method_controller
– taxi_booking_controller
– user_controller
– user_location_controller
d. Data Layer
– Models (Taxi, Booking, User, Location, PaymentMethod)
– Storage (taxi_booking_storage) – local persistence (SharedPreferences or file)
e. Platform / Integration Layer
– Google Maps SDK (google_maps_flutter)
– Location plugin (location)
– Firebase (analytics/auth if added later)
f. Mobile OS Hosts
– Android (MainActivity → FlutterEngine)
– iOS (AppDelegate → FlutterEngine)
g. External Services
– Google Maps APIs
– (Potential) Firebase Cloud services

##### Relationships & interactions
- User taps UI → UI widget dispatches BLoC event → BLoC processes via controllers → may read/write storage or call platform plugins → updates BLoC state → UI rebuilds.
- LocationController uses location plugin → provides current coords → BLoC feeds to UI map.
- TaxiController / BookingController simulates booking logic, updates Models, persists via Storage.
- Widgets subscribe to BLoC state streams to render map markers, polylines, animations.

##### Architectural patterns & design principles
- BLoC pattern: clear separation of UI (presentation) and business logic.
- MVC-like layering: UI → BLoC/controllers → data/storage → external services.
- Dependency injection (via context.read<Bloc>()) ensures testability.
- Single Responsibility: each controller handles its domain, each model is an immutable data carrier (Equatable).

##### Checklist before you finalize
- Every component from the file tree is represented or logically grouped.
- All data flows (UI ↔ BLoC ↔ Controller ↔ Storage/Plugin) are shown.
- External dependencies (google_maps_flutter, location) are distinct.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile OS Hosts"
        Android["Android\nMainActivity"]:::os
        iOS["iOS\nAppDelegate"]:::os
    end

    FlutterEngine["Flutter Engine"]:::platform

    Android -->|launch| FlutterEngine
    iOS -->|launch| FlutterEngine
    FlutterEngine -->|runs| FlutterApp

    subgraph "Flutter App"
        subgraph "Presentation Layer"
            HomeScreen["Home Screen"]:::frontend
            LocationMap["Map View"]:::frontend
            TaxiMap["Taxi Map"]:::frontend
            DestSelect["Destination Selection"]:::frontend
            BookingHome["Booking Home"]:::frontend
            BookingList["Taxis List"]:::frontend
            BookingPayments["Booking Payments"]:::frontend
            BookingState["Booking State"]:::frontend
            ConfirmedDialog["Confirmed Dialog"]:::frontend
            NotConfirmed["Not Confirmed"]:::frontend
            Cancellation["Cancellation Dialog"]:::frontend
            BookingDetails["Booking Details"]:::frontend
            AppBar["App Bar"]:::frontend
            Drawer["Drawer"]:::frontend
            RoundedBtn["Rounded Button"]:::frontend
            Shimmer["Shimmer Loading"]:::frontend
            DashedLine["Dashed Line"]:::frontend
            EaseIn["Ease-In Animation"]:::frontend
        end

        subgraph "BLoC Layer"
            TaxiBookingBloc["TaxiBookingBloc"]:::logic
        end

        subgraph "Controllers Layer"
            LocationController["LocationController"]:::logic
            UserLocationController["UserLocationController"]:::logic
            TaxiController["TaxiController"]:::logic
            TaxiBookingController["TaxiBookingController"]:::logic
            PaymentMethodController["PaymentMethodController"]:::logic
            UserController["UserController"]:::logic
        end

        subgraph "Data Layer"
            Models["Models\n(GoogleLocation, UserLocation,\nUser, Taxi, TaxiDriver,\nTaxiType, PaymentMethod, TaxiBooking)"]:::data
            Storage["TaxiBookingStorage"]:::data
        end

        subgraph "Platform Plugins"
            MapsSDK["Google Maps SDK"]:::platform
            LocationPlugin["Location Plugin"]:::platform
        end
    end

    subgraph "External Services"
        GoogleMapsAPI["Google Maps API"]:::external
    end

    %% Flows
    HomeScreen -->|dispatches| TaxiBookingBloc
    LocationMap -->|dispatches| TaxiBookingBloc
    TaxiBookingBloc -->|stateStream| HomeScreen
    TaxiBookingBloc -->|calls| LocationController
    TaxiBookingBloc -->|calls| TaxiController
    TaxiBookingBloc -->|calls| TaxiBookingController
    TaxiBookingBloc -->|calls| PaymentMethodController
    TaxiBookingBloc -->|calls| UserController
    LocationController -->|uses| LocationPlugin
    LocationController -->|provides coords| TaxiBookingBloc
    UserLocationController -->|provides user loc| TaxiBookingBloc
    TaxiController -->|manages taxi data| Models
    TaxiBookingController -->|persists booking| Storage
    TaxiBookingController -->|reads booking| Storage
    PaymentMethodController -->|manages payments| Models
    UserController -->|manages users| Models
    MapsSDK -->|renders map| LocationMap
    MapsSDK -->|renders map| TaxiMap
    LocationPlugin -->|fetches location| GoogleMapsAPI

    %% Hosts to App
    FlutterEngine --> FlutterApp

    %% Click Events
    click HomeScreen "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/screens/home_screen.dart"
    click LocationMap "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/location_map.dart"
    click TaxiMap "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/taxi_map.dart"
    click DestSelect "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/destination_selection_widget.dart"
    click BookingHome "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/taxi_booking_home_widget.dart"
    click BookingList "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/taxi_booking_taxis_widget.dart"
    click BookingPayments "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/taxi_booking_payments_widget.dart"
    click BookingState "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/taxi_booking_state_widget.dart"
    click ConfirmedDialog "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/taxi_booking_confirmed_widget.dart"
    click NotConfirmed "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/taxi_booking_not_confirmed_widget.dart"
    click Cancellation "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/taxi_booking_cancellation_dialog.dart"
    click BookingDetails "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/taxi_booking_details_widget.dart"
    click AppBar "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/home_app_bar.dart"
    click Drawer "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/home_drawer.dart"
    click RoundedBtn "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/rounded_button.dart"
    click Shimmer "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/loading_shimmer.dart"
    click DashedLine "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/dashed_line.dart"
    click EaseIn "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/widgets/ease_in_widget.dart"
    click TaxiBookingBloc "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/bloc/taxi_booking_bloc.dart"
    click LocationController "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/controllers/location_controller.dart"
    click UserLocationController "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/controllers/user_location_controller.dart"
    click TaxiController "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/controllers/taxi_controller.dart"
    click TaxiBookingController "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/controllers/taxi_booking_controller.dart"
    click PaymentMethodController "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/controllers/payment_method_controller.dart"
    click UserController "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/controllers/user_controller.dart"
    click Models "https://github.com/openconsultinggroup/taxi-app/tree/master/lib/models"
    click Storage "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/storage/taxi_booking_storage.dart"
    click MapsSDK "https://github.com/openconsultinggroup/taxi-app/blob/master/pubspec.yaml"
    click LocationPlugin "https://github.com/openconsultinggroup/taxi-app/blob/master/pubspec.yaml"
    click FlutterEngine "https://github.com/openconsultinggroup/taxi-app/blob/master/lib/main.dart"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef logic fill:#87CEFA,stroke:#000,stroke-width:1px
    classDef data fill:#90EE90,stroke:#000,stroke-width:1px
    classDef platform fill:#FFA07A,stroke:#000,stroke-width:1px
    classDef os fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef external fill:#FFD700,stroke:#000,stroke-width:1px
```
