
- Replace authentication system with automatic default user creation - Update all API endpoints to work without authentication - Modify user endpoints to work with default user - Update README.md to reflect the open access model - Fix linting issues and ensure code quality
93 lines
2.6 KiB
Markdown
93 lines
2.6 KiB
Markdown
# News Aggregation Service
|
|
|
|
A FastAPI application that aggregates news from various sources using the Mediastack API.
|
|
|
|
## Features
|
|
|
|
- Open API access without authentication
|
|
- News article fetching and storage from Mediastack API
|
|
- Filtering news by keywords, sources, categories, countries, and languages
|
|
- User preferences for personalized news
|
|
- Save articles for later reading
|
|
- Background tasks for periodic news updates
|
|
|
|
## Tech Stack
|
|
|
|
- **FastAPI**: High-performance web framework
|
|
- **SQLite**: Database for storing news articles and user data
|
|
- **SQLAlchemy**: ORM for database interactions
|
|
- **Alembic**: Database migration tool
|
|
- **Pydantic**: Data validation and settings management
|
|
|
|
## Requirements
|
|
|
|
- Python 3.8+
|
|
- Mediastack API key (required for fetching news data)
|
|
|
|
## Setup
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
3. Set up environment variables:
|
|
```
|
|
# Required for fetching news from Mediastack API
|
|
MEDIASTACK_API_KEY=your_api_key_here
|
|
```
|
|
|
|
4. Run database migrations:
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
5. Start the server:
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
The API is documented with Swagger UI, available at `/docs` when the server is running.
|
|
|
|
### Main Endpoints
|
|
|
|
- `/api/v1/users/default`: Get the default user for open API access
|
|
- `/api/v1/news`: Get news articles with optional filtering
|
|
- `/api/v1/news/personalized`: Get personalized news based on user preferences
|
|
- `/api/v1/news/refresh`: Fetch fresh news from Mediastack API
|
|
- `/api/v1/news/saved`: Save or retrieve articles for later reading
|
|
- `/health`: Health check endpoint
|
|
|
|
## Project Structure
|
|
|
|
- `app/api`: API routes and endpoints
|
|
- `app/core`: Core functionality (config, security, utils)
|
|
- `app/db`: Database connection and session
|
|
- `app/models`: SQLAlchemy models
|
|
- `app/schemas`: Pydantic schemas for validation
|
|
- `app/services`: Business logic services
|
|
- `migrations`: Database migrations
|
|
|
|
## Access Model
|
|
|
|
This application uses an open access model without authentication:
|
|
|
|
1. **Mediastack API Key**: The only key required is for the external Mediastack news API service. This key is used to fetch news data and must be provided in the MEDIASTACK_API_KEY environment variable.
|
|
|
|
2. **Default User**: The application automatically creates and uses a default user for all operations that would normally require authentication. This makes it easy to use the API without needing to create accounts or manage tokens.
|
|
|
|
## Development
|
|
|
|
To run linting checks:
|
|
|
|
```bash
|
|
ruff check .
|
|
```
|
|
|
|
To fix linting issues automatically:
|
|
|
|
```bash
|
|
ruff check --fix .
|
|
``` |