# shawon5ice/newsly architecture

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

- Interactive diagram: https://gitdiagram.com/shawon5ice/newsly
- Repository: https://github.com/shawon5ice/newsly

## Overview

##### High-Level Components

a) Presentation Layer (UI)
- Main UI components: Home, Search, Bookmark, and Details screens
- BLoC components for each feature (represented as hexagons)

b) Domain Layer
- UseCases for each feature
- Repository interfaces

c) Data Layer
- Repository implementations
- Data sources (both remote and local)

##### Core Infrastructure
- DI Container (AppComponent)
- Route Management
- Theme Management
- Local Storage (Hive)
- Network Client (Dio)

##### External Services
External dependencies:
- News API (external service)
- Firebase (for configuration)

##### Component Relationships

**UI -> BLoC -> UseCase -> Repository Interface -> Repository Implementation -> Data Sources**

##### Detailed Component Breakdown

For each feature module (home, search, bookmark, details), show:
- Presentation: BLoC (Event, State, Bloc)
- Domain: UseCase, Repository Interface
- Data: Repository Implementation, Models

##### Core services and utilities

Remember to:
- Keep components grouped by feature
- Clear boundaries between layers
- Dependency direction (always inward)
- Notes for important architectural decisions

This will create a comprehensive visualization that accurately represents the application's architecture while maintaining clarity and understanding of the system's components and their interactions.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef presentation fill:#E3F2FD,stroke:#2196F3
    classDef domain fill:#E8F5E9,stroke:#4CAF50
    classDef data fill:#FFF3E0,stroke:#FF9800
    classDef infrastructure fill:#F3E5F5,stroke:#9C27B0
    classDef external fill:#EFEBE9,stroke:#795548
    classDef bloc fill:#E1F5FE,stroke:#03A9F4,shape:hexagon
    classDef storage fill:#FFE0B2,stroke:#FF9800,shape:cylinder

    %% Infrastructure Layer
    subgraph Infrastructure
        DI[DI Container]:::infrastructure
        Routes[Route Management]:::infrastructure
        Theme[Theme Management]:::infrastructure
        Network[Network Client]:::infrastructure
        LocalDB[Local Storage]:::infrastructure
        Session[Session Management]:::infrastructure
    end

    %% External Services
    subgraph External
        NewsAPI[News API]:::external
        Firebase[Firebase Config]:::external
    end

    %% Presentation Layer
    subgraph Presentation
        HomeScreen[Home Screen]:::presentation
        SearchScreen[Search Screen]:::presentation
        BookmarkScreen[Bookmark Screen]:::presentation
        DetailsScreen[Details Screen]:::presentation
        
        HomeBloc[Home BLoC]:::bloc
        SearchBloc[Search BLoC]:::bloc
        BookmarkBloc[Bookmark BLoC]:::bloc
        DetailsBloc[Details BLoC]:::bloc
        
        CommonWidgets[Common Widgets]:::presentation
    end

    %% Domain Layer
    subgraph Domain
        HomeUseCase[Home UseCase]:::domain
        SearchUseCase[Search UseCase]:::domain
        NewsRepo[News Repository Interface]:::domain
    end

    %% Data Layer
    subgraph Data
        RepoImpl[Repository Implementation]:::data
        NewsModel[News Response Model]:::data
        DetailsModel[News Details Model]:::data
        HiveDB[Hive Storage]:::storage
    end

    %% Relationships
    HomeScreen --> HomeBloc
    SearchScreen --> SearchBloc
    BookmarkScreen --> BookmarkBloc
    DetailsScreen --> DetailsBloc

    HomeBloc --> HomeUseCase
    SearchBloc --> SearchUseCase
    BookmarkBloc --> NewsRepo
    DetailsBloc --> NewsRepo

    HomeUseCase --> NewsRepo
    SearchUseCase --> NewsRepo
    NewsRepo --> RepoImpl
    RepoImpl --> NewsModel
    RepoImpl --> DetailsModel
    RepoImpl --> Network
    Network --> NewsAPI

    RepoImpl --> HiveDB
    DI --> Network
    DI --> LocalDB
    DI --> Session
    
    %% Click Events
    click HomeScreen "https://github.com/shawon5ice/newsly/blob/master/lib/home/presentation/ui/home_page.dart"
    click SearchScreen "https://github.com/shawon5ice/newsly/blob/master/lib/search/presentation/ui/search_page.dart"
    click BookmarkScreen "https://github.com/shawon5ice/newsly/blob/master/lib/bookmark/presentation/ui/bookmark_page.dart"
    click DetailsScreen "https://github.com/shawon5ice/newsly/blob/master/lib/details/presentation/ui/news_details.dart"
    click HomeBloc "https://github.com/shawon5ice/newsly/blob/master/lib/home/presentation/bloc/home_bloc.dart"
    click SearchBloc "https://github.com/shawon5ice/newsly/blob/master/lib/search/presentation/bloc/search_bloc.dart"
    click BookmarkBloc "https://github.com/shawon5ice/newsly/blob/master/lib/bookmark/presentation/bloc/news_details_bloc.dart"
    click DetailsBloc "https://github.com/shawon5ice/newsly/blob/master/lib/details/presentation/bloc/news_details_bloc.dart"
    click HomeUseCase "https://github.com/shawon5ice/newsly/blob/master/lib/home/domain/usecase/home_usecase.dart"
    click SearchUseCase "https://github.com/shawon5ice/newsly/blob/master/lib/search/domain/usecase/search_usecase.dart"
    click NewsRepo "https://github.com/shawon5ice/newsly/blob/master/lib/home/domain/repository/news_repository.dart"
    click RepoImpl "https://github.com/shawon5ice/newsly/blob/master/lib/home/data/repository/news_repository_implementation.dart"
    click NewsModel "https://github.com/shawon5ice/newsly/blob/master/lib/home/data/model/news_response.dart"
    click DetailsModel "https://github.com/shawon5ice/newsly/blob/master/lib/details/data/model/news_details_model.dart"
    click DI "https://github.com/shawon5ice/newsly/blob/master/lib/core/di/app_component.dart"
    click Routes "https://github.com/shawon5ice/newsly/blob/master/lib/core/routes/app_routes.dart"
    click Theme "https://github.com/shawon5ice/newsly/blob/master/lib/core/theme/newsly_theme_data.dart"
    click Network "https://github.com/shawon5ice/newsly/blob/master/lib/core/data/source/dio_client.dart"
    click LocalDB "https://github.com/shawon5ice/newsly/blob/master/lib/core/service/local_database_service.dart"
    click Session "https://github.com/shawon5ice/newsly/blob/master/lib/core/session/session_manager.dart"
    click Firebase "https://github.com/shawon5ice/newsly/blob/master/lib/firebase_options.dart"
```
