# aditya290605/smart_trip_planner_flutter architecture

> Architecture diagram of the GitHub repository aditya290605/smart_trip_planner_flutter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aditya290605/smart_trip_planner_flutter
- Repository: https://github.com/aditya290605/smart_trip_planner_flutter

## Overview

1. **High-level shape**
   - This is a **Flutter cross-platform mobile app** (Android, iOS, and web scaffolding exist, but the main product is the Flutter client).
   - The app is organized around **feature-first Clean Architecture** with two major business domains: **authentication** and **trip planning**.

2. **Startup and composition root**
   - `lib/main.dart` is the app entry point.
   - `lib/init_dependencies.dart` and `lib/init_dependencies.main.dart` are the composition/bootstrap layer, wiring up **GetIt** dependency injection and likely initializing services such as Firebase, repositories, and BLoCs before UI rendering.

3. **Shared core layer**
   - `lib/core/` contains app-wide building blocks reused by both features:
     - `constants/` for dummy data and fixed values.
     - `theme/` for Material styling and color palette.
     - `errors/` for shared exception/error types.
     - `entities/` for common domain objects like `UserProfile`.
     - `usecase/` for the base use-case abstraction.
     - `utils/` for prompt building and user-data helpers.
     - `common/` for cross-cutting state and wrappers.

4. **Auth boundary**
   - The auth feature is split into the classic layers:
     - `data/` contains `auth_remote_data_soucre.dart`, `user_model.dart`, and `auth_repository_impl.dart`.
     - `domain/` defines `auth_repository.dart` plus sign-in/sign-up use cases.
     - `presentation/` contains `auth_bloc_bloc.dart`, events, states, and the login/sign-up pages.
   - This feature is the gatekeeper for app access and is wrapped by `core/common/wrappers/auth_wraper.dart`, which likely decides whether to show auth screens or the authenticated app shell.

5. **Trip planning boundary**
   - The main product logic lives in `lib/features/trip_plan/`.
   - `data/datasource/trip_remote_datasource.dart` is the AI/network integration point.
   - `data/repository/repository_impl.dart` is the concrete implementation behind the trip repository interface.
   - `domain/usecases/generate_itinerary_usecase.dart` encapsulates itinerary generation as the main business action.
   - `presentation/bloc/itinerary_bloc.dart` drives the planner UI states.

6. **AI / LLM flow**
   - The app generates itineraries by sending a structured prompt to **Google Gemini**.
   - The prompt-building logic is centralized in `core/utils/prompt_builder.dart`, which suggests the app constructs rich trip requests from user inputs like destination, budget, duration, and preferences.
   - Returned AI output is then transformed into app-specific models/entities before reaching the UI.

7. **Local persistence and offline support**
   - Offline caching is backed by **Hive**.
   - The trip feature includes `itinerary_hive_model.dart` and the generated adapter `itinerary_hive_model.g.dart`, which indicates local serialization of itinerary data.
   - `presentation/pages/offline_saved_page.dart` is the dedicated surface for browsing cached itineraries when network access is unavailable.

8. **State management pattern**
   - The app uses **BLoC/Cubit** for predictable state transitions:
     - Auth uses `auth_bloc_*`.
     - User profile/state uses `core/common/user/cubit/user_data_cubit.dart`.
     - Trip planning uses `itinerary_bloc.dart`.
   - The UI does not call services directly; it emits events, BLoCs invoke use cases, repositories access data sources, and states flow back to the pages.

9. **UI surface and screen flow**
   - The main screens are:
     - `login_page.dart` / `sing_up_page.dart` for authentication.
     - `home_page.dart` as the landing/dashboard screen.
     - `chat_page.dart` and `create_itineary_input.dart` for trip request entry.
     - `response_page.dart` for generated itinerary output.
     - `offline_saved_page.dart` for cached trips.
     - `profile_page.dart` for user details/account state.
   - Reusable widgets under `presentation/widgets/` handle inputs, buttons, loaders, chat bubbles, error cards, and itinerary cards.

10. **External services and runtime dependencies**
   - **Firebase** is configured at the platform level (`android/app/google-services.json`), and the README indicates use of Firebase Auth and cloud storage.
   - **Google Gemini** is the core AI backend for itinerary generation.
   - **Connectivity Plus** and **Speech-to-Text** are part of the described product capabilities, supporting network-aware behavior and voice input.
   - **Hive** provides local persistence for offline mode.

11. **User-data and app-wide state**
   - `core/common/user/` and `core/utils/userdata.dart` suggest a shared user profile/cache layer used across auth and trip planning.
   - `lib/features/auth` and `lib/features/trip_plan` likely both feed into this common user state so the app can keep user context consistent after login and during itinerary generation.

12. **Platform-specific boundaries**
   - Android and iOS directories are standard Flutter host shells, but the architecture is still driven from Dart.
   - Android contains the Firebase config and native launch scaffolding; iOS mirrors this with Runner project files and app metadata.
   - The native layers appear thin, serving mainly as launch/configuration containers rather than business-logic hosts.

13. **Architectural diagram takeaway**
   - The core diagram should show two feature pipelines:
     - **Auth pipeline:** UI → BLoC → use case → repository → Firebase auth source.
     - **Trip pipeline:** UI → BLoC → use case → repository → Gemini remote source, with a parallel write/read path to Hive for offline caching.
   - A shared core band should sit beneath both, providing error handling, theme, prompt construction, user state, and DI/bootstrap services.

Main entry points: [`smart_trip_planner/lib/init_dependencies.dart`](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/init_dependencies.dart) (init deps), [`smart_trip_planner/lib/features/trip_plan/presentation/bloc/itinerary_bloc.dart`](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/presentation/bloc/itinerary_bloc.dart) (Itinerary BLoC), [`smart_trip_planner/lib/features/auth/presentation/bloc/auth_bloc_bloc.dart`](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/presentation/bloc/auth_bloc_bloc.dart) (Auth BLoC), [`smart_trip_planner/lib/core/common/wrappers/auth_wraper.dart`](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/common/wrappers/auth_wraper.dart) (Auth wrapper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform shells"]
  node_android_shell["Android shell<br/>host"]
  node_ios_shell["iOS shell<br/>host"]
  node_web_shell["Web shell<br/>host"]
end

subgraph group_bootstrap["Bootstrap"]
  node_main["main.dart<br/>entrypoint<br/>[main.dart]"]
  node_init_deps["init deps<br/>bootstrap"]
  node_init_deps_main["init deps main<br/>bootstrap"]
end

subgraph group_core["Shared core"]
  node_app_theme["Theme<br/>ui core<br/>[app_theme.dart]"]
  node_app_errors["Errors<br/>error core<br/>[errors.dart]"]
  node_user_profile["User profile<br/>domain core<br/>[user_profile.dart]"]
  node_prompt_builder["Prompt builder<br/>ai core"]
  node_user_state(("User state<br/>state core"))
  node_auth_wrapper["Auth wrapper<br/>shell<br/>[auth_wraper.dart]"]
end

subgraph group_auth["Auth feature"]
  node_auth_bloc(("Auth BLoC"))
  node_auth_ui["Auth screens<br/>ui<br/>[login_page.dart]"]
  node_auth_usecases["Auth use cases"]
  node_auth_repo[("Auth repo")]
  node_auth_remote[("Auth source<br/>firebase auth")]
end

subgraph group_trip["Trip planning"]
  node_trip_bloc(("Itinerary BLoC"))
  node_trip_ui["Trip screens<br/>ui<br/>[home_page.dart]"]
  node_trip_usecase["Generate itinerary<br/>use case"]
  node_trip_repo[("Trip repo")]
  node_trip_remote[("Gemini source<br/>ai remote")]
  node_trip_cache[("Hive cache<br/>local store")]
end

node_main -->|"starts"| node_init_deps
node_init_deps -->|"configures"| node_init_deps_main
node_init_deps -->|"injects"| node_auth_wrapper
node_init_deps -->|"provides"| node_user_state
node_auth_wrapper -->|"shows"| node_auth_bloc
node_auth_wrapper -->|"unlocks"| node_trip_ui
node_auth_ui -->|"events"| node_auth_bloc
node_auth_bloc -->|"calls"| node_auth_usecases
node_auth_usecases -->|"depends on"| node_auth_repo
node_auth_repo -->|"fetches"| node_auth_remote
node_auth_bloc -->|"updates"| node_user_state
node_trip_ui -->|"events"| node_trip_bloc
node_trip_bloc -->|"calls"| node_trip_usecase
node_trip_usecase -->|"depends on"| node_trip_repo
node_trip_repo -->|"generates"| node_trip_remote
node_trip_repo -->|"stores"| node_trip_cache
node_trip_bloc -->|"loads"| node_trip_cache
node_trip_usecase -->|"builds prompt"| node_prompt_builder
node_trip_bloc -->|"reads"| node_user_state
node_auth_ui -->|"styles"| node_app_theme
node_trip_ui -->|"styles"| node_app_theme
node_auth_remote -->|"raises"| node_app_errors
node_trip_remote -->|"raises"| node_app_errors
node_trip_cache -->|"raises"| node_app_errors

click node_main "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/main.dart"
click node_init_deps "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/init_dependencies.dart"
click node_init_deps_main "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/init_dependencies.main.dart"
click node_android_shell "https://github.com/aditya290605/smart_trip_planner_flutter/tree/main/smart_trip_planner/android"
click node_ios_shell "https://github.com/aditya290605/smart_trip_planner_flutter/tree/main/smart_trip_planner/ios"
click node_web_shell "https://github.com/aditya290605/smart_trip_planner_flutter/tree/main/smart_trip_planner/web"
click node_app_theme "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/theme/app_theme.dart"
click node_app_errors "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/errors/errors.dart"
click node_user_profile "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/entities/user_profile.dart"
click node_prompt_builder "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/utils/prompt_builder.dart"
click node_user_state "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/common/user/cubit/user_data_cubit.dart"
click node_auth_wrapper "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/common/wrappers/auth_wraper.dart"
click node_auth_bloc "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/presentation/bloc/auth_bloc_bloc.dart"
click node_auth_ui "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/presentation/pages/login_page.dart"
click node_auth_usecases "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/domain/usercase/sign_in_usecase.dart"
click node_auth_repo "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/domain/repository/auth_repository.dart"
click node_auth_remote "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/data/data_source/auth_remote_data_soucre.dart"
click node_trip_bloc "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/presentation/bloc/itinerary_bloc.dart"
click node_trip_ui "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/presentation/pages/home_page.dart"
click node_trip_usecase "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/domain/usecases/generate_itinerary_usecase.dart"
click node_trip_repo "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/domain/repository/itinerary_repository.dart"
click node_trip_remote "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/data/datasource/trip_remote_datasource.dart"
click node_trip_cache "https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/data/model/itinerary_hive_model.dart"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_android_shell,node_ios_shell,node_web_shell toneBlue
class node_main,node_init_deps,node_init_deps_main toneAmber
class node_app_theme,node_app_errors,node_user_profile,node_prompt_builder,node_user_state,node_auth_wrapper toneMint
class node_auth_bloc,node_auth_ui,node_auth_usecases,node_auth_repo,node_auth_remote toneRose
class node_trip_bloc,node_trip_ui,node_trip_usecase,node_trip_repo,node_trip_remote,node_trip_cache toneIndigo
```

## Components

### Platform shells

Android, iOS, and web host the Flutter runtime and platform configs.

- [Android shell](https://github.com/aditya290605/smart_trip_planner_flutter/tree/main/smart_trip_planner/android): host · Native Android wrapper and Firebase config. · `smart_trip_planner/android`
- [iOS shell](https://github.com/aditya290605/smart_trip_planner_flutter/tree/main/smart_trip_planner/ios): host · Native iOS wrapper and launch scaffolding. · `smart_trip_planner/ios`
- [Web shell](https://github.com/aditya290605/smart_trip_planner_flutter/tree/main/smart_trip_planner/web): host · Web hosting assets and manifest. · `smart_trip_planner/web`

### Bootstrap

App entry and dependency wiring.

- [main.dart](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/main.dart): entrypoint · Flutter app entry that starts composition and rendering. · `smart_trip_planner/lib/main.dart`
- [init deps](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/init_dependencies.dart): bootstrap · Dependency injection and app startup initialization. · `smart_trip_planner/lib/init_dependencies.dart`
- [init deps main](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/init_dependencies.main.dart): bootstrap · Main-specific bootstrap variant for runtime setup. · `smart_trip_planner/lib/init_dependencies.main.dart`

### Shared core

Cross-cutting app-wide primitives reused by both features.

- [Theme](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/theme/app_theme.dart): ui core · Material theme and color palette shared across screens. · `smart_trip_planner/lib/core/theme/app_theme.dart`
- [Errors](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/errors/errors.dart): error core · Shared exception and error definitions. · `smart_trip_planner/lib/core/errors/errors.dart`
- [User profile](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/entities/user_profile.dart): domain core · Common user identity/profile entity. · `smart_trip_planner/lib/core/entities/user_profile.dart`
- [Prompt builder](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/utils/prompt_builder.dart): ai core · Builds structured Gemini prompts from trip inputs. · `smart_trip_planner/lib/core/utils/prompt_builder.dart`
- [User state](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/common/user/cubit/user_data_cubit.dart): state core · Shared user-data cubit used across the app. · `smart_trip_planner/lib/core/common/user/cubit/user_data_cubit.dart`
- [Auth wrapper](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/core/common/wrappers/auth_wraper.dart): shell · Gates the app between auth flow and authenticated shell. · `smart_trip_planner/lib/core/common/wrappers/auth_wraper.dart`

### Auth feature

Authentication pipeline and UI.

- [Auth BLoC](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/presentation/bloc/auth_bloc_bloc.dart): bloc · Handles sign-in and sign-up state transitions. · `smart_trip_planner/lib/features/auth/presentation/bloc/auth_bloc_bloc.dart`
- [Auth screens](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/presentation/pages/login_page.dart): ui · Login and sign-up pages plus form widgets. · `smart_trip_planner/lib/features/auth/presentation/pages/login_page.dart`
- [Auth use cases](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/domain/usercase/sign_in_usecase.dart): use cases · Sign-in and sign-up application actions. · `smart_trip_planner/lib/features/auth/domain/usercase/sign_in_usecase.dart`
- [Auth repo](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/domain/repository/auth_repository.dart): repository · Auth domain contract and repository implementation. · `smart_trip_planner/lib/features/auth/domain/repository/auth_repository.dart`
- [Auth source](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/auth/data/data_source/auth_remote_data_soucre.dart): firebase auth · Remote authentication source backed by Firebase. · `smart_trip_planner/lib/features/auth/data/data_source/auth_remote_data_soucre.dart`

### Trip planning

Itinerary generation, persistence, and UI.

- [Itinerary BLoC](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/presentation/bloc/itinerary_bloc.dart): bloc · Coordinates itinerary generation and loading states. · `smart_trip_planner/lib/features/trip_plan/presentation/bloc/itinerary_bloc.dart`
- [Trip screens](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/presentation/pages/home_page.dart): ui · Home, chat, response, offline cache, and profile pages. · `smart_trip_planner/lib/features/trip_plan/presentation/pages/home_page.dart`
- [Generate itinerary](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/domain/usecases/generate_itinerary_usecase.dart): use case · Main business action for generating a trip plan. · `smart_trip_planner/lib/features/trip_plan/domain/usecases/generate_itinerary_usecase.dart`
- [Trip repo](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/domain/repository/itinerary_repository.dart): repository · Trip repository contract and concrete implementation. · `smart_trip_planner/lib/features/trip_plan/domain/repository/itinerary_repository.dart`
- [Gemini source](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/data/datasource/trip_remote_datasource.dart): ai remote · Network integration point for Gemini itinerary generation. · `smart_trip_planner/lib/features/trip_plan/data/datasource/trip_remote_datasource.dart`
- [Hive cache](https://github.com/aditya290605/smart_trip_planner_flutter/blob/main/smart_trip_planner/lib/features/trip_plan/data/model/itinerary_hive_model.dart): local store · Offline itinerary persistence and serialization. · `smart_trip_planner/lib/features/trip_plan/data/model/itinerary_hive_model.dart`

## Connections

- main.dart → init deps: starts · App entry delegates setup to composition root.
- init deps → init deps main: configures · Startup wiring prepares runtime-specific initialization.
- init deps → Auth wrapper: injects · Dependency graph provides the authenticated app shell.
- init deps → User state: provides · Shared user state is registered at startup.
- Auth wrapper → Auth BLoC: shows · Unauthenticated users are routed into auth state handling.
- Auth wrapper → Trip screens: unlocks · Authenticated users enter the main product shell.
- Auth screens → Auth BLoC: events · Auth screens dispatch login and sign-up actions.
- Auth BLoC → Auth use cases: calls · BLoC invokes sign-in and sign-up actions.
- Auth use cases → Auth repo: depends on · Use cases target the repository abstraction.
- Auth repo → Auth source: fetches · Concrete repository delegates to Firebase auth source.
- Auth BLoC → User state: updates · Successful auth updates shared user context.
- Trip screens → Itinerary BLoC: events · Trip pages send planner and cache actions to BLoC.
- Itinerary BLoC → Generate itinerary: calls · Planner BLoC invokes itinerary generation.
- Generate itinerary → Trip repo: depends on · Use case targets the itinerary repository abstraction.
- Trip repo → Gemini source: generates · Remote source sends structured prompts to Gemini.
- Trip repo → Hive cache: stores · Repository persists generated itineraries for offline use.
- Itinerary BLoC → Hive cache: loads · Offline saved flow reads cached itineraries.
- Generate itinerary → Prompt builder: builds prompt · Prompt construction centralizes trip request formatting.
- Itinerary BLoC → User state: reads · Planner uses shared user context during request flow.
- Auth screens → Theme: styles · Shared styling is applied across auth screens.
- Trip screens → Theme: styles · Shared styling is applied across trip screens.
- Auth source → Errors: raises · Auth failures map into shared error types.
- Gemini source → Errors: raises · AI/network failures map into shared error types.
- Hive cache → Errors: raises · Cache/persistence failures map into shared error types.
