How frank0ch0a/hackernewsiosexample works
This is a SwiftUI Hacker News reader. On launch or pull-to-refresh, the list view asks its view model to fetch articles; the repository attempts the remote source, filters previously deleted IDs, caches results, and falls back to cached articles on failure or offline use. Users can open linked stories in an in-app web view and swipe to delete posts. The graph covers the principal flow and persistence; the README documents the user-facing capabilities, while some view-model and storage details are represented only where the source index or excerpts support them.
Main entry points: NewsListView.swift News list · ArticleRepositoryImpl.swift Repository implementation · RemoteArticleDataSource.swift Remote source · ArticleViewModel.swift Article view model
Components 18
Presentation
- App entry
HackerNewsExample/HackerNewsExample/HackerNewsExampleApp.swift - News list
HackerNewsExample/HackerNewsExample/Presentation/NewsListView.swift - Article row
HackerNewsExample/HackerNewsExample/Presentation/ArticleItemView.swift - In-app web view
HackerNewsExample/HackerNewsExample/Presentation/WebView.swift - Article view model
HackerNewsExample/HackerNewsExample/ViewModel/ ArticleViewModel.swift
Article workflow
- Repository factory
HackerNewsExample/HackerNewsExample/Factory/ArticleRepositoryFactory.swift - Article repository
HackerNewsExample/HackerNewsExample/Repository/ArticleRepository.swift - Repository implementation
HackerNewsExample/HackerNewsExample/Repository/ArticleRepositoryImpl.swift - Fetch use case
HackerNewsExample/HackerNewsExample/Domain/UseCases/FetchArticleUseCase.swift - Article model
HackerNewsExample/HackerNewsExample/Entity/Article.swift
Data sources
- Remote source
HackerNewsExample/HackerNewsExample/Datasource/RemoteArticleDataSource.swift - Local source
HackerNewsExample/HackerNewsExample/Datasource/LocalArticleDataSource.swift - Network monitor
HackerNewsExample/HackerNewsExample/Utils/NetworkMonitor.swift
Local persistence
- Core Data stack
HackerNewsExample/HackerNewsExample/Storage/CoreDataStack.swift - Article store
HackerNewsExample/HackerNewsExample/Storage/HackerNewsExample.xcdatamodeld/HackerNewsExample.xcdatamodel/contents
Networking
- Network service
HackerNewsExample/HackerNewsExample/Network/NetworkService.swift
Other components
- Reader
- Hacker News API
Connections 20
- Reader → News list: views and interacts
README.md - App entry → News list: shows
HackerNewsExample/HackerNewsExample/HackerNewsExampleApp.swift - News list → Article view model: fetches and deletes
HackerNewsExample/HackerNewsExample/Presentation/NewsListView.swift - News list → Article row: renders
HackerNewsExample/HackerNewsExample/Presentation/NewsListView.swift - News list → In-app web view: opens selected link
HackerNewsExample/HackerNewsExample/Presentation/NewsListView.swift - Article view model → Article repository: requests articles
HackerNewsExample/HackerNewsExample/ViewModel/ ArticleViewModel.swift - Article view model → Network monitor: checks connectivity
HackerNewsExample/HackerNewsExample/ViewModel/ ArticleViewModel.swift - Repository factory → Repository implementation: creates
HackerNewsExample/HackerNewsExample/Factory/ArticleRepositoryFactory.swift - Repository implementation → Remote source: fetches remotely
HackerNewsExample/HackerNewsExample/Repository/ArticleRepositoryImpl.swift - Repository implementation → Local source: reads and saves cache
HackerNewsExample/HackerNewsExample/Repository/ArticleRepositoryImpl.swift - Repository implementation → Core Data stack: filters deleted IDs
HackerNewsExample/HackerNewsExample/Repository/ArticleRepositoryImpl.swift - Fetch use case → Article repository: uses
HackerNewsExample/HackerNewsExample/Domain/UseCases/FetchArticleUseCase.swift - Remote source → Network service: requests data
HackerNewsExample/HackerNewsExample/Datasource/RemoteArticleDataSource.swift - Remote source → Hacker News API: retrieves articles
HackerNewsExample/HackerNewsExample/Datasource/RemoteArticleDataSource.swift - Network service → Hacker News API: sends HTTP request
HackerNewsExample/HackerNewsExample/Network/NetworkService.swift - Local source → Core Data stack: reads and writes
HackerNewsExample/HackerNewsExample/Datasource/LocalArticleDataSource.swift - Core Data stack → Article store: persists entities
- Remote source → Article model: decodes
HackerNewsExample/HackerNewsExample/Datasource/RemoteArticleDataSource.swift - Local source → Article model: maps cached records
HackerNewsExample/HackerNewsExample/Datasource/LocalArticleDataSource.swift - Article row → Article model: displays
HackerNewsExample/HackerNewsExample/Presentation/ArticleItemView.swift