Aggregate, de-duplicate and republish RSS feeds.
The problem I'm solving here is this; if I subscribe to the main Guardian RSS feed, I see a great many articles I'm not interested in1. But if instead I subscribe to the feeds for individual tags, while I don't see the things I'm not interested in, I do see a great many duplicates - articles with multiple tags show up in multiple feeds. This little app allows me to have the best of both worlds - I can see only2 the articles I'm interested in my reader3, and only once.
Local development requires:
- uv for all things Python
- just as a task runner
- colima4 for running the docker images we need for our integration tests
Some tasks may require additional tools:
- gh for controlling GitHub actions
- 1Password CLI for secure secret usage
- AWS CLI for controlling & querying AWS
- terraform for deployment (version pinned in
.tool-versions) - libxml2 for testing our RSS output
- fzf and gum for command line shenanigans.
On a Mac, you can install most of these with homebrew and asdf.
brew install uv just gh 1password-cli awscli asdf colima libxml2 fzf gum # And follow any additional setup instructions brew gives you
brew install --cask terraform-linters/tap/tflint
asdf plugin add terraform
asdf installThe application is a Flask async web app deployed as an AWS Lambda function running within the Lambda Web Adapter.
Good places to start investigating the code are:
On each request, RSSService orchestrates the full pipeline:
- A FeedsService implementation reads a list of feed paths
and constructs full Guardian RSS URLs.
- FileFeedsService reads from from feeds.txt, OR
- S3FeedsService reads from an S3 object using boto3.
- Feeds may be commented out (by prefixing with a
#) - Feeds may be excluded (by prefixing with a
-). Items on these feeds will be excluded, even if they are also on an included feed.
- Fetcher retrieves all feeds concurrently using httpx2 with HTTP/2 and connection pooling.
- RSSParser parses the responses with defusedxml and de-duplicates items by GUID.
- RSSGenerator sorts by date, applies a configurable item limit, and emits a fresh RSS feed.
Services are wired together with wireup for dependency injection, with configuration sourced from environment variables as per the twelve-factor app. AWS API Gateway provides the public HTTP endpoint, backed by Terraform-managed infrastructure-as-code located in terraform/.
Configuration is sourced from environment variables:
| Variable | Description | Default |
|---|---|---|
FEEDS_SERVICE |
Feeds service implementation: FileFeedsService or S3FeedsService |
FileFeedsService |
FEEDS_FILE |
Path to the feeds list file (used by FileFeedsService) |
feeds.txt |
MAX_ITEMS |
Maximum number of items in the output feed | 50 |
MAX_CONNECTIONS |
Maximum number of concurrent HTTP connections | 16 |
MAX_KEEPALIVE_CONNECTIONS |
Maximum number of keep-alive HTTP connections | 16 |
KEEPALIVE_EXPIRY |
Keep-alive connection expiry in seconds | 5 |
RETRIES |
Number of HTTP retry attempts per feed | 3 |
TIMEOUT |
HTTP request timeout in seconds | 3 |
LOG_LEVEL |
Log verbosity: ERROR, WARNING, INFO, or DEBUG |
INFO |
The following are additionally required when FEEDS_SERVICE=S3FeedsService:
| Variable | Description | Default |
|---|---|---|
FEEDS_BUCKET_NAME |
S3 bucket name containing the feeds list | brunns-rss-agg-feeds |
FEEDS_OBJECT_NAME |
S3 object key for the feeds list | feeds.txt |
AWS_DEFAULT_REGION |
AWS region for S3 access | boto3 default |
AWS_ACCESS_KEY_ID |
AWS access key ID for S3 access | boto3 default |
AWS_SECRET_ACCESS_KEY |
AWS secret access key for S3 access | boto3 default |
S3_ENDPOINT |
Custom S3-compatible endpoint URL, e.g. for local testing | AWS S3 |
Development and build tasks can be run using just. To see available tasks, run:
just -lUse brunns-python-template or similar.