# tibo/swiftrss architecture

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

- Interactive diagram: https://gitdiagram.com/tibo/swiftrss
- Repository: https://github.com/tibo/swiftrss

## Overview

##### Project Type and Purpose
- SwiftRSS is an open-source Swift library (module) that parses RSS feeds.
- It includes:
- The core parsing module (`SwiftRSS/`)
- An example iOS app (`SwiftRSS_Example/`) showing how to consume the library
- A suite of unit tests with mock RSS files (`Tests/`)
- Continuous integration configuration (`.travis.yml`)

##### File-Structure Analysis
- Top-level: CI config, license, README, core module folder, example app Xcode project, example app source, and tests.
- Core module (`SwiftRSS/`):
- RSSParser.swift – entry point for parsing
- RSSFeed.swift, RSSItem.swift – model objects
- NSDate+dateFromInternetDateTimeString.swift – date parsing extension
- String+imageLinksFromHTML.swift – HTML image-URL extractor
- Example app (`SwiftRSS_Example/` + `.xcodeproj`):
- AppDelegate + Master/Detail view controllers + storyboard
- `template.html` – sample UI template (optional)
- Tests (`Tests/`):
- Individual test files for each feature + mock RSS feeds in `Tests/Mocks/`

##### Core Components
a. Networking Layer
- NSURLSession / NSURLRequest in the example app or client code
b. Parser Module
- RSSParser.parseFeedForRequest(request, callback)
c. Model Layer
- RSSFeed (feed metadata)
- RSSItem (individual items)
d. Helpers / Extensions
- Date extension for RFC822/RFC3339 parsing
- HTML extension for extracting image URLs
e. Consumer (Example App)
- MasterViewController → requests feed → shows list
- DetailViewController → shows item details, images
f. Testing & CI
- Unit tests targeting each parser and extension
- Travis CI build runner

##### Relationships and Data Flows
- Consumer (UI or client) issues NSURLRequest →
→ passed to RSSParser →
→ RSSParser invokes helper extensions (date parsing, HTML parsing) →
→ constructs RSSFeed & RSSItem models →
→ returns models via callback →
→ Consumer updates UI.
- Tests directly invoke RSSParser & helpers with mock data to validate output.
- CI monitors `.travis.yml` to run tests on each push/pull request.

##### Architectural Patterns & Design Principles
- Modular separation:
- Core parsing logic lives in its own folder (module)
- Consumer code (UI) separated into example app
- Single Responsibility:
- Parser handles XML parsing + delegation to model creators
- Extensions handle specialized tasks (dates, HTML)
- Models encapsulate data only
- Dependency Injection (callback closure) for asynchronous parsing
- MVC pattern in the example app (ViewControllers + Models)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Subgraphs for organization
    subgraph "Core Module"
        direction TB
        CoreModule["SwiftRSS Module"]:::core
        RSSParser["RSSParser.parseFeedForRequest(request,callback)"]:::core
        CoreModule --> RSSParser
    end

    subgraph "Helper Extensions"
        direction TB
        DateExt["NSDate+dateFromInternetDateTimeString"]:::helper
        HTMLExt["String+imageLinksFromHTML"]:::helper
    end

    subgraph "Model Objects"
        direction TB
        RSSFeed["RSSFeed"]:::model
        RSSItem["RSSItem"]:::model
    end

    subgraph "Example App (Consumer)"
        direction TB
        AppProject["SwiftRSS_Example.xcodeproj"]:::consumer
        AppDir["SwiftRSS_Example/"]:::consumer
        AppDelegate["AppDelegate"]:::consumer
        MasterVC["MasterViewController"]:::consumer
        DetailVC["DetailViewController"]:::consumer
        Storyboard["Main.storyboard"]:::consumer
        HTMLTemplate["template.html"]:::consumer
        AppProject --> AppDir
        AppDir --> AppDelegate
        AppDir --> MasterVC
        AppDir --> DetailVC
        AppDir --> Storyboard
        AppDir --> HTMLTemplate
    end

    subgraph "Tests & CI"
        direction TB
        TravisCI[".travis.yml"]:::ci
        TestsSuite["Unit Tests Suite"]:::ci
        Mocks["Tests/Mocks"]:::ci
        ParserTests["RSSParser_Tests"]:::ci
        FeedTests["RSSFeed_Tests"]:::ci
        ItemTests["RSSItem_Tests"]:::ci
        DateTests["NSDate+dateFromInternetDateTimeString_Tests"]:::ci
        HTMLTests["String+imageLinksFromHTML_Tests"]:::ci
        TestsSuite --> ParserTests
        TestsSuite --> FeedTests
        TestsSuite --> ItemTests
        TestsSuite --> DateTests
        TestsSuite --> HTMLTests
        Mocks --> ParserTests
        Mocks --> FeedTests
        Mocks --> ItemTests
        Mocks --> DateTests
        Mocks --> HTMLTests
        TravisCI --> TestsSuite
    end

    %% Data flow arrows
    MasterVC -->|"NSURLRequest"| RSSParser
    RSSParser -->|"uses DateExt"| DateExt
    RSSParser -->|"uses HTMLExt"| HTMLExt
    RSSParser -->|"constructs RSSFeed"| RSSFeed
    RSSParser -->|"constructs RSSItem"| RSSItem
    RSSParser -->|"callback([RSSItem])"| MasterVC
    RSSItem -->|"detail data"| DetailVC

    %% Test flows
    ParserTests --> RSSParser
    FeedTests --> RSSFeed
    ItemTests --> RSSItem
    DateTests --> DateExt
    HTMLTests --> HTMLExt

    %% Styles
    classDef core fill:#D0E1FF,stroke:#0366d6,color:#0366d6;
    classDef helper fill:#E6F7E6,stroke:#28a428,color:#28a428;
    classDef model fill:#FFF4CC,stroke:#d29922,color:#d29922;
    classDef consumer fill:#FFE5CC,stroke:#d16103,color:#d16103;
    classDef ci fill:#EDEDED,stroke:#6a737d,color:#6a737d;

    %% Click Events
    click CoreModule "https://github.com/tibo/swiftrss/tree/master/SwiftRSS/"
    click RSSParser "https://github.com/tibo/swiftrss/blob/master/SwiftRSS/RSSParser.swift"
    click RSSFeed "https://github.com/tibo/swiftrss/blob/master/SwiftRSS/RSSFeed.swift"
    click RSSItem "https://github.com/tibo/swiftrss/blob/master/SwiftRSS/RSSItem.swift"
    click DateExt "https://github.com/tibo/swiftrss/blob/master/SwiftRSS/NSDate+dateFromInternetDateTimeString.swift"
    click HTMLExt "https://github.com/tibo/swiftrss/blob/master/SwiftRSS/String+imageLinksFromHTML.swift"
    click AppProject "https://github.com/tibo/swiftrss/blob/master/SwiftRSS_Example.xcodeproj"
    click AppDir "https://github.com/tibo/swiftrss/tree/master/SwiftRSS_Example/"
    click AppDelegate "https://github.com/tibo/swiftrss/blob/master/SwiftRSS_Example/AppDelegate.swift"
    click MasterVC "https://github.com/tibo/swiftrss/blob/master/SwiftRSS_Example/MasterViewController.swift"
    click DetailVC "https://github.com/tibo/swiftrss/blob/master/SwiftRSS_Example/DetailViewController.swift"
    click Storyboard "https://github.com/tibo/swiftrss/blob/master/SwiftRSS_Example/Base.lproj/Main.storyboard"
    click HTMLTemplate "https://github.com/tibo/swiftrss/blob/master/SwiftRSS_Example/template.html"
    click TestsSuite "https://github.com/tibo/swiftrss/tree/master/Tests/"
    click Mocks "https://github.com/tibo/swiftrss/tree/master/Tests/Mocks/"
    click ParserTests "https://github.com/tibo/swiftrss/blob/master/Tests/RSSParser_Tests.swift"
    click FeedTests "https://github.com/tibo/swiftrss/blob/master/Tests/RSSFeed_Tests.swift"
    click ItemTests "https://github.com/tibo/swiftrss/blob/master/Tests/RSSItem_Tests.swift"
    click DateTests "https://github.com/tibo/swiftrss/blob/master/Tests/NSDate+dateFromInternetDateTimeString_Tests.swift"
    click HTMLTests "https://github.com/tibo/swiftrss/blob/master/Tests/String+imageLinksFromHTML_Tests.swift"
    click TravisCI "https://github.com/tibo/swiftrss/blob/master/.travis.yml"
```
