# gotolstoy/tolstoy-flutter-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/gotolstoy/tolstoy-flutter-sdk
- Repository: https://github.com/gotolstoy/tolstoy-flutter-sdk

## Overview

**┌─ Presentation Layer ─────┐**
- (Widgets & Screens)      │
- Business Logic Layer ───┤
- (Services & Models)      │
- Core Layer ────────────┤
- (Configuration & Types)  │
- Utils Layer ───────────┘

##### Module Organization

**Feed Module │ Rail Module │ Assets Module │ Products Module │ API Module**

##### Component Details

For each module, show the following hierarchy:
- Widgets/Screens (Top)
- Services (Middle)
- Models (Bottom)

Key components to highlight:

a) Feed Module (Purple):
- FeedScreen & FeedView
- Feed-related widgets (FeedAsset, FeedOverlay)
- Product integration components

b) Rail Module (Blue):
- Rail & RailWithFeed widgets
- RailOptions configuration
- Rail-specific services

c) Assets Module (Green):
- Asset handling services (Image, Video)
- Asset models and types
- Asset widgets hierarchy

d) Products Module (Orange):
- Product models
- Product loaders (Batch, Simple)
- Product utilities

e) API Module (Red):
- TvConfigProvider
- API services
- Configuration models

- Configuration flow from API to modules
- Asset loading paths
- Product data distribution
- Widget composition relationships

##### Integration Points

External integration points:
- Analytics module connections
- API endpoints
- Asset service connections

**🔷 Widget Component**
**🔶 Service Component**
**⬡ Model**
**↔️ Two-way Data Flow**
**→ One-way Data Flow**

##### How the TvConfigProvider acts as a central configuration source.

3. Relationship between Feed and Rail components, as they can work independently or together.

##### Products module's integration with the feed display system.

Level of Detail:

- Keep high-level components visible at first glance
- Use expandable/collapsible sections for detailed implementation
- Maintain clear boundaries between modules while showing their interactions
- Configuration and type definitions without overwhelming detail

- Nested components
- Grouping of related elements

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef presentation fill:#e1bee7,stroke:#000
    classDef business fill:#bbdefb,stroke:#000
    classDef core fill:#c8e6c9,stroke:#000
    classDef utils fill:#ffe0b2,stroke:#000
    classDef api fill:#ffcdd2,stroke:#000
    classDef feed fill:#d1c4e9,stroke:#000
    classDef rail fill:#b3e5fc,stroke:#000
    classDef assets fill:#a5d6a7,stroke:#000
    classDef products fill:#ffcc80,stroke:#000

    %% Core Layer
    subgraph CoreLayer["Core Layer"]
        Config["Configuration"]:::core
        Types["Types"]:::core
    end
    click Config "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/core/config.dart"
    click Types "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/core/types.dart"

    %% Utils Layer
    subgraph UtilsLayer["Utils Layer"]
        JsonParser["JSON Parser"]:::utils
        DebugPrint["Debug Print"]:::utils
        DelayedDisplay["Delayed Display"]:::utils
    end
    click JsonParser "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/utils/json_parser.dart"
    click DebugPrint "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/utils/debug_print.dart"
    click DelayedDisplay "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/utils/components/delayed_display.dart"

    %% API Module
    subgraph APIModule["API Module"]
        TvConfigProvider["TV Config Provider"]:::api
        PreloadedTvConfigProvider["Preloaded TV Config Provider"]:::api
        APIServices["API Services"]:::api
        TvPageConfig["TV Page Config"]:::api
    end
    click TvConfigProvider "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/api/widgets/tv_config_provider.dart"
    click PreloadedTvConfigProvider "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/api/widgets/preloaded_tv_config_provider.dart"
    click APIServices "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/api/services/api.dart"
    click TvPageConfig "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/api/models/tv_page_config.dart"

    %% Feed Module
    subgraph FeedModule["Feed Module"]
        FeedScreen["Feed Screen"]:::feed
        FeedView["Feed View"]:::feed
        FeedAsset["Feed Asset"]:::feed
        FeedProductList["Feed Product List"]:::feed
    end
    click FeedModule "https://github.com/GoTolstoy/tolstoy-flutter-sdk/tree/master/lib/modules/feed/"
    click FeedScreen "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/feed/screens/feed_screen.dart"
    click FeedView "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/feed/widgets/feed_view.dart"
    click FeedAsset "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/feed/widgets/feed_asset.dart"
    click FeedProductList "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/feed/widgets/feed_product_list.dart"

    %% Rail Module
    subgraph RailModule["Rail Module"]
        Rail["Rail"]:::rail
        RailWithFeed["Rail With Feed"]:::rail
        RailOptions["Rail Options"]:::rail
    end
    click RailModule "https://github.com/GoTolstoy/tolstoy-flutter-sdk/tree/master/lib/modules/rail/"
    click Rail "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/rail/widgets/rail.dart"
    click RailWithFeed "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/rail/widgets/rail_with_feed.dart"
    click RailOptions "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/rail/models/rail_options.dart"

    %% Assets Module
    subgraph AssetsModule["Assets Module"]
        AssetService["Asset Service"]:::assets
        ImageService["Image Service"]:::assets
        VideoService["Video Service"]:::assets
        AssetModel["Asset Model"]:::assets
        AssetWidgets["Asset Widgets"]:::assets
    end
    click AssetsModule "https://github.com/GoTolstoy/tolstoy-flutter-sdk/tree/master/lib/modules/assets/"
    click AssetService "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/assets/services/asset_service.dart"
    click ImageService "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/assets/services/image_service.dart"
    click VideoService "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/assets/services/video_service.dart"
    click AssetModel "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/assets/models/asset.dart"
    click AssetWidgets "https://github.com/GoTolstoy/tolstoy-flutter-sdk/tree/master/lib/modules/assets/widgets/assets/"

    %% Products Module
    subgraph ProductsModule["Products Module"]
        ProductModel["Product Model"]:::products
        BatchLoader["Batch Products Loader"]:::products
        SimpleLoader["Simple Products Loader"]:::products
        ProductUtils["Product Utils"]:::products
    end
    click ProductsModule "https://github.com/GoTolstoy/tolstoy-flutter-sdk/tree/master/lib/modules/products/"
    click ProductModel "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/products/models/product.dart"
    click BatchLoader "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/products/loaders/batch_products_loader.dart"
    click SimpleLoader "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/products/loaders/simple_products_loader.dart"
    click ProductUtils "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/products/services/product_utils.dart"

    %% Analytics
    Analytics["Analytics"]:::business
    click Analytics "https://github.com/GoTolstoy/tolstoy-flutter-sdk/blob/master/lib/modules/analytics/analytics.dart"

    %% Relationships
    TvConfigProvider --> Config
    TvConfigProvider --> FeedModule
    TvConfigProvider --> RailModule
    
    FeedModule --> AssetsModule
    FeedModule --> ProductsModule
    FeedModule --> Analytics
    
    RailModule --> AssetsModule
    RailModule --> Analytics
    
    AssetsModule --> APIModule
    ProductsModule --> APIModule
    
    APIModule --> JsonParser
    APIModule --> DebugPrint
    
    %% Legend
    subgraph Legend
        L1["🔷 Widget Component"]
        L2["🔶 Service Component"]
        L3["⬡ Model"]
        L4["↔️ Two-way Data Flow"]
        L5["→ One-way Data Flow"]
    end
```
