Skip to content

Latest commit

Β 

History

History
137 lines (102 loc) Β· 3.53 KB

File metadata and controls

137 lines (102 loc) Β· 3.53 KB

Harmonica

A native Swift/SwiftUI Hacker News client inspired by Harmonic for Android.

Built with SwiftUI, Core Data, and zero third-party dependencies.


Screenshots

screenshots


Features

  • Best, New, Ask, Show, Jobs feeds
  • Time filter β€” 24h / 48h / Week / Month / All
  • In-app WebView with progress bar, back/forward navigation, share
  • Bookmarks β€” save stories, export as text
  • Comments β€” full threaded view with collapse/expand
  • User profiles β€” karma, bio, submissions
  • Search β€” powered by Algolia full-text search
  • Submit β€” post stories to HN
  • Offline caching β€” Core Data cache with smart expiry
  • 7 themes including 3 animated Liquid UI themes

Architecture

harmonica-hn/
β”œβ”€β”€ Models/              Pure Swift structs (API models)
β”œβ”€β”€ CoreData/            Core Data stack + entity extensions
β”œβ”€β”€ Repository/          Cache-first data layer
β”œβ”€β”€ Services/            Network layer (HN Firebase + Algolia)
β”œβ”€β”€ ViewModels/          @Observable state management
β”œβ”€β”€ Views/               SwiftUI views
β”œβ”€β”€ Theme/               Theme definitions + liquid animations
└── Utilities/           HTML parser, date formatter, extensions

Data Flow

View β†’ ViewModel β†’ Repository β†’ Cache (Core Data)
                              ↓ (if stale/empty)
                              β†’ Service (Network)
                              β†’ Cache (save)
                              β†’ ViewModel β†’ View

APIs Used

HN Firebase API

https://hacker-news.firebaseio.com/v0/
  • /beststories.json β€” Best story IDs
  • /newstories.json β€” New story IDs
  • /askstories.json β€” Ask HN IDs
  • /showstories.json β€” Show HN IDs
  • /jobstories.json β€” Jobs IDs
  • /item/{id}.json β€” Story or comment detail
  • /user/{id}.json β€” User profile

Algolia Search API

https://hn.algolia.com/api/v1/
  • /search?tags=front_page β€” Front page stories
  • /search_by_date?query=... β€” Full text search
  • /items/{id} β€” Story with full comment tree
  • /search_by_date?tags=author_{username} β€” User submissions

Cache Expiry

Data Duration
Best stories 10 min
New stories 5 min
Ask / Show / Jobs 15 min
Comments 5 min
User profiles 30 min

Requirements

  • Xcode 15+
  • iOS 17+ / macOS 14+
  • Swift 5.9+
  • No third-party dependencies

Setup

  1. Clone the repo
  2. Open harmonica-hn.xcodeproj in Xcode
  3. Select your target device (iPhone simulator or My Mac)
  4. Press Cmd+R to run

No API keys required β€” both HN Firebase and Algolia APIs


Building for macOS

The app uses SwiftUI Multiplatform β€” macOS support is built in from day one.

Select My Mac in the Xcode device picker and press Run.

All platform-specific code is wrapped in #if os(iOS) / #if os(macOS) blocks so both targets compile cleanly.


Roadmap

  • HN login + voting
  • Push notifications for replies
  • iCloud sync for bookmarks
  • iPad optimised split view
  • Home screen widget β€” top story of the day
  • Filter stories by keyword / domain
  • Comment navigation buttons (jump between top-level)
  • Font size settings
  • Reader mode in WebView

Credits