# rvish-glitch/smart_trip_planner architecture

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

- Interactive diagram: https://gitdiagram.com/rvish-glitch/smart_trip_planner
- Repository: https://github.com/rvish-glitch/smart_trip_planner

## Overview

##### Project type and purpose
- This is a cross-platform Flutter application (“Smart Trip Planner”) for conversational, AI-powered travel itinerary generation.
- It uses Google Gemini AI for NLP and itinerary creation, Isar for local persistence, and integrates Google Maps for geospatial visualization.

##### File structure
- Top-level directories for each platform (android, ios, linux, macos, windows, web) contain the native runners and configuration.
- The core Flutter code lives under lib/:
- core/utils & core/services – shared utilities and foundational services (e.g., reading API key from .env)
- data/datasources – REST/HTTP clients for Google Gemini AI (gemini_api.dart / gemini_api_fixed.dart)
- data/models – data objects (Itinerary, generated code)
- data/repositories – abstraction over local (Isar, SharedPreferences) and remote sources
- presentation/screens & widgets – UI pages (chat, memory, trip editor, token manager) and reusable UI components
- presentation/services – view-model-like services managing state and bridging UI to data layer
- Configuration/build scripts: pubspec.yaml, Android Gradle scripts, iOS Xcode projects, CMakeLists for desktop.

##### README for additional insights
- Confirms Clean Architecture: separation into core, data, presentation layers.
- Specifies repository pattern, dependency injection, and use cases (CRUD itinerary, chat messaging, map visualization).
- Shows high-level tech stack (Flutter, Dart, Gemini AI, Isar).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Platform Runners
    subgraph "Platform Runners"
        Android["Android"]:::external
        iOS["iOS"]:::external
        Linux["Linux"]:::external
        macOS["macOS"]:::external
        Windows["Windows"]:::external
        Web["Web"]:::external
    end

    %% Application Startup
    AppStartup["App Startup (main.dart)"]:::core

    %% Core Utilities
    APIKeyUtil["API Key Loader"]:::core

    %% Presentation Layer
    subgraph "Presentation Layer"
        ChatScreen["ChatScreen"]:::presentation
        MemoryScreen["MemoryScreen"]:::presentation
        TokenManagerScreen["TokenManagerScreen"]:::presentation
        TripEditScreen["TripEditScreen"]:::presentation
        TripEditScreen1["TripEditScreen_Alt"]:::presentation
    end

    %% Presentation Services
    subgraph "Presentation Services"
        TokenManagerService["TokenManagerService"]:::business
    end

    %% Business Logic Services
    subgraph "Business Logic"
        SharedTokenManager["TokenManager (shared)"]:::business
    end

    %% Data Layer
    subgraph "Repositories"
        IsarRepo["IsarRepository"]:::data
        SharedPrefsRepo["SharedPrefsRepository"]:::data
    end

    subgraph "Data Sources"
        GeminiAPI["GeminiApiDataSource"]:::data
        GeminiAPIFix["GeminiApiFixedDataSource"]:::data
    end

    subgraph "Models"
        ItineraryModel["Itinerary Model"]:::data
        ItineraryAdapter["Itinerary Adapter"]:::data
    end

    %% External Services
    subgraph "External Services"
        GeminiAI["Google Gemini AI"]:::external
        GoogleMaps["Google Maps API"]:::external
    end

    %% Local Storage
    subgraph "Local Storage"
        IsarDB["Isar DB"]:::storage
        SharedPrefs["SharedPreferences"]:::storage
        JSONFiles["JSON File Storage"]:::storage
    end

    %% Connections
    Android --> AppStartup
    iOS --> AppStartup
    Linux --> AppStartup
    macOS --> AppStartup
    Windows --> AppStartup
    Web --> AppStartup

    AppStartup --> APIKeyUtil
    APIKeyUtil --> GeminiAPI
    APIKeyUtil --> GeminiAPIFix

    AppStartup --> ChatScreen
    AppStartup --> MemoryScreen
    AppStartup --> TokenManagerScreen
    AppStartup --> TripEditScreen
    AppStartup --> TripEditScreen1

    ChatScreen --> TokenManagerService
    MemoryScreen --> TokenManagerService
    TokenManagerScreen --> TokenManagerService
    TripEditScreen --> TokenManagerService
    TripEditScreen1 --> TokenManagerService

    TokenManagerService --> SharedTokenManager
    SharedTokenManager --> IsarRepo
    SharedTokenManager --> SharedPrefsRepo

    IsarRepo --> GeminiAPI
    IsarRepo --> IsarDB
    SharedPrefsRepo --> GeminiAPI
    SharedPrefsRepo --> SharedPrefs

    GeminiAPI --> GeminiAI
    GeminiAPIFix --> GeminiAI
    TripEditScreen --> GoogleMaps
    TripEditScreen1 --> GoogleMaps

    IsarRepo --> ItineraryModel
    ItineraryModel --> ItineraryAdapter
    SharedPrefsRepo --> ItineraryModel

    %% Click Events
    click ChatScreen "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/presentation/screens/chat_screen.dart"
    click MemoryScreen "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/presentation/screens/memory_screen.dart"
    click TokenManagerScreen "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/presentation/screens/token_manager_screen.dart"
    click TripEditScreen "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/presentation/screens/trip_edit_screen.dart"
    click TripEditScreen1 "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/presentation/screens/trip_edit_screen_1.dart"
    click TokenManagerService "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/presentation/services/token_manager.dart"
    click SharedTokenManager "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/services/token_manager.dart"
    click GeminiAPI "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/data/datasources/gemini_api.dart"
    click GeminiAPIFix "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/data/datasources/gemini_api_fixed.dart"
    click ItineraryModel "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/data/models/itinerary.dart"
    click ItineraryAdapter "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/data/models/itinerary.g.dart"
    click IsarRepo "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/data/repositories/isar_repository.dart"
    click SharedPrefsRepo "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/data/repositories/shared_prefs_repository.dart"
    click APIKeyUtil "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/core/utils/api_key_util.dart"
    click AppStartup "https://github.com/rvish-glitch/smart_trip_planner/blob/main/lib/main.dart"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef business fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFD580,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef storage fill:#DEB887,stroke:#333,stroke-width:1px
    classDef core fill:#E6E6FA,stroke:#333,stroke-width:1px
```
