
- Fix code linting issues - Update README with detailed documentation - Configure database paths for the current environment - Create necessary directory structure The News Aggregation Service is now ready to use with FastAPI and SQLite.
2.0 KiB
2.0 KiB
News Aggregation Service
A FastAPI application that aggregates news from various sources using the Mediastack API.
Features
- User authentication and authorization
- 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
- JWT: Token-based authentication
Requirements
- Python 3.8+
- Mediastack API key
Setup
-
Clone the repository
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
MEDIASTACK_API_KEY=your_api_key_here SECRET_KEY=your_secret_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/register
: Register a new user/api/v1/users/token
: Login and get JWT token/api/v1/news
: Get news articles with optional filtering/api/v1/news/personalized
: Get personalized news based on user preferences/api/v1/news/saved
: Save 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
Development
To run linting checks:
ruff check .
To fix linting issues automatically:
ruff check --fix .