# tpoo1408/jarvis_ai architecture

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

- Interactive diagram: https://gitdiagram.com/tpoo1408/jarvis_ai
- Repository: https://github.com/tpoo1408/jarvis_ai

## Overview

##### Main Components
- Domain Layer: Each module further divides its code into a “domain” directory containing business rules, models, events, and use cases. This clearly demonstrates a clean separation of concerns typical of layered or MVVM/MVC architecture.
- Configuration & Dependency Injection: Files like “locator.dart” and configuration files in “lib/config” indicate that the app employs dependency injection and centralized configuration management.
- External Integrations: There’s integration with Firebase (e.g., “firebase_options.dart”, “firebase.json”), Google Mobile Ads, and other third-party services. The “packages/easy_ads-main” subproject shows support for ad management.
- Platform-Specific Wrappers: Directories for Android, iOS, macOS, Linux, and Windows provide the native wrappers and configurations that allow Flutter to compile for different platforms.

##### Inter-Component Relationships
- The Presentation Layer interacts with the Domain Layer via view models (e.g., “*_viewmodel.dart”), which in turn invoke use cases located in the Domain Layer.
- Use cases call repositories in the Data Layer to retrieve or send data to remote datasources (e.g., auth_remote_datasource.dart, ai_chat_datasource.dart) and web services.
- The Data Layer communicates with external services such as Firebase, external AI chat services, and ad providers.
- Dependency injection (using the locator) centrally manages component instantiation and service provisioning.
- There is a clear separation between UI (lib/modules/*/app/ui) and business logic (domain and data folders), reinforcing modularity and testability.

##### Notable Architectural Patterns and Design Principles
- Layered Architecture: Presentation, Domain, and Data layers promote separation of concerns.
- Modularization: Each feature (auth, knowledge, prompt, etc.) is contained in its module with subdirectories for different responsibilities.
- Dependency Injection: Use of a service locator for managing dependencies.
- Cross-Platform Design: The project supports multiple platforms (Android, iOS, desktop, web) using Flutter.
- Integration with External Services: Firebase for backend services and third-party SDKs for ads and other services are integrated smoothly into the architecture.

##### Technologies & Frameworks
- Flutter – for UI and multi-platform support.
- Firebase – for backend and configurations.
- Google Mobile Ads – integrated via the “easy_ads” package.
- Standard architectural patterns (e.g., MVVM/MVC) using view models and modular components.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Presentation Layer
    subgraph "Presentation Layer"
        AuthUI["Auth UI (Widgets & Pages)"]:::frontend
        HomeUI["Home UI (Widgets & Pages)"]:::frontend
        KnowledgeUI["Knowledge UI (Widgets & Pages)"]:::frontend
        ViewModels["View Models/Controllers"]:::frontend
    end

    %% Domain Layer
    subgraph "Domain Layer"
        AuthDomain["Auth Domain (Use Cases & Models)"]:::domain
        HomeDomain["Home Domain (Use Cases & Models)"]:::domain
        KnowledgeDomain["Knowledge Domain (Use Cases & Models)"]:::domain
        EmailDomain["Email Domain (Use Cases & Models)"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        AuthData["Auth Data (Repositories & Datasources)"]:::data
        HomeData["Home Data (Repositories & Datasources)"]:::data
        KnowledgeData["Knowledge Data (Repositories & Datasources)"]:::data
    end

    %% External Integrations
    subgraph "External Integrations"
        FirebaseOpt["Firebase Options"]:::external
        FirebaseJSON["Firebase JSON"]:::external
        EasyAds["Easy Ads (Ad Integration)"]:::external
        AdUtilities["Ad Utilities"]:::external
    end

    %% Configuration & Dependency Injection
    subgraph "Configuration & DI"
        ConfigFile["Configuration File"]:::config
        DILocator["DI Locator"]:::config
    end

    %% Platform-Specific Wrappers
    subgraph "Platform-Specific Wrappers"
        Android["Android"]:::platform
        iOS["iOS"]:::platform
        macOS["macOS"]:::platform
        Linux["Linux"]:::platform
        Windows["Windows"]:::platform
    end

    %% Connections between Presentation and Domain Layers via ViewModels
    AuthUI --> ViewModels
    HomeUI --> ViewModels
    KnowledgeUI --> ViewModels

    ViewModels --> AuthDomain
    ViewModels --> HomeDomain
    ViewModels --> KnowledgeDomain

    %% Domain to Data Layer connections
    AuthDomain --> AuthData
    HomeDomain --> HomeData
    KnowledgeDomain --> KnowledgeData

    %% Data Layer to External Integrations connections
    AuthData --> FirebaseOpt
    AuthData --> FirebaseJSON

    HomeData --> FirebaseOpt
    HomeData --> FirebaseJSON
    HomeData --> EasyAds
    HomeData --> AdUtilities

    KnowledgeData --> FirebaseOpt
    KnowledgeData --> FirebaseJSON
    KnowledgeData --> EasyAds
    KnowledgeData --> AdUtilities

    %% Configuration & DI injections
    ConfigFile --- DILocator
    DILocator --- ViewModels
    DILocator --- AuthDomain
    DILocator --- HomeDomain
    DILocator --- KnowledgeDomain
    DILocator --- AuthData
    DILocator --- HomeData
    DILocator --- KnowledgeData

    %% Platform-specific integration (connecting one representative arrow)
    Windows --> AuthUI

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef domain fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef data fill:#FFFFE0,stroke:#DAA520,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#696969,stroke-width:2px;
    classDef config fill:#F08080,stroke:#B22222,stroke-width:2px;
    classDef platform fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;

    %% Click Events for Presentation Layer
    click AuthUI "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/auth/app/ui"
    click HomeUI "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/home/app/ui"
    click KnowledgeUI "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/knowledge/app/ui"

    %% Click Events for Domain Layer
    click AuthDomain "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/auth/domain"
    click HomeDomain "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/home/domain"
    click EmailDomain "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/email/domain"
    click KnowledgeDomain "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/knowledge/domain"

    %% Click Events for Data Layer
    click AuthData "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/auth/data"
    click HomeData "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/home/data"
    click KnowledgeData "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/modules/knowledge/data"

    %% Click Events for Configuration & DI
    click ConfigFile "https://github.com/tpoo1408/jarvis_ai/blob/master/lib/config/config.dart.example"
    click DILocator "https://github.com/tpoo1408/jarvis_ai/blob/master/lib/locator.dart"

    %% Click Events for External Integrations
    click FirebaseOpt "https://github.com/tpoo1408/jarvis_ai/blob/master/lib/firebase_options.dart"
    click FirebaseJSON "https://github.com/tpoo1408/jarvis_ai/blob/master/firebase.json"
    click EasyAds "https://github.com/tpoo1408/jarvis_ai/tree/master/packages/easy_ads-main"
    click AdUtilities "https://github.com/tpoo1408/jarvis_ai/tree/master/lib/ads"

    %% Click Events for Platform-Specific Wrappers
    click Android "https://github.com/tpoo1408/jarvis_ai/tree/master/android/app"
    click iOS "https://github.com/tpoo1408/jarvis_ai/tree/master/ios/Runner"
    click macOS "https://github.com/tpoo1408/jarvis_ai/tree/master/macos/Runner"
    click Linux "https://github.com/tpoo1408/jarvis_ai/tree/master/linux"
    click Windows "https://github.com/tpoo1408/jarvis_ai/tree/master/windows"
```
