Gator is a command-line interface (CLI) tool designed to help users manage RSS feeds and posts. This project was built to enhance database interaction skills, demonstrating how applications can store and retrieve records, much like how banks handle their data.
- User Management: Register and log in users. 👤
- Feed Management: Add, list, follow, and unfollow RSS feeds. 📰
- Post Aggregation: Automatically scrape and store posts from followed feeds. 📥
- Post Browse: View aggregated posts. 📖
- Database Reset: Clear all data from the database. 🗑️
Before running Gator, ensure you have the following installed and configured on your system:
- Go (Golang): Version 1.18 or higher.
- PostgreSQL: A running PostgreSQL database instance.
- Goose: A database migration tool for Go. You can install it via:
go install https://github.com/pressly/goose/v3/cmd/goose@latest
Clone the repository:
bash git clone <https://github.com/Josephus-git/gator.git> cd gator
Gator utilizes goose for managing database schema migrations. You need to set up your PostgreSQL database and apply the necessary migrations:
-
Configure your database connection string: Navigate to the
sql/schemadirectory within the cloned repository. You will find migration files there. By default, the application expects a PostgreSQL database atpostgres://postgres:postgres@localhost:5432/gator. You might need to:- Create a database named
gator. - Ensure a user
postgreswith passwordpostgresexists, or adjust the connection string in thegoosecommands to match your database credentials.
- Create a database named
-
Run database migrations: From the sql/schema of your cloned repository, execute
goosewith your database connection string:goose postgres postgres://postgres:postgres@localhost:5432/gator up
This command will apply all required database schemas and prepare your database for Gator.
-
Configure connection credentials for the postgreSQL database: Manually create a config file in your home directory, ~/.gatorconfig.json with the following content:
{ "db_url": "postgres postgres://postgres:postgres@localhost:5432/gator?sslmode=disable" }
Install the executable:
bash go install
This command will compile the gator program and place the executable in your GOPATH/bin directory, making it available for use from your terminal.
Once Gator is installed and the database is set up, you can interact with it using various commands from your terminal.
General Command Structure:
gator <command> [arguments...]
gator users
gator register <username>
# e.g.
gator register skywalker
gator login <username>
# e.g.
gator login skywalker
gator addfeed <feed_name> <feed_url>
# e.g.
gator addfeed GoBlog https://blog.golang.org/feed.atom
gator agg <seconds>
# e.g.
gator agg 30
gator browse <limit>
# e.g.
gator browse 5
gator feeds
gator following
gator follow <feed_url>
gator unfollow <feed_url>
gator reset
Feel free to explore the commands and contribute to the project! Happy Gating! 🎉