# igordodukh/trudor architecture

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

- Interactive diagram: https://gitdiagram.com/igordodukh/trudor
- Repository: https://github.com/igordodukh/trudor

## Overview

Based on our analysis of the file tree and README, the Spoto App is a Flutter-based mobile application that follows a modular and layered (or “clean”) architectural pattern. It targets both Android and iOS platforms and integrates with third‐party services like Firestore for storage (images, user info, product details) and Typesense for search/indexing.

##### Main Components
- Mobile Frontend: Representing the Flutter UI spread across the lib/presentation directory (including views, widgets, and BloCs for state management).
- Business Logic / Domain Layer: Captured in lib/domain; this contains the domain entities, usecases, and repository interfaces that define business rules.
- Data Layer: Found primarily under lib/data, organized into models, data sources (both remote and local), and repository implementations. This layer handles fetching/storing data from Firestore, Typesense, and local storage.
- Core Helpers & Utilities: Under lib/core, including constants, network utilities, theme configuration, routing, and dependency injection (services_locator).
- Mobile Platform Specifics: Native folders for Android and iOS which manage platform-specific configurations, build files, and integration scaffolding.
- External Integrations: Firestore (as the primary backend data store) and Typesense (for search and automatic mirroring of data).
- Testing: Comprehensive testing directories (test/) covering unit tests for core functionalities, data sources, repositories, and business logic.

##### Relationships and Interactions
- Presentation Layer -> Domain Layer: UI components (views, BloCs/Cubits) trigger usecases defined in the domain layer.
- Domain Layer -> Data Layer: Usecases interact with repository interfaces whose implementations reside in the data layer. This abstraction ensures separation of concerns.
- Core and Utilities: Common support functions, like networking, theming, routing, and dependency lookup, which are used across the app.

##### Architectural Patterns and Design Principles
- Clean Architecture: Clearly separate the project into presentation, domain, and data layers.
- Dependency Injection: Via the services_locator in lib/core/services to facilitate decoupling.
- BLoC State Management: Use BloCs (within lib/presentation/blocs) to manage the app’s state, promoting a reactive design.
- Platform Abstraction: Android and iOS directories encapsulate platform-specific configuration, keeping Flutter code platform-independent.

##### Relevant Technology Stacks & Frameworks
- Flutter for the cross-platform UI.
- BloC/Cubit for state management.
- Firestore as the backend cloud database.
- Typesense for advanced search and indexing.
- Gradle & Xcode for Android and iOS native builds respectively.
- The various directories in lib/core, lib/domain, and lib/data illustrate adherence to clean architecture principles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        A["Flutter UI & BloCs (lib/presentation)"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        B["Business Logic / Domain Usecases (lib/domain)"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        C["Data Repositories & Data Sources (lib/data)"]:::data
    end

    %% Core Utilities
    subgraph "Core Utilities"
        D["Core Helpers & Utilities (lib/core)"]:::core
        E["Dependency Injection (services_locator)"]:::core
        D --> E
    end

    %% External Services
    subgraph "External Services"
        F["Firestore (Cloud Data)"]:::external
        G["Typesense (Search Service)"]:::external
    end

    %% Mobile Platform Specifics
    subgraph "Mobile Platform Specifics"
        H["Android Native (android)"]:::platform
        I["iOS Native (ios)"]:::platform
    end

    %% Testing Suite
    subgraph "Testing Suite"
        J["Testing Suite (test)"]:::testing
    end

    %% Connections between layers and components
    A -->|"triggers"| B
    B -->|"calls"| C
    C -->|"fetch/store"| F
    C -->|"syncs"| G
    F -->|"mirrors"| G

    %% Core supports all internal layers
    D ---|"supports"| A
    D ---|"supports"| B
    D ---|"supports"| C
    E ---|"injects"| A
    E ---|"injects"| B
    E ---|"injects"| C

    %% Mobile platform dependencies
    A -->|"runsOn"| H
    A -->|"runsOn"| I

    %% Testing relations
    J ---|"tests"| A
    J ---|"tests"| B
    J ---|"tests"| C
    J ---|"tests"| D
    J ---|"tests"| E

    %% Click Events
    click A "https://github.com/igordodukh/trudor/tree/main/lib/presentation"
    click B "https://github.com/igordodukh/trudor/tree/main/lib/domain"
    click C "https://github.com/igordodukh/trudor/tree/main/lib/data"
    click D "https://github.com/igordodukh/trudor/tree/main/lib/core"
    click E "https://github.com/igordodukh/trudor/blob/main/lib/core/services/services_locator.dart"
    click F "https://github.com/igordodukh/trudor/tree/main/lib/core/util/firestore"
    click G "https://github.com/igordodukh/trudor/tree/main/lib/core/util/typesense"
    click H "https://github.com/igordodukh/trudor/tree/main/android"
    click I "https://github.com/igordodukh/trudor/tree/main/ios"
    click J "https://github.com/igordodukh/trudor/tree/main/test"

    %% Styles
    classDef presentation fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef domain fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef data fill:#FFCCBC,stroke:#BF360C,stroke-width:2px;
    classDef core fill:#D1C4E9,stroke:#4A148C,stroke-width:2px;
    classDef external fill:#FFE082,stroke:#FF6F00,stroke-width:2px,stroke-dasharray: 5, 5;
    classDef platform fill:#B2EBF2,stroke:#006064,stroke-width:2px;
    classDef testing fill:#F8BBD0,stroke:#880E4F,stroke-width:2px;
```
