A command-line RSS feed aggregator written in Go that allows users to manage and aggregate RSS feeds, follow feeds of interest, and browse posts from subscribed feeds.
- User Management: Register and manage multiple users with login switching
- Feed Management: Add and track RSS feeds from various sources
- RSS Aggregation: Automatically fetch and parse RSS feeds at configurable intervals
- Feed Subscription: Follow and unfollow RSS feeds
- Post Browsing: Browse aggregated posts from followed feeds
- Database Persistence: Store users, feeds, posts, and subscriptions in PostgreSQL
- Go 1.26.2 or later
- PostgreSQL database
- Command-line interface
- Clone the repository:
git clone https://github.com/itsankitpatel/gator.git
cd gator- Install dependencies:
go mod downloadNOTE: You can skip the above two steps if you install the project via go install:
go install github.com/itsankitpatel/gator@latestand then you can run the commands with gator instead of go run ..
-
Set up your PostgreSQL database
- Download postgresql
- Check the postgresql version
psql --version
- Update postgres password:
sudo passwd postgres
Enter a password, and be sure you won't forget it. You can just use something easy like postgres.
-
Start the postgres server in background
For Linux:sudo service postgresql start
For macOS:
brew services start postgresql
-
Enter the psql shell
For Linux:sudo -u postgres psql
For macOS:
psql postgres
You should see something like this:
postgres=# -
Create a new database named gator:
CREATE DATABASE gator;
- Connect to the gator database:
\c gator;
- Set the user password(Linux/WSL only):
ALTER USER postgres WITH PASSWORD 'postgres';
For simplicity, I used postgres as the password. Before, we altered the system user's password, now we're altering the database user's password.
-
Create a
.gatorconfig.jsonfile in your home directory:
{
"db_url": "postgres://username:password@localhost/gator?sslmode=disable",
"current_user_name": ""
}Register a new user:
go run . register <username>Login as a user:
go run . login <username>List all users:
go run . usersAdd a new RSS feed:
go run . addfeed <feed_name> <feed_url>Requires user to be logged in. Automatically follows the feed for the current user.
List all feeds:
go run . feedsFollow a feed by URL:
go run . follow <feed_url>Requires user to be logged in. Adds an existing feed to the current user's subscriptions.
List feeds you're following:
go run . followingRequires user to be logged in.
Unfollow a feed:
go run . unfollow <feed_url>Requires user to be logged in. Removes the feed from your subscriptions.
Start automatic feed aggregation:
go run . agg <interval>Fetches all RSS feeds at the specified interval (e.g., 10s, 1m, 5m).
Example:
go run . agg 30sThis fetches all feeds every 30 seconds and saves new posts to the database.
View posts from followed feeds:
go run . browse [limit]Requires user to be logged in. Displays posts from feeds you follow. Optionally specify the number of posts to display (default: 2).
Example:
go run . browse 5Reset the entire gator database:
go run . resetClears all data from users, feeds, posts, and feed follows tables.
gator/
├── main.go # Application entry point
├── commands.go # Command registration and routing
├── handler_*.go # HTTP handlers for each command
├── rss_feed.go # RSS parsing logic
├── internal/
│ ├── config/
│ │ └── config.go # Configuration management
│ └── database/
│ ├── db.go # Database initialization
│ ├── models.go # Data models
│ └── *.sql.go # Auto-generated SQL queries
└── sql/
├── schema/ # Database schema migrations
└── queries/ # SQL queries
- users: Stores user accounts
- feeds: Stores RSS feed URLs and metadata
- feed_follows: Tracks which users follow which feeds
- posts: Stores individual blog posts from feeds
The application uses a .gatorconfig.json file in your home directory to store:
db_url: PostgreSQL connection stringcurrent_user_name: Currently logged-in user
github.com/google/uuid- UUID generation for database recordsgithub.com/lib/pq- PostgreSQL driver for Go
- User Registration: Create user accounts that are stored in the database
- Feed Management: Add RSS feed URLs to track
- Aggregation: The
aggcommand fetches feeds on an interval:- Fetches the next unfetched feed
- Marks the feed as fetched
- Parses the RSS XML
- Saves new posts to the database (skips duplicates)
- Browsing: Users can browse posts from feeds they follow, filtered by user
- The application uses context-based database queries for proper timeout handling
- RSS parsing handles both RFC1123Z and RFC1123 date formats
- HTML entities in RSS content are properly unescaped
- Duplicate posts are automatically skipped during aggregation
- Authentication is handled through config file user switching (middleware)