Skip to content

anujgawde/newsread-server

Repository files navigation

NewsRead Server

The NewsRead Server is the backend service powering the NewsRead application. It is designed to handle news fetching, storage, and text-to-speech (TTS) functionality. This server interacts with the newsdata.io API for fetching news articles and leverages AWS Polly for generating audio files, ensuring a seamless and efficient experience for the user.

This server is essential for running the NewsRead application. To view the client-side code and integrate it with this backend, refer to the newsread repository.

Features 🚀

  • News Management:
    • Fetch and store the latest news articles.
    • Retrieve trending, latest, or specific articles.
  • Database Optimization:
    • Reduce API calls by efficiently storing fetched data in PostgreSQL.
  • Text-to-Speech (TTS):
    • Convert articles into audio using AWS Polly and stream it to users.
  • Trending Analytics:
    • Track and update article visits for ranking popular articles.

Installation & Setup ⚙️

Prerequisites

  • Node.js and npm installed.
  • Setup AWS Polly and AWS S3 enabled with appropriate access keys.

Steps

  1. Clone the Repository:

    git clone https://github.com/anujgawde/newsread-server  
    cd newsread-server 
    
  2. Install Dependencies:

    npm install 
    
  3. Set Environment Variables:
    Create a .env file in the root directory and configure the following variables:

    AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key  
    AWS_TTS_BUCKET_NAME=your_aws_s3_bucket_name  
    DB_URL=your_postgresql_connection_url  
    DB_NAME=your_database_name  
    DB_PASSWORD=your_database_password  
    NEWSDATA_API_KEY=your_newsdata_api_key 
    
  4. Run the Server:

    npm run start:dev 
    
  5. Test the API:
    The server runs at http://localhost:8001. Use tools like Postman or your browser to test endpoints.

API Endpoints 🛠️

  1. GET /articles/get-all-articles: Retrieve all stored articles
  2. GET /articles/get-latest-articles: Fetch and store the latest articles
  3. GET /articles/get-trending-articles: Retrieve trending articles based on visits
  4. GET /articles/:id: Retrieve a specific article by its ID
  5. POST /articles/read-article: Convert article content to audio and play it
  6. POST /articles/update-article-visits: Increment the visit count for an article

Tech Stack 🛠️

Roadmap 🗺️

  • Add API caching to reduce database queries.
  • Implement multi-language TTS support.
  • Enhance analytics for article performance.

Contributing 🤝

Contributions are welcome! Please open an issue or submit a pull request for suggestions or improvements.

Stay in touch

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published