# avinashk369/tapinvest architecture

> Architecture diagram of the GitHub repository avinashk369/tapinvest, 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/avinashk369/tapinvest
- Repository: https://github.com/avinashk369/tapinvest

## Overview

##### Main Components
- Flutter Application Shell: Represent the client app that encompasses the user interface. This includes all Flutter pages, widgets, and layout files (in lib and the platform directories like ios, android, etc.).
- Feature Modules: Highlight “home” and “instrument” as distinct features. Each feature is broken down into:
- Data Layer: Contains models and repositories (e.g., bonds_model.dart, bond_detail.dart) for fetching and processing data.
- Domain/Business Logic Layer: Defines repository interfaces and business rules.
- Presentation Layer: Uses BLoC (business logic component) patterns to manage states and events (home_bloc.dart, instrument_bloc.dart) along with corresponding UI pages and widgets.
- Core Components:
- Dependency Injection: The “di” directory under lib/core contains modules and configuration files (app_manager.dart, injection.dart) to wire up dependencies.
- Routing & Navigation: The “lib/routes” folder holds route animations, constants, and a route generator that bridges navigation among pages.
- Services & API Communication: Under lib/services, the API client and Dio client manage network communications essential for retrieving data from external sources.

##### Relationships & Interactions
- Dependency injection component as an underlying layer that binds the repositories, blocs, and services together.
- Navigation flows managed by the routing component.

##### Architectural Patterns & Design Principles
- Clean Architecture & Modular Organization: Emphasize the separation of concerns between data, domain, and presentation layers within each feature.
- State Management via BLoC: Note that each feature has its events, states, and logic segregated from UI components.
- Dependency Injection: Clearly mark out the DI container setup for managing dependencies across the app.
- Cross-platform Build: Optionally, show that the same core Flutter codebase is deployed across different platforms by referencing directories (android, ios, macos, windows, web, linux).

