Gator is a multi-user command-line RSS feed aggregator written in Go. It allows users to add and follow RSS feeds, aggregate the posts, and browse them efficiently. The program utilizes a PostgreSQL database for storage and supports user authentication to manage personal feed subscriptions.
- User Authentication: Register, login, and manage user sessions.
- RSS Feed Management: Add and follow RSS feeds.
- Feed Aggregation: Periodically fetch RSS feed data.
- Post Browsing: View recent posts from followed feeds.
- Database-backed Storage: Uses PostgreSQL for data persistence.
Ensure you have the following installed:
- Go (1.24+)
- PostgreSQL
git clone https://github.com/bsuvonov/gator.git
cd gatorCreate a configuration file in your home directory:
touch ./.gatorconfig.jsonEdit the file and add:
{
"db_url": "postgres://user:password@hostname:5432/gator",
"current_user_name": ""
}Replace user, hostname, password, and gator with your PostgreSQL credentials.
# Install goose to handle database migrations
go install github.com/pressly/goose/v3/cmd/goose@latest
# Run `up` migrations
goose postgres "postgres://user:password@hostname:5432/gator" --dir sql/schema upReplace the PosgtreSQL connection string with a correct one.
To build the project:
go mod tidy
go build -o gatorRun the program:
./gator <command> [args]| Command | Description |
|---|---|
register <name> |
Register a new user |
login <name> |
Login to existing user |
reset |
Reset users and their feeds |
users |
List existing users |
addfeed <name> <url> |
Add a new RSS feed |
feeds |
List all created feeds |
follow <url> |
Follow a specific feed |
following |
List feeds the user follows |
unfollow <url> |
Unfollow a feed |
agg <duration> |
Fetch new posts from subscribed feeds periodically |
browse [limit] |
Browse recently published posts (default: 5 posts) |
- Register a user:
./gator register alice- Login as the user:
./gator login alice- Add an RSS feed:
./gator addfeed TechCrunch https://techcrunch.com/feed/- Follow an existing feed:
./gator follow https://techcrunch.com/feed/- Start fetching feeds every 10 minutes:
./gator agg 10m- Browse the latest posts:
./gator browse 10This application uses PostgreSQL with the following main tables:
users: Stores registered users.feeds: Stores added RSS feeds.feed_follows: Tracks which users follow which feeds.posts: Stores posts from feeds.