This is the backend service for the Blog Aggregator application, developed using Go. It provides APIs for managing users, feeds, and feed follows, and is deployed on Google Cloud Platform (GCP) using Cloud Run. A major feature of this project is the concurrent scraping of blogs from the followed feeds, ensuring that users receive the latest posts efficiently.
The goal of this project is to create a robust, scalable, and efficient backend service for aggregating blog feeds. It aims to provide a seamless experience for users to register, manage their feeds, and follow updates from various blog sources. Concurrent scraping allows for timely updates and efficient handling of multiple feeds.
-
Clone the Repository
git clone https://github.com/yourusername/blog-aggregator.git cd blog-aggregator -
Set Up Environment Variables
Create a
.envfile with the following content:PORT="8080" DB_URL="your-database-url"
-
Run the Application
go mod tidy go run main.go
-
Build and Run with Docker
docker build -t blog-aggregator . docker run -p 8080:8080 blog-aggregator
-
Build and Tag Docker Image
docker build -t gcr.io/YOUR_PROJECT_ID/blog-aggregator:v1 . -
Push Docker Image to GCR
docker push gcr.io/YOUR_PROJECT_ID/blog-aggregator:v1
-
Deploy to Cloud Run
gcloud run deploy blog-aggregator \ --image gcr.io/YOUR_PROJECT_ID/blog-aggregator:v1 \ --platform managed \ --region us-central1 \ --allow-unauthenticated
-
Health Check
GET /v1/healthz- Response:
{ "status": "ok" }
-
User Registration
POST /v1/users- Request Body:
{ "Name": "UserName" } - Response:
{ "ID": "UUID", "CreatedAt": "Timestamp", "UpdatedAt": "Timestamp", "Name": "UserName", "Apikey": "ApiKey" }
-
Create Feed
POST /v1/feeds- Requires Authentication
- Request Body:
{ "name": "Feed Name", "url": "Feed URL" } - Response:
{ "ID": "UUID", "Name": "Feed Name", "Url": "Feed URL", "CreatedAt": "Timestamp", "UpdatedAt": "Timestamp", "UserID": "UUID" }
-
Follow Feed
POST /v1/feed_follows- Requires Authentication
- Request Body:
{ "feed_id": "FeedID" } - Response:
{ "id": "UUID", "feed_id": "FeedID", "user_id": "UserID", "created_at": "Timestamp", "updated_at": "Timestamp" }
Authentication is handled using JWT tokens. The token is provided upon user registration and must be included in the Authorization header for authenticated endpoints.
-
Fork the Repository
git clone https://github.com/yourusername/blog-aggregator.git cd blog-aggregator -
Create a Feature Branch
git checkout -b feature/your-feature-name
-
Commit Your Changes
git commit -m "Description of your changes" -
Push to the Branch
git push origin feature/your-feature-name
-
Create a Pull Request
Open a pull request on GitHub and provide a detailed description of your changes.