A Hacker News client built using Elm that fetches the top stories and displays them in a table with filtering and sorting capabilities.
- Fetch and display Hacker News top stories
- Sort posts by score, title, posting date, or no sorting
- Filter posts (show/hide job posts and text-only posts)
- Configurable number of posts to display (10, 25, or 50)
- Relative time display showing how long ago posts were created
- Responsive UI with clean layout
src/
├── Cursor.elm # Data structure for list navigation
├── Effect.elm # Effect management for HTTP requests
├── Main.elm # Application entry point
├── Model/ # Domain models
│ ├── Post.elm # Post data structure and decoder
│ ├── PostIds.elm # Post IDs data structure and operations
│ └── PostsConfig.elm # Configuration for posts display
├── Model.elm # Main application model
├── Reactor.elm # For local development
├── Util/
│ └── Time.elm # Time formatting utilities
└── View/
└── Posts.elm # Post table rendering
- Node.js and npm
- Elm (0.19.1)
- Clone the repository:
git clone https://github.com/yourusername/elm-hackernews-client.git
cd elm-hackernews-client- Install dependencies:
npm installStart the Elm reactor:
elm reactorThen open http://localhost:8000/src/Main.elm in your browser.
For offline development without the real Hacker News API:
npm run serverThen open http://localhost:8000/src/Reactor.elm in your browser.
The application uses the Elm Architecture with:
- Model: Defines the application state
- Update: Handles messages and updates the model
- View: Renders the UI based on the current model
- Commands: Manages side effects like HTTP requests
Run all tests:
npm testTo see your final grade:
npm run grade- Cursor: Efficient data structure for navigating a list forward or backward
- Post Table: Displays posts with score, title, type, posting time, and link
- Configuration Panel: Allows customizing the posts display
- Time Utilities: Format timestamps and calculate relative time durations
This project is provided as an educational resource with no specific license.