Skip to content

lucasbbs/news_aggregator_backend

Repository files navigation

The NewsHubConnect Backend

License

Description

The news aggregator is a powerful platform that brings together news from popular sources such as the New York Times, The Guardian, and News API. With its user-friendly interface and advanced search capabilities, users can easily explore a vast collection of news articles, tailored to their preferences.

The platform offers two main features:

  1. Comprehensive News Search: Users can perform searches across multiple news sources, including the New York Times, The Guardian, and News API. The search functionality allows users to refine their results by specifying categories and keywords. This empowers users to find the most relevant and up-to-date news articles that align with their interests.

  2. Personalized User Experience: The news aggregator also provides a personalized experience by allowing users to register and save their preferences in the database. By registering an account, users can define their preferred categories, keywords, or topics of interest. Based on their saved information, the platform filters and presents news articles that are most likely to resonate with their individual preferences.

  3. RSS Feed: By leveraging the RSS feeds from Wall Street Journal, CBS, BBC, NPR, and New York Times, users can access a comprehensive range of news content conveniently from a single platform.

Prerequisites

Technologies Used

  • Laravel: A popular PHP framework for building robust and scalable web applications.
  • Laravel Sail: A lightweight Docker development environment for Laravel applications, providing a consistent and reproducible development environment.
  • PHP: The server-side scripting language used by Laravel for processing backend logic.
  • MySQL: A popular relational database management system used for storing and retrieving data.
  • Eloquent ORM: The database abstraction layer provided by Laravel, simplifying database operations and interactions.
  • API Authentication with Sanctum: Laravel Sanctum provides a lightweight and easy-to-use token-based authentication system for securing the API endpoints.
  • Composer: A dependency management tool for PHP, used to manage and install the required packages and libraries for the Laravel project.

Getting Started

These instructions will help you get a copy of the project up and running on your local machine for testing purposes.

Installation

To set up and run the backend project locally using Docker, follow these steps:

  1. Clone the repository from GitHub to your local machine.
git clone https://github.com/lucasbbs/news_aggregator_challenge_backend.git
  1. Change directory into the newly created folder.
cd news_aggregator_challenge_backend
  1. Install all required dependencies
./vendor/bin/sail up
  1. Run migrations for database
./vendor/bin/sail artisan migrate
  1. Run database seeder
./vendor/bin/sail artisan db:seed

API Reference

User Endpoints

Get User Details

GET /user

Update Password

PUT /user/password

Update Name

PUT /user/name

User Login

POST /auth/login

User Registration

POST /auth/register

User Logout

POST /auth/logout

News Endpoints

Get Latest News

GET /news/latest

Get New York Times News

GET /news/nytimes
Query Parameters Type Description
keyword string Search news articles containing the specified keyword.
begin_date string format: date Filter news articles with a publish date greater than or equal to the specified begin date.
end_date string format: date Filter news articles with a publish date less than or equal to the specified end date.
category string Filter news articles by category.
source string Filter news articles by source. Possible values: [list of available sources].
page number Specify the page number of the results. Default: 1.
sort string Sort the news articles by a specific criterion. Possible values: [list of available sources].
search boolean Determine if the query will be used to handle a search instead of feed. Default: false.

Get The Guardian News

GET /news/guardian
Query Parameters Type Description
keyword string Search news articles containing the specified keyword.
begin_date string format: date Filter news articles with a publish date greater than or equal to the specified begin date.
end_date string format: date Filter news articles with a publish date less than or equal to the specified end date.
category string Filter news articles by category.
page number Specify the page number of the results. Default: 1.
sort string Sort the news articles by a specific criterion. Possible values: [list of available sources].
search boolean Determine if the query will be used to handle a search instead of feed. Default: false.

Get NewsAPI News

GET /news/newsapi
Query Parameters Type Description
keyword string Search news articles containing the specified keyword.
begin_date string format: date Filter news articles with a publish date greater than or equal to the specified begin date.
end_date string format: date Filter news articles with a publish date less than or equal to the specified end date.
page number Specify the page number of the results. Default: 1.
sort string Sort the news articles by a specific criterion. Possible values: [list of available sources].
search boolean Determine if the query will be used to handle a search instead of feed. Default: false.

Sources Endpoints

Get All Sources

Retrieve a list of news sources and their categories.

GET /sources

Get User's Favorite Sources

Retrieve the favorite source categories of the authenticated user.

GET /sources/favorites

Favorites Endpoints

Add User's Favorite News

Add a news category to the authenticated user's favorites.

POST /favorites/user-favorites

Tags Endpoints

Get All Tags

Retrieve a list of all the tags a user has saved.

GET /tags

Create a Tag

Create a new tag for the authenticated user.

POST /tags

Delete a Tag

Delete a tag by its ID.

DELETE /tags/{id}

Settings Endpoints

Get User Settings

Retrieve the settings of the authenticated user.

GET /settings

Update User Settings

Update the settings of the authenticated user.

POST /settings

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published