How aditya290605/smart_trip_planner_flutter works
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: init_dependencies.dart init deps · itinerary_bloc.dart Itinerary BLoC · auth_bloc_bloc.dart Auth BLoC · auth_wraper.dart Auth wrapper
Components 23
Platform shells
Android, iOS, and web host the Flutter runtime and platform configs.
- Android shell · Native Android wrapper and Firebase config.
smart_trip_planner/android - iOS shell · Native iOS wrapper and launch scaffolding.
smart_trip_planner/ios - Web shell · Web hosting assets and manifest.
smart_trip_planner/web
Bootstrap
App entry and dependency wiring.
- main.dart · Flutter app entry that starts composition and rendering.
smart_trip_planner/lib/main.dart - init deps · Dependency injection and app startup initialization.
smart_trip_planner/lib/init_dependencies.dart - init deps main · 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 · Material theme and color palette shared across screens.
smart_trip_planner/lib/core/theme/app_theme.dart - Errors · Shared exception and error definitions.
smart_trip_planner/lib/core/errors/errors.dart - User profile · Common user identity/profile entity.
smart_trip_planner/lib/core/entities/user_profile.dart - Prompt builder · Builds structured Gemini prompts from trip inputs.
smart_trip_planner/lib/core/utils/prompt_builder.dart - User state · Shared user-data cubit used across the app.
smart_trip_planner/lib/core/common/user/cubit/user_data_cubit.dart - Auth wrapper · 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 · Handles sign-in and sign-up state transitions.
smart_trip_planner/lib/features/auth/presentation/bloc/auth_bloc_bloc.dart - Auth screens · Login and sign-up pages plus form widgets.
smart_trip_planner/lib/features/auth/presentation/pages/login_page.dart - Auth use cases · Sign-in and sign-up application actions.
smart_trip_planner/lib/features/auth/domain/usercase/sign_in_usecase.dart - Auth repo · Auth domain contract and repository implementation.
smart_trip_planner/lib/features/auth/domain/repository/auth_repository.dart - Auth source · 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 · Coordinates itinerary generation and loading states.
smart_trip_planner/lib/features/trip_plan/presentation/bloc/itinerary_bloc.dart - Trip screens · Home, chat, response, offline cache, and profile pages.
smart_trip_planner/lib/features/trip_plan/presentation/pages/home_page.dart - Generate itinerary · Main business action for generating a trip plan.
smart_trip_planner/lib/features/trip_plan/domain/usecases/generate_itinerary_usecase.dart - Trip repo · Trip repository contract and concrete implementation.
smart_trip_planner/lib/features/trip_plan/domain/repository/itinerary_repository.dart - Gemini source · Network integration point for Gemini itinerary generation.
smart_trip_planner/lib/features/trip_plan/data/datasource/trip_remote_datasource.dart - Hive cache · Offline itinerary persistence and serialization.
smart_trip_planner/lib/features/trip_plan/data/model/itinerary_hive_model.dart
Connections 24
- 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.