# sanjaysupanch/news-app architecture

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

- Interactive diagram: https://gitdiagram.com/sanjaysupanch/news-app
- Repository: https://github.com/sanjaysupanch/news-app

## Overview

##### Project Type and Purpose
- This is a modern Android News App built using Jetpack Compose. It follows the MVVM architectural pattern combined with Clean Architecture principles.
- The app fetches news articles from NewsAPI, displays them in a scrollable list, allows users to save articles locally using Room, and opens full articles in a WebView. Dependency Injection is achieved via Hilt, and the overall experience is enriched with modern UI elements like bottom navigation and dynamic theming.

##### Analyzing the File Structure
- The entire project's structure lies under the "app" directory. Key directories include:
- src/main/java: Contains all application code including UI screens, navigation, theme definitions, data handling (API service, DAO, database, repository), dependency injection (DI modules), and viewmodels.
- Data Layer: Found in subdirectories like data/api (ArticlesAPIService), data/database (NewsDatabase, NewsDao), and data/modal (NewsModal).
- DI: Directory "di" includes modules such as NetworkModule and DatabaseModule.
- UI: Layers include UI components, screens (HomeScreen, DetailsScreen, SavedArticlesScreen), navigation (BottomNavigationBar, Screens), theme, etc.
- The file tree also hints at clear separation of concerns aligning with the MVVM and Clean Architecture patterns.

##### Additional Details and Recommendations
- The process of fetching news articles: API Service call, data processing in Repository, updating the ViewModel, and display on UI.
- The saving of articles: interaction with Room Database through DAO and Repository.
- Navigation between screens handled via a Bottom Navigation Bar.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        A1["HomeScreen"]:::ui
        A2["DetailsScreen"]:::ui
        A3["SavedArticlesScreen"]:::ui
        AC["ArticleCard"]:::ui
        NB["BottomNavigationBar"]:::ui
        NI["BottomNavigationItem"]:::ui
        NS["Screens mapping"]:::ui
        UT1["Color Definitions"]:::ui
        UT2["Theme Setup"]:::ui
        UT3["Type Definitions"]:::ui
    end

    %% Domain Layer
    subgraph "Domain Layer"
        V["NewsViewModel"]:::domain
        R["NewsRepository"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        API["ArticlesAPIService"]:::data
        DB["NewsDatabase"]:::data
        DAO["NewsDao"]:::data
        NM["NewsModal"]:::data
    end

    %% Dependency Injection
    subgraph "Dependency Injection"
        NMODULE["NetworkModule"]:::di
        DMODULE["DatabaseModule"]:::di
    end

    %% Connections between Layers
    %% UI Layer to Domain Layer
    A1 -->|"sendsUserEvents"| V
    A2 -->|"sendsUserEvents"| V
    A3 -->|"sendsUserEvents"| V

    %% Domain Layer interactions
    V -->|"fetchData"| R

    %% Repository interacts with Data Layer
    R -->|"fetchRemote"| API
    R -->|"fetchLocal"| DB

    %% Database contains DAO
    DB -->|"contains"| DAO

    %% Dependency Injection provides dependencies
    NMODULE -->|"provides"| API
    NMODULE -->|"injects"| R
    DMODULE -->|"provides"| DB
    DMODULE -->|"injects"| R
    DMODULE -->|"injects"| V

    %% UI Navigation and Components
    NB -->|"navigatesTo"| NS

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef domain fill:#ABEBC6,stroke:#196F3D,stroke-width:2px;
    classDef data fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef di fill:#F5B7B1,stroke:#922B21,stroke-width:2px;

    %% Click Events for UI Layer (Screens)
    click A1 "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/screens/HomeScreen.kt"
    click A2 "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/screens/DetailsScreen.kt"
    click A3 "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/screens/SavedArticlesScreen.kt"
    click AC "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/components/ArticleCard.kt"
    click NB "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/navigation/BottomNavigationBar.kt"
    click NI "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/navigation/BottomNavigationItem.kt"
    click NS "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/navigation/Screens.kt"
    click UT1 "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/theme/Color.kt"
    click UT2 "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/theme/Theme.kt"
    click UT3 "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/ui/theme/Type.kt"

    %% Click Events for ViewModel Layer
    click V "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/viewmodal/NewsViewModel.kt"

    %% Click Events for Repository Layer
    click R "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/data/repository/NewsRepository.kt"

    %% Click Events for Data Layer
    click API "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/data/api/ArticlesAPIService.kt"
    click DB "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/data/database/NewsDatabase.kt"
    click DAO "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/data/database/NewsDao.kt"
    click NM "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/data/modal/NewsModal.kt"

    %% Click Events for Dependency Injection
    click NMODULE "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/di/NetworkModule.kt"
    click DMODULE "https://github.com/sanjaysupanch/news-app/blob/main/app/src/main/java/com/example/news/di/DatabaseModule.kt"
```
