blog-aggregator

command module
v0.0.0-...-699d7d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 17 Imported by: 0

README

Blog Aggregator aka gator

Gator is a Go-based CLI application for aggregating, browsing, and following RSS feeds. It is designed to simplify the consumption of blog and news content for users. This project uses PostgreSQL for database queries and supports user management and feed subscriptions.

Features

  • User Management: Create and manage user accounts.
  • RSS Feed Aggregation: Fetch and store RSS feed content.
  • Feed Browsing: View available feeds and posts.
  • Follow Feeds: Users can follow feeds and view personalized content.
  • Efficient Database Interaction: SQL queries are managed with sqlc for type-safe database operations.

Prerequisites

  • Go: Version 1.18 or higher.
  • PostgreSQL: A running PostgreSQL instance for the database.
  • sqlc: To regenerate database code from SQL queries.

Installation

  1. Clone the Repository:

    git clone https://github.com/Taanviir/blog-aggregator.git
    cd blog-aggregator
    
  2. Install Dependencies:

    go mod tidy
    
  3. Set Up Database:

    • Create a PostgreSQL database.
    • Apply schema migrations from sql/schema/.
      psql -U <username> -d <database_name> -f sql/schema/001_users.sql
      psql -U <username> -d <database_name> -f sql/schema/002_feeds.sql
      # Repeat for remaining files in schema
      
  4. Set Up Configuration File:

    • Create a configuration file in your home directory named ~/.gatorconfig.json.
    {
        "db_url": "url",
        "current_user_name": "user"
    }
    
    • Replace db_url with your PostgreSQL connection string and current_user_name with your desired username. The application will automatically look for this configuration file at ~/.gatorconfig.json during runtime.
  5. Install the CLI:

    go install github.com/Taanviir/blog-aggregator@latest
    
    • This will compile and install the gator CLI tool, making it available in your $GOPATH/bin directory.
    • Ensure this directory is in your PATH to use the gator command globally.

Usage

CLI Commands

To use the application, run the gator executable followed by a command:

gator <command> [<args>]
Available Commands
  • login: Log in as an existing user.

  • register: Register a new user account.

  • reset: Reset user password.

  • users: View all users (admin only).

  • agg: Aggregate RSS feed data.

  • addfeed: Add a new RSS feed (requires login).

  • feeds: List all available RSS feeds.

  • follow: Follow a specific RSS feed (requires login).

  • following: View feeds followed by the logged-in user.

  • unfollow: Unfollow a specific RSS feed (requires login).

  • browse: Browse posts from followed feeds (requires login).

Example Usage
# Register a new user
gator register <username> <password>

# Log in
gator login <username> <password>

# Add a new feed (requires login)
gator addfeed <feed_url>

# Follow a feed (requires login)
gator follow <feed_id>

# View posts from followed feeds
gator browse

Development

Regenerate SQL Code

If you modify SQL queries, use sqlc to regenerate code:

sqlc generate

Contributing

  1. Fork the repository.
  2. Create a new branch for your feature/fix.
  3. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL