
- 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
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
-
Clone the repository
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
# Required for fetching news from Mediastack API MEDIASTACK_API_KEY=your_api_key_here
-
Run database migrations:
alembic upgrade head
-
Start the server:
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 endpointsapp/core
: Core functionality (config, security, utils)app/db
: Database connection and sessionapp/models
: SQLAlchemy modelsapp/schemas
: Pydantic schemas for validationapp/services
: Business logic servicesmigrations
: Database migrations
Access Model
This application uses an open access model without authentication:
-
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.
-
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:
ruff check .
To fix linting issues automatically:
ruff check --fix .