Blogator is a modern blogging platform designed to allow users to manage and share blogs efficiently. Built with Golang, it leverages PostgreSQL for data persistence and integrates with goose for database migrations and sqlc for type-safe SQL query management.
- User Management: Securely create and manage user profiles.
- Feed Management: Users can add and manage RSS feeds, representing blogs or other content sources.
- Post Scraping: Automatically scrapes new posts from added feeds.
- Feed Following: Users can follow specific feeds and manage their subscriptions.
- API Key Authentication: Each user is assigned a unique API key for secure interactions with the API.
Ensure you have the following installed:
- Go (version 1.16 or later)
- PostgreSQL
- Goose (for database migrations)
- SQLC (for generating Go code from SQL)
- Clone the repository:
git clone https://github.com/yourgithubusername/blogator.git
- Navigate to the project directory:
cd blogator - Set up the environment variables:
Create a
.envfile in the project root and update the following variables:DB_URL="postgres://username:password@localhost:5432/blogator" - Run Database Migrations:
goose postgres $DB_URL up - Generate Go code from SQL:
sqlc generate
- Build the project:
go build -o blogator
- Run the server:
./blogator
All API requests are prefixed with /app/v1.
-
Create User:
POST /users- Body:
{"name": "username"} - Response: Returns the created user object with API key.
- Body:
-
Get User by API Key:
GET /users- Headers:
Authorization: ApiKey <key> - Response: Returns the user object.
- Headers:
-
Create Feed:
POST /feeds- Body:
{"name": "Feed Name", "url": "https://feedurl.com/rss"} - Auth Required
- Body:
-
Get Feeds:
GET /feeds- Auth Not Required
-
Follow Feed:
POST /feeds/follow- Body:
{"feed_id": "feed_uuid"} - Auth Required
- Body:
-
Unfollow Feed:
DELETE /feed_follows/{feedFollowID}- Auth Required
- Get Posts by User:
GET /posts- Query Parameters:
limit(optional) - Auth Required
- Query Parameters:
- Users: Stores user data including a generated API key.
- Feeds: Contains details of the RSS feeds added by users.
- Posts: Captures posts fetched from the RSS feeds.
goose postgres postgres://postgres:postgres@localhost:5432/blogator up
psql postgres://postgres:postgres@localhost:5432/blogator
sqlc generate
Contributions to improve Blogator are welcome. Please fork the repository and submit a pull request with your changes.
Distributed under the MIT License. See LICENSE for more information.