# ngdhuy/se_newspaper architecture

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

- Interactive diagram: https://gitdiagram.com/ngdhuy/se_newspaper
- Repository: https://github.com/ngdhuy/se_newspaper

## Overview

##### Project type and purpose
- Type: Desktop GUI application built with JavaFX
- Purpose: Load and parse RSS feeds from multiple newspaper “brands” and “categories,” then render the results in JavaFX screens.

##### File structure
- Controllers (src/main/java/io/setud/se_newspaper/controllers)
– MainScreenController, SplashScreenController: handle user events and view logic
- Views (src/main/resources/io/setud/se_newspaper/*.fxml + CSS)
– Two FXML files (Splash, Main), plus an extra heat-tab view and their styles
- Models (src/main/java/io/setud/se_newspaper/models)
– Brand, Category, Feed, News, plus a NewsPaperFactory
– Subpackages: “brands,” “categories,” and “concretes/[brand]/[category]” implement a family of RSS-parsers per brand & category
- Utility (src/main/java/io/setud/se_newspaper/util/Loader.java)
– Central FXML loader utility
- Entry point: Main.java
- Build and dependency management: pom.xml (Maven), module-info.java

##### Core components
a. JavaFX UI Layer
– SplashScreen.fxml + SplashScreenController
– MainScreen.fxml + MainScreenController
b. Application Core / Business Layer
– NewsPaperFactory: instantiates the correct concrete Feed parser based on selected brand & category
– Feed interface / abstract: defines loadRSS() or similar
– Concrete Feed implementations (e.g., VnExpressBusiness, VnExpressSports, ThanhNienCovid, etc.)
– Domain models: News, Feed, Category, Brand
c. Utility
– Loader: FXML loader & resource manager
d. External Services
– RSS endpoints (one per brand/category combination)

##### Relationships & data flow
– User launches Main → Main.java
– Loader loads SplashScreen.fxml → SplashScreenController
– After splash, Loader switches to MainScreen.fxml → MainScreenController
– MainScreenController captures user’s brand & category choice
– Controller calls NewsPaperFactory.getFeed(brand, category)
– Factory returns a ConcreteFeed instance (e.g., VnExpressSports)
– ConcreteFeed.fetchRSS() contacts external RSS URL → parses XML → produces List<News>
– Controller receives List<News> → binds it to JavaFX UI components (TableView, WebView, etc.)

##### Architectural patterns & principles
- MVC (JavaFX):
– Model = domain objects + factory + concrete parsers
– View = FXML + CSS
– Controller = MainScreenController, SplashScreenController
- Factory Method: NewsPaperFactory decides which parser to instantiate
- Separation of concerns: UI, business logic, parsing logic, and utility are clearly split
- Single desktop‐process with no database; all data comes from external RSS services

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Entry & Utility"
        Main["Main"]:::util
        Loader["Loader"]:::util
    end

    subgraph "UI Layer"
        SplashFXML["SplashScreen.fxml"]:::ui
        SplashCSS["SplashScreen.css"]:::ui
        SplashCtrl["SplashScreenController"]:::ui
        MainFXML["MainScreen.fxml"]:::ui
        MainCSS["MainScreen.css"]:::ui
        MainCtrl["MainScreenController"]:::ui
        HeatFXML["heat-tab.fxml"]:::ui
    end

    subgraph "Core / Business Layer"
        Factory["NewsPaperFactory"]:::business
        FeedInterface["Feed"]:::business
        BrandModel["Brand"]:::business
        CategoryModel["Category"]:::business
        NewsModel["News"]:::business
    end

    subgraph "Concrete Feed Parsers"
        subgraph "NguoiLaoDong"
            NLD_Biz["NguoiLaoDongBusiness"]:::parser
            NLD_Sports["NguoiLaoDongSports"]:::parser
            NLD_Covid["NguoiLaoDongCovid"]:::parser
        end
        subgraph "ThanhNien"
            TN_Biz["ThanhNienBusiness"]:::parser
            TN_Sports["ThanhNienSports"]:::parser
            TN_Covid["ThanhNienCovid"]:::parser
        end
        subgraph "TuoiTre"
            TT_Biz["TuoiTreBusiness"]:::parser
            TT_Sports["TuoiTreSports"]:::parser
            TT_Covid["TuoiTreCovid"]:::parser
        end
        subgraph "VnExpress"
            VN_Biz["VnExpressBusiness"]:::parser
            VN_Sports["VnExpressSports"]:::parser
            VN_Covid["VnExpressCovid"]:::parser
        end
        subgraph "VtcNews"
            VTC_Biz["VtcNewsBusiness"]:::parser
            VTC_Sports["VtcNewsSports"]:::parser
            VTC_Covid["VtcNewsCovid"]:::parser
        end
    end

    subgraph "External RSS Endpoints"
        ExternalRSS["RSS Endpoints"]:::external
    end

    %% Connections
    Main -->|launches| Loader
    Loader -->|loads| SplashCtrl
    SplashCtrl -->|binds view| SplashFXML
    SplashCtrl -->|after splash| Loader
    Loader -->|loads| MainCtrl
    MainCtrl -->|binds view| MainFXML
    MainCtrl -->|includes extra tab| HeatFXML
    MainCtrl -->|"selects brand/category"| Factory
    Factory -->|returns parser| FeedInterface
    FeedInterface -->|implemented by| NLD_Biz & NLD_Sports & NLD_Covid
    FeedInterface -->|implemented by| TN_Biz & TN_Sports & TN_Covid
    FeedInterface -->|implemented by| TT_Biz & TT_Sports & TT_Covid
    FeedInterface -->|implemented by| VN_Biz & VN_Sports & VN_Covid
    FeedInterface -->|implemented by| VTC_Biz & VTC_Sports & VTC_Covid
    NLD_Biz & NLD_Sports & NLD_Covid -->|fetchRSS| ExternalRSS
    TN_Biz & TN_Sports & TN_Covid -->|fetchRSS| ExternalRSS
    TT_Biz & TT_Sports & TT_Covid -->|fetchRSS| ExternalRSS
    VN_Biz & VN_Sports & VN_Covid -->|fetchRSS| ExternalRSS
    VTC_Biz & VTC_Sports & VTC_Covid -->|fetchRSS| ExternalRSS
    NLD_Biz & TN_Biz & TT_Biz & VN_Biz & VTC_Biz -->|produce| NewsModel
    NewsModel -->|provided to| MainCtrl

    %% Click Events
    click Main "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/java/io/setud/se_newspaper/Main.java"
    click Loader "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/java/io/setud/se_newspaper/util/Loader.java"
    click SplashFXML "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/resources/io/setud/se_newspaper/SplashScreen.fxml"
    click SplashCtrl "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/java/io/setud/se_newspaper/controllers/SplashScreenController.java"
    click MainFXML "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/resources/io/setud/se_newspaper/MainScreen.fxml"
    click MainCtrl "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/java/io/setud/se_newspaper/controllers/MainScreenController.java"
    click HeatFXML "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/resources/io/setud/se_newspaper/heat-tab.fxml"
    click Factory "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/java/io/setud/se_newspaper/models/NewsPaperFactory.java"
    click FeedInterface "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/java/io/setud/se_newspaper/models/Feed.java"
    click BrandModel "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/java/io/setud/se_newspaper/models/Brand.java"
    click CategoryModel "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/java/io/setud/se_newspaper/models/Category.java"
    click NewsModel "https://github.com/ngdhuy/se_newspaper/blob/main/src/main/java/io/setud/se_newspaper/models/News.java"

    %% Styles
    classDef ui fill:#add8e6,stroke:#000,color:#000;
    classDef business fill:#90ee90,stroke:#000,color:#000;
    classDef parser fill:#ffa500,stroke:#000,color:#000;
    classDef util fill:#ffdead,stroke:#000,color:#000;
    classDef external fill:#ff7f7f,stroke:#000,color:#000;
```
