YAHNC is a FastAPI-based web application that fetches and displays top stories from Hacker News with additional features like trend indicators when a story is trending and images fetched from Open Graph metadata.
- Fetches top 30 stories from Hacker News API
- Displays stories with images, descriptions, and metadata
- Shows trending information for trending stories
- Dark mode toggle
- Responsive design using Tailwind CSS
- Automatic page refresh every 15 minutes
- Backend: Python 3.10+, FastAPI, SQLAlchemy, aiohttp
- Frontend: HTML, Tailwind CSS, JavaScript
- Database: SQLite (with aiosqlite for async operations)
- Other: BeautifulSoup4, Pillow
-
Clone the repository:
git clone https://github.com/ilyaizen/hn-clone.git cd hn-clone
-
Create a virtual environment and activate it:
python -m venv .venv source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Run the application:
uvicorn main:app --reload
-
Open your browser and navigate to
http://localhost:8000
main.py
: FastAPI application and main routehn_scraper.py
: Hacker News API scraperdatabase.py
: Database operations and ORM setupmetadata.py
: Metadata fetching and image processingmodels.py
: SQLAlchemy modelstemplates/
: HTML templatesstatic/
: Static files (CSS, images)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.