API to manage RSS feeds.
- subscribe users
- follow/unfollow feeds
- mark feed items as read/unread
Background (scheduled) worker to fetch feeds items.
- Python 3.9 + FastAPI + pipenv
- OAuth2 authentication with user/password
- Docker container to run app and its deps
- MongoDB as the domain storage and tasks control
- Dramatiq to run the background workers
- Redis as dramatiq message broker
- Apscheduler for the task scheduling
- Pytest for integration tests
Application loads env vars from a .env
file in src/
folder.
Variable | Description | Example |
---|---|---|
FEEDS_UPDATE_INTERVAL | Interval in minutes to update feeds. | 15 |
JWT_SECRET | Secret to encrypt user passwords. | 26faa9...58d95d |
MONGO_URL | Database url. | mongodb://127.0.0.1:21017 |
MONGO_DB_NAME | Database name. | rss_reader |
TOKEN_EXPIRATION_MIN | Token expiration time in minutes. | 15 |
JWT_SECRET can be randomly generated with openssl.
$ openssl rand -hex 32
Use docker-compose to execute application and its dependencies altogether.
First go to src/
folder and create an updated requirements.txt
file.
$ pipenv lock -r > requirements.txt
Build and run.
$ docker-compose build
$ docker-compose up -d
Server URL:
Docs URL (OpenAPI):
Run mongo and redis in background.
$ docker-compose up -d mongo redis
Go to src/
folder, install all deps and run.
# on terminal 1
$ pipenv install --dev
$ pipenv run workers
# on terminal 2
$ pipenv run app
Go to src/
folder, install dev deps and run.
$ pipenv install --dev
$ pipenv run test
Static code analysis is made by pylint.
$ pipenv run lint
List of things that can be improved:
- Cache. To improve the performance of the API requests.
- Service layer. That layer would help to abstract a little bit more the logic present in routers.
- Pagination. To go through items listed from the database.
- DB transactions. Started to implement it, but left the initial code in a separate branch.
- Events-driven architecture. Might be useful, but will add substantial complexity.
- More tests. Especially for the background workers.
- Documentation. Code and system documentation.