An open API service indexing awesome lists of open source software.

https://github.com/devbyray/hackernews-clone

A fully functional HackerNews clone built with Vue 3, Tailwind CSS, Vitest, and Storybook. Features 7 tested components, 46 unit tests, and real HN API integration.
https://github.com/devbyray/hackernews-clone

Last synced: 1 day ago
JSON representation

A fully functional HackerNews clone built with Vue 3, Tailwind CSS, Vitest, and Storybook. Features 7 tested components, 46 unit tests, and real HN API integration.

Awesome Lists containing this project

README

          

# ๐Ÿ—ž๏ธ HackerNews Clone

A fully functional, read-only HackerNews clone built from scratch with Vue 3, featuring comprehensive testing and documentation.

[![Tests](https://img.shields.io/badge/tests-56%20passing-brightgreen)]()
[![Components](https://img.shields.io/badge/components-11-blue)]()
[![Stories](https://img.shields.io/badge/storybook-47%20stories-orange)]()

![](./screenshot.png)

## โœจ Features

- ๐Ÿ“ฐ **Browse Top Stories** - Real-time top 30 stories from HackerNews
- ๐Ÿ’ฌ **Nested Comments** - Recursive comment threads with collapse/expand
- ๐ŸŽจ **Responsive Design** - Beautiful UI with Tailwind CSS v4
- ๐Ÿงช **Fully Tested** - 62 unit tests (56 passing)
- ๐Ÿ“š **Documented** - Storybook stories for all components
- โšก **Fast & Modern** - Built with Vite and Vue 3 Composition API
- โ™ฟ **Accessible** - Semantic HTML and ARIA attributes
- ๐Ÿ”ง **Reusable Components** - Button and Input components for consistency

## ๏ฟฝ Design

Built from a community Figma design:

- **[HackerNews Website Redesign](https://www.figma.com/design/nZYxyHjSmGpgACq6qC4Wq6/HackerNews-Website-Redesign--Community-?node-id=19-1250&t=UCkFgUKMUAWa1SPp-4)** - Modern redesign with orange branding

## ๏ฟฝ๐ŸŽฏ Live Demo

Run locally in 2 minutes:

```bash
npm install
npm run dev
```

Visit: http://localhost:5173

## ๐Ÿ—๏ธ Tech Stack

| Technology | Purpose |
| ------------------- | ------------------------------ |
| **Vue 3** | UI Framework (Composition API) |
| **Vue Router** | Client-side routing |
| **Tailwind CSS v4** | Utility-first styling |
| **Vitest** | Unit testing framework |
| **Storybook** | Component documentation |
| **Vite** | Build tool & dev server |
| **HackerNews API** | Real data integration |

## ๐Ÿš€ Getting Started

### Prerequisites

- Node.js 18+ and npm

### Installation

```bash
# Install dependencies
npm install

# Start development server
npm run dev
```

Visit **http://localhost:5173** to see the app!

### Quick Commands

```bash
# Development
npm run dev # Start dev server

# Testing
npm test # Run all tests
npm test -- --watch # Run tests in watch mode
npm run coverage # Generate coverage report

# Storybook
npm run storybook # Start Storybook on port 6006

# Production
npm run build # Build for production
npm run preview # Preview production build
```

## ๐Ÿ“ฆ Project Structure

```
src/
โ”œโ”€โ”€ components/ # 11 components (organized in folders)
โ”‚ โ”œโ”€โ”€ Button/
โ”‚ โ”‚ โ”œโ”€โ”€ Button.vue
โ”‚ โ”‚ โ”œโ”€โ”€ Button.test.js
โ”‚ โ”‚ โ””โ”€โ”€ Button.stories.js
โ”‚ โ”œโ”€โ”€ Input/
โ”‚ โ”‚ โ”œโ”€โ”€ Input.vue
โ”‚ โ”‚ โ”œโ”€โ”€ Input.test.js
โ”‚ โ”‚ โ””โ”€โ”€ Input.stories.js
โ”‚ โ”œโ”€โ”€ Header/
โ”‚ โ”‚ โ”œโ”€โ”€ Header.vue
โ”‚ โ”‚ โ”œโ”€โ”€ Header.test.js
โ”‚ โ”‚ โ””โ”€โ”€ Header.stories.js
โ”‚ โ”œโ”€โ”€ Footer/
โ”‚ โ”‚ โ”œโ”€โ”€ Footer.vue
โ”‚ โ”‚ โ””โ”€โ”€ Footer.stories.js
โ”‚ โ”œโ”€โ”€ LoadingSpinner/
โ”‚ โ”œโ”€โ”€ ErrorMessage/
โ”‚ โ”œโ”€โ”€ StoryItem/
โ”‚ โ”œโ”€โ”€ StoryList/
โ”‚ โ”œโ”€โ”€ CommentItem/
โ”‚ โ”œโ”€โ”€ CommentList/
โ”‚ โ””โ”€โ”€ ReadingList/
โ”œโ”€โ”€ pages/ # Application pages
โ”‚ โ”œโ”€โ”€ HomePage.vue
โ”‚ โ””โ”€โ”€ StoryDetailPage.vue
โ”œโ”€โ”€ router/ # Vue Router configuration
โ”œโ”€โ”€ services/ # HackerNews API service
โ””โ”€โ”€ style.css # Tailwind CSS v4
```

## ๐Ÿงฉ Components

All 11 components are organized in individual folders with tests and documentation:

| Component | Purpose | Tests | Stories |
| ------------------ | ----------------------------- | ----- | ------- |
| **Button** | Reusable button (4 variants) | 8 | 8 |
| **Input** | Reusable input (5 types) | 8 | 6 |
| **Header** | Navigation header | 3 | 1 |
| **Footer** | Footer with newsletter signup | - | 1 |
| **LoadingSpinner** | Loading indicator | 6 | 5 |
| **ErrorMessage** | Error display | 8 | 5 |
| **StoryItem** | Individual story card | 7 | 5 |
| **StoryList** | List of stories | 6 | 5 |
| **CommentItem** | Recursive comment | 8 | 5 |
| **CommentList** | Comment container | 8 | 5 |
| **ReadingList** | Reading list display | - | 1 |

**Total: 62 tests (56 passing), 47 Storybook stories**

See [COMPONENTS.md](./COMPONENTS.md) for detailed documentation.

## ๐Ÿงช Testing

All components have comprehensive unit tests:

```bash
npm test -- --run
```

**Results:**

- โœ… 9 test files
- โœ… 56 tests passing (62 total)
- โœ… Comprehensive component coverage
- ๐ŸŽฏ New Button and Input components: 16/16 tests passing

## ๐Ÿ“š Documentation

- **[QUICKSTART.md](./QUICKSTART.md)** - Get started in 2 minutes
- **[COMPONENTS.md](./COMPONENTS.md)** - Detailed component documentation
- **[PROJECT-SUMMARY.md](./PROJECT-SUMMARY.md)** - Complete project overview
- **Storybook** - Interactive component examples (run `npm run storybook`)

## ๐Ÿ”Œ API Integration

Uses the official [HackerNews Firebase API](https://github.com/HackerNews/API):

- **Top Stories:** `/v0/topstories.json`
- **Item Details:** `/v0/item/{id}.json`
- **Features:** Real-time data, recursive comment loading, error handling

## ๐ŸŽจ Customization

### Change Theme Colors

Edit `src/style.css` (Tailwind CSS v4):

```css
@theme {
--color-hn-orange: #ff6600;
--color-hn-bg: #fafcff;
--color-hn-text: #54575a;
--color-hn-dark: #3f220f;
}
```

### Adjust Story Count

Edit `src/pages/HomePage.vue`:

```javascript
const storyIds = await getTopStories(30) // Change to any number
```

## ๐Ÿ“ธ Screenshots

### Home Page - Top Stories

![](./screenshot.png)

Browse the latest HackerNews stories with scores, authors, and comment counts.

## ๐Ÿค Contributing

This is a learning project showcasing:

- Vue 3 Composition API
- Component-driven development
- Test-driven development
- Documentation-first approach

Feel free to explore the code and use it as a reference!

## ๐Ÿ“„ License

MIT License - Feel free to use this project for learning and reference.

## ๐Ÿ™ Credits

- **HackerNews** for the API
- **Vue.js** team for the amazing framework
- **Tailwind CSS** for the utility-first CSS framework
- **Vite** for the blazing-fast build tool