# Owly News Summariser

Owly News Summariser is a web application that fetches news articles from various RSS feeds, uses an LLM (Large Language Model) to summarize them, and presents them in a clean, user-friendly interface.

## Features

- Fetches news from configurable RSS feeds
- Automatically summarizes articles using Ollama LLM
- Filters news by country
- Progressive Web App (PWA) support for offline access
- Scheduled background updates

## Project Structure

The project consists of two main components:

- **Backend**: A FastAPI application that fetches and processes news feeds, summarizes articles, and provides API endpoints
- **Frontend**: A Vue.js application that displays the news and provides a user interface for managing feeds

## Prerequisites

- Python 3.8+ for the backend
- Node.js 16+ and Yarn for the frontend
- [Ollama](https://ollama.ai/) for article summarization

## Installing Yarn

Yarn is a package manager for JavaScript that's required for the frontend. Here's how to install it:

### Using npm (recommended)

If you already have Node.js installed, the easiest way to install Yarn is via npm:

```bash
npm install -g yarn
```

### Platform-specific installations

#### Windows

- **Using Chocolatey**: `choco install yarn`
- **Using Scoop**: `scoop install yarn`
- **Manual installation**: Download and run the [installer](https://classic.yarnpkg.com/latest.msi)

#### macOS

- **Using Homebrew**: `brew install yarn`
- **Using MacPorts**: `sudo port install yarn`

#### Linux

- **Debian/Ubuntu**:
  ```bash
  curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
  echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  sudo apt update && sudo apt install yarn
  ```

- **CentOS/Fedora/RHEL**:
  ```bash
  curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
  sudo yum install yarn
  ```

- **Arch Linux**: `pacman -S yarn`

After installation, verify Yarn is installed correctly:

```bash
yarn --version
```

## Setup

### Backend Setup

1. Navigate to the backend directory:
   ```bash
   cd backend
   ```

2. Create a virtual environment:
   ```bash
   python -m venv venv
   source venv/bin/activate  # On Windows: venv\Scripts\activate
   ```

3. Install dependencies:
   ```bash
   pip install -r requirements.txt
   ```

4. Create a `.env` file based on the example:
   ```bash
   cp example.env .env
   ```

5. Customize the `.env` file as needed:
   - `OLLAMA_HOST`: URL for the Ollama service (default: http://localhost:11434)
   - `CRON_HOURS`: Interval for scheduled news fetching (default: 1)
   - `DATABASE_URL`: SQLite database connection string

### Frontend Setup

1. Navigate to the frontend directory:
   ```bash
   cd frontend
   ```

2. Install dependencies:
   ```bash
   yarn
   ```

## Running the Application

### Running the Backend

1. Navigate to the backend directory:
   ```bash
   cd backend
   ```

2. Activate the virtual environment:
   ```bash
   source venv/bin/activate  # On Windows: venv\Scripts\activate
   ```

3. Start the backend server:
   ```bash
   uvicorn app.main:app --reload
   ```

   The backend will be available at http://localhost:8000

### Running the Frontend

1. Navigate to the frontend directory:
   ```bash
   cd frontend
   ```

2. Start the development server:
   ```bash
   yarn dev:watch
   ```

   The frontend will be available at http://localhost:5173

## Building for Production

### Building the Backend

The backend can be deployed as a standard FastAPI application. You can use tools like Gunicorn with Uvicorn workers:

```bash
pip install gunicorn
gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker
```

### Building the Frontend

1. Navigate to the frontend directory:
   ```bash
   cd frontend
   ```

2. Build the frontend:
   ```bash
   yarn build
   ```

   The built files will be in the `dist` directory and can be served by any static file server.

## API Endpoints

The backend provides the following API endpoints:

- `GET /news`: Get news articles with optional filtering
- `GET /meta/last_sync`: Get the timestamp of the last feed synchronization
- `POST /meta/cron`: Set the schedule for automatic feed synchronization
- `GET /meta/feeds`: List all configured feeds
- `POST /meta/feeds`: Add a new feed
- `DELETE /meta/feeds`: Delete a feed
- `GET /meta/model`: Check the status of the LLM model
- `POST /meta/sync`: Manually trigger a feed synchronization

## Environment Variables

### Backend

- `OLLAMA_HOST`: URL for the Ollama service
- `CRON_HOURS`: Interval for scheduled news fetching in hours
- `DATABASE_URL`: SQLite database connection string

## License

Code ist unter der [PolyForm Noncommercial 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0/) lizenziert. Für jegliche kommerzielle Nutzung bitte Kontakt aufnehmen.