##### Incorporate Technical Stack & Technologies
- Flutter Framework for building UI
- Dart language (as shown by .dart files in lib)
- BLoC pattern for state management
- Dio (or similar HTTP client) for API calls
- Dependency Injection for wiring modules together
- Clearly denote use of platform-specific configuration files and resources in respective directories.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Tapinvest Flutter App Container
    subgraph "Tapinvest Flutter App"
        %% Flutter Application Shell
        subgraph "Flutter Application Shell"
            MainApp["Flutter App Shell"]:::ui
            Android["Android"]:::ui
            iOS["iOS"]:::ui
            Linux["Linux"]:::ui
            macOS["macOS"]:::ui
            Web["Web"]:::ui
            Windows["Windows"]:::ui
        end

        %% Home Feature
        subgraph "Home Feature"
            subgraph "Presentation"
                HomeScreen["Home Screen"]:::ui
                HomeBloc["Home Bloc"]:::bloc
            end
            subgraph "Domain"
                HomeRepoInterface["Home Repository Interface"]:::domain
            end
            subgraph "Data"
                BondsModel["Bonds Model"]:::data
                HomeRepoImpl["Home Repository Impl"]:::data
            end
        end

        %% Instrument Feature
        subgraph "Instrument Feature"
            subgraph "Presentation"
                InstrumentDetail["Instrument Detail"]:::ui
                InstrumentBloc["Instrument Bloc"]:::bloc
            end
            subgraph "Domain"
                InstrumentRepoInterface["Instrument Repository Interface"]:::domain
            end
            subgraph "Data"
                BondDetail["Bond Detail"]:::data
                InstrumentRepoImpl["Instrument Repository Impl"]:::data
            end
        end
    end

    %% Core Services outside main app container
    subgraph "Core Services"
        %% Dependency Injection Components
        subgraph "Dependency Injection"
            AppManager["App Manager"]:::di
            AppModule["App Module"]:::di
            Injection["Injection"]:::di
            InjectionConfig["Injection Config"]:::di
        end

        %% Routing & Navigation
        subgraph "Routing & Navigation"
            RouteAnimation["Route Animation"]:::routing
            RouteConst["Route Const"]:::routing
            RouteGenerator["Route Generator"]:::routing
        end

        %% Services & API Communication
        subgraph "Services & API Communication"
            ApiClient["API Client"]:::services
            DioClient["Dio Client"]:::services
        end

        %% Error Handling & Utilities
        subgraph "Error Handling & Utilities"
            ServerError["Server Error"]:::utilities
            ApiConst["API Const"]:::utilities
            AppColors["App Colors"]:::utilities
            AppConst["App Const"]:::utilities
            ErrorConst["Error Const"]:::utilities
        end
    end

    %% Connections within Flutter Application Shell and Features
    MainApp -->|"launches"| HomeScreen
    MainApp -->|"launches"| InstrumentDetail

    MainApp --> Android
    Android --> iOS
    iOS --> Linux
    Linux --> macOS
    macOS --> Web
    Web --> Windows

    HomeScreen -->|"triggers"| HomeBloc
    InstrumentDetail -->|"triggers"| InstrumentBloc

    HomeBloc -->|"calls"| HomeRepoInterface
    InstrumentBloc -->|"calls"| InstrumentRepoInterface

    HomeRepoInterface -->|"implementedBy"| HomeRepoImpl
    InstrumentRepoInterface -->|"implementedBy"| InstrumentRepoImpl

    HomeRepoImpl -->|"uses"| BondsModel
    InstrumentRepoImpl -->|"uses"| BondDetail

    HomeRepoImpl -->|"fetchesFrom"| ApiClient
    InstrumentRepoImpl -->|"fetchesFrom"| ApiClient

    ApiClient -->|"utilizes"| DioClient
    ApiClient -->|"handles"| ServerError

    %% Dependency Injection wiring
    Injection -->|"injects"| HomeBloc
    Injection -->|"injects"| InstrumentBloc
    Injection -->|"injects"| HomeRepoImpl
    Injection -->|"injects"| InstrumentRepoImpl
    Injection -->|"injects"| ApiClient
    Injection -->|"injects"| RouteGenerator

    %% Routing Integration
    MainApp -->|"navigatesVia"| RouteGenerator

    %% Styling classes assignment (for clarity)
    class MainApp,Android,iOS,Linux,macOS,Web,Windows,HomeScreen,InstrumentDetail ui;
    class HomeBloc,InstrumentBloc bloc;
    class HomeRepoInterface,InstrumentRepoInterface domain;
    class BondsModel,HomeRepoImpl,BondDetail,InstrumentRepoImpl data;
    class AppManager,AppModule,Injection,InjectionConfig di;
    class RouteAnimation,RouteConst,RouteGenerator routing;
    class ApiClient,DioClient services;
    class ServerError,ApiConst,AppColors,AppConst,ErrorConst utilities;

    %% Click Events
    click MainApp "https://github.com/avinashk369/tapinvest/blob/main/lib/main.dart"
    click Android "https://github.com/avinashk369/tapinvest/tree/main/android"
    click iOS "https://github.com/avinashk369/tapinvest/tree/main/ios"
    click Linux "https://github.com/avinashk369/tapinvest/tree/main/linux"
    click macOS "https://github.com/avinashk369/tapinvest/tree/main/macos"
    click Web "https://github.com/avinashk369/tapinvest/tree/main/web"
    click Windows "https://github.com/avinashk369/tapinvest/tree/main/windows"

    click HomeScreen "https://github.com/avinashk369/tapinvest/blob/main/lib/features/home/presentation/pages/home_screen.dart"
    click HomeBloc "https://github.com/avinashk369/tapinvest/blob/main/lib/features/home/presentation/bloc/home_bloc.dart"
    click HomeRepoInterface "https://github.com/avinashk369/tapinvest/blob/main/lib/features/home/domain/repositories/home_repository.dart"
    click BondsModel "https://github.com/avinashk369/tapinvest/blob/main/lib/features/home/data/model/bonds_model.dart"
    click HomeRepoImpl "https://github.com/avinashk369/tapinvest/blob/main/lib/features/home/data/repositories/home_repository_impl.dart"

    click InstrumentDetail "https://github.com/avinashk369/tapinvest/blob/main/lib/features/instrument/presentation/pages/instrument_detail.dart"
    click InstrumentBloc "https://github.com/avinashk369/tapinvest/blob/main/lib/features/instrument/presentation/bloc/instrument_bloc.dart"
    click InstrumentRepoInterface "https://github.com/avinashk369/tapinvest/blob/main/lib/features/instrument/domain/repository/instrument_repository.dart"
    click BondDetail "https://github.com/avinashk369/tapinvest/blob/main/lib/features/instrument/data/model/bond_detail.dart"
    click InstrumentRepoImpl "https://github.com/avinashk369/tapinvest/blob/main/lib/features/instrument/data/repositories/instrument_repository_impl.dart"

    click AppManager "https://github.com/avinashk369/tapinvest/blob/main/lib/core/di/app_manager.dart"
    click AppModule "https://github.com/avinashk369/tapinvest/blob/main/lib/core/di/app_module.dart"
    click Injection "https://github.com/avinashk369/tapinvest/blob/main/lib/core/di/injection.dart"
    click InjectionConfig "https://github.com/avinashk369/tapinvest/blob/main/lib/core/di/injection.config.dart"

    click ServerError "https://github.com/avinashk369/tapinvest/blob/main/lib/core/errors/server_error.dart"
    click ApiConst "https://github.com/avinashk369/tapinvest/blob/main/lib/core/utils/api_const.dart"
    click AppColors "https://github.com/avinashk369/tapinvest/blob/main/lib/core/utils/app_colors.dart"
    click AppConst "https://github.com/avinashk369/tapinvest/blob/main/lib/core/utils/app_const.dart"
    click ErrorConst "https://github.com/avinashk369/tapinvest/blob/main/lib/core/utils/error_const.dart"

    click RouteAnimation "https://github.com/avinashk369/tapinvest/blob/main/lib/routes/route_animation.dart"
    click RouteConst "https://github.com/avinashk369/tapinvest/blob/main/lib/routes/route_const.dart"
    click RouteGenerator "https://github.com/avinashk369/tapinvest/blob/main/lib/routes/route_generator.dart"

    click ApiClient "https://github.com/avinashk369/tapinvest/blob/main/lib/services/api_client.dart"
    click DioClient "https://github.com/avinashk369/tapinvest/blob/main/lib/services/dio_client.dart"

%% Styles
classDef ui fill:#ade8f4,stroke:#000,stroke-width:2px;
classDef bloc fill:#ffb703,stroke:#000,stroke-width:2px;
classDef domain fill:#ffd6a5,stroke:#000,stroke-width:2px;
classDef data fill:#a2d2ff,stroke:#000,stroke-width:2px;
classDef di fill:#bde0fe,stroke:#000,stroke-width:2px;
classDef routing fill:#ffc8dd,stroke:#000,stroke-width:2px;
classDef services fill:#caffbf,stroke:#000,stroke-width:2px;
classDef utilities fill:#d3f8e2,stroke:#000,stroke-width:2px;
```
