# sudan-dhungana/newsapp architecture

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

- Interactive diagram: https://gitdiagram.com/sudan-dhungana/newsapp
- Repository: https://github.com/sudan-dhungana/newsapp

## Overview

##### Project type and purpose
- This is a native Android mobile application (“NewsApp”) written in Java (Android Studio).
- It aggregates news articles from external web APIs (via Retrofit) and supports user login/registration, bookmarking, commenting, and admin operations.
- It integrates with Firebase (google-services.json) for push notifications and possibly authentication.

##### File structure
- Top-level:
- app/: Android module (build.gradle, src/, res/)
- build/ & gradle/: build artifacts and wrapper
- settings.gradle, gradlew: project configuration
- Under app/src/main/java/com/infinix/NewsApp/:
- AdminActivities/: AdminLoginActivity, AdminDashboard
- MainActivities/: activity_feed, activity_read_full_news
- UserLoginRegister/: login, register, email verif, forgot password
- fragments/: news feed, tech trends, user profile
- RetrofitAPI.java: interface for REST calls
- NewsNotificationService/: Firebase messaging receiver
- WebAppInterface.java: JS-bridge for possible WebView usage
- Model classes: NewsModel, Comment, CategoryRVModel, Bookmarks, etc.
- Resources (res/): layouts, drawables, menus, values, XML configs (network security, data extraction rules).

##### Key architectural insights from README
- Frontend only (Android)
- Backed by PHP/HTML/CSS/JS server (not in this repo, but implied external news source and possible admin backend)
- Fetches region-specific news via REST endpoints

##### Elements
- Clear component labels: e.g., “NewsApp UI”, “RetrofitAPI”, “FCM Service”, “External News API”
- Data fetch (Android → News API → Android)
- Push notifications (FCM → Android)
- Auth requests (Android → Auth Service → Android)
- Green clouds for external services (FCM, News API, Admin backend)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Android App Module
    subgraph "Android App" 
        direction TB
        subgraph "UI Layer" 
            direction TB
            Splash["SplashActivity"]:::blue
            ActivityFeed["activity_feed"]:::blue
            ActivityRead["activity_read_full_news"]:::blue
            AdminLogin["AdminLoginActivity"]:::blue
            AdminDashboard["AdminDashboard"]:::blue
            UserLogin["UserLoginActivity"]:::blue
            UserRegister["UserRegisterActivity"]:::blue
            EmailVerification["EmailVerificationActivity"]:::blue
            ForgotPassword["ForgotPasswordActivity"]:::blue
            FragNewsFeed["fragment_news_feed"]:::blue
            FragTechTrends["fragment_techtrends_local_news"]:::blue
            FragUserProfile["fragment_userprofile"]:::blue
        end

        subgraph "Presentation Layer" 
            direction TB
            CategoryAdapter["CategoryRVAdapter"]:::blue
            NewsAdapter["NewsRVAdapter"]:::blue
            CommentAdapter["CommentAdapter"]:::blue
            CommentViewHolder["CommentViewHolder"]:::blue
            WebAppInterface["WebAppInterface"]:::blue
        end

        subgraph "Data Layer" 
            direction TB
            RetrofitAPI["RetrofitAPI"]:::blue
            Models["Models"]:::blue
        end

        subgraph "Service & Storage" 
            direction TB
            NotificationReceiver["NotificationBroadcastReceiver"]:::blue
            LocalStorage["Local Storage (SQLite/Prefs)"]:::storage
        end
    end

    %% Firebase Cloud Services
    subgraph "Firebase Cloud" 
        direction TB
        FCM["FCM Service"]:::green
        FirebaseAuth["Firebase Auth / Firestore"]:::green
    end

    %% External REST Services
    subgraph "External Services" 
        direction TB
        NewsAPI["External News API"]:::green
        AdminBackend["Admin Backend API"]:::green
    end

    %% Interactions
    Splash -->|initialization| ActivityFeed
    ActivityFeed -->|uses| CategoryAdapter
    ActivityFeed -->|uses| NewsAdapter
    ActivityFeed -->|hosts| FragNewsFeed
    ActivityFeed -->|hosts| FragTechTrends
    ActivityFeed -->|hosts| FragUserProfile
    ActivityRead -->|reads full| NewsAdapter
    AdminLogin -->|login| AdminBackend
    AdminDashboard -->|manage articles| AdminBackend
    UserLogin -->|auth request| FirebaseAuth
    UserRegister -->|register request| FirebaseAuth
    EmailVerification -->|verify| FirebaseAuth
    ForgotPassword -->|reset| FirebaseAuth

    FragNewsFeed -->|fetch news| RetrofitAPI
    FragTechTrends -->|fetch tech news| RetrofitAPI
    ActivityFeed -->|bookmark| LocalStorage
    ActivityRead -->|comment| CommentAdapter
    CommentAdapter -->|model| Models
    CategoryAdapter -->|model| Models
    NewsAdapter -->|model| Models
    RetrofitAPI -->|HTTP/JSON| NewsAPI
    AdminBackend -->|HTTP/JSON| RetrofitAPI
    WebAppInterface -->|JS bridge| ActivityRead

    FCM -->|push notif| NotificationReceiver
    NotificationReceiver -->|display| ActivityFeed
    NotificationReceiver -->|display| ActivityRead

    %% Click Events
    click Splash "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/SplashScreen/SplashActivity.java"
    click ActivityFeed "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/MainActivities/activity_feed.java"
    click ActivityRead "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/MainActivities/activity_read_full_news.java"
    click AdminLogin "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/AdminActivities/AdminLoginActivity.java"
    click AdminDashboard "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/AdminActivities/AdminDashboard.java"
    click UserLogin "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/UserLoginRegister/UserLoginActivity.java"
    click UserRegister "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/UserLoginRegister/UserRegisterActivity.java"
    click EmailVerification "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/UserLoginRegister/EmailVerificationActivity.java"
    click ForgotPassword "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/UserLoginRegister/ForgotPasswordActivity.java"
    click FragNewsFeed "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/fragments/fragment_news_feed.java"
    click FragTechTrends "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/fragments/fragment_techtrends_local_news.java"
    click FragUserProfile "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/fragments/fragment_userprofile.java"
    click CategoryAdapter "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/CategoryRVAdapter.java"
    click NewsAdapter "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/NewsRVAdapter.java"
    click CommentAdapter "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/CommentAdapter.java"
    click CommentViewHolder "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/CommentViewHolder.java"
    click WebAppInterface "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/WebAppInterface.java"
    click RetrofitAPI "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/RetrofitAPI.java"
    click NotificationReceiver "https://github.com/sudan-dhungana/newsapp/blob/main/app/src/main/java/com/infinix/NewsApp/NewsNotificationService/NotificationBroadcastReceiver.java"
    click LocalStorage "https://github.com/sudan-dhungana/newsapp/blob/main/app/google-services.json"

    %% Styles
    classDef blue fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef green fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef storage fill:#e6ccff,stroke:#333,stroke-width:1px
    class Splash,ActivityFeed,ActivityRead,AdminLogin,AdminDashboard,UserLogin,UserRegister,EmailVerification,ForgotPassword,FragNewsFeed,FragTechTrends,FragUserProfile,CategoryAdapter,NewsAdapter,CommentAdapter,CommentViewHolder,WebAppInterface,RetrofitAPI,NotificationReceiver blue
    class FCM,FirebaseAuth,NewsAPI,AdminBackend green
    class LocalStorage storage
```
