App that fetchet tweets from Twitter and shows their basic statistics.
Background task fetches k
recent tweets by phrase
. Exposed API allows to see those tweets, their top hashtags,
top user who made max amount of tweets, total amount of recently fetched tweets.
- python 3.7
- postgres 11+
- redis
Background task performed with schedule
library,
which is lightweight and simple in comparison to celery
.
API is created with starlette
and hosted with uvicorn
All data for API responses is cached in redis.
- Clone repository
:$ git clone https://github.com/pgtuk/tweets.git
:$ cd tweets
- Create
.env
:$ cp .env.example .env
- Put your twitter consumer key to
TWITTER_CONSUMER_KEY
and secter toTWITTER_CONSUMER_SECRET
in.env
. Don't hesitate to change querying phrasePHRASE
, tweets countTWEETS_COUNT
and fetching intervalTIME_INTERVAL
. Check limits at Twitter API docs
:$ docker-compose up
Note: docker will run linters before starting app, but not tests - requires to add test database.
App will be available at '0.0.0.0:5000' by default
- If you want to run it locally you'll need python3.7,
postgres
andredis
. Set up databases for deployment and tests. Test DB name assumed to be same as deployment db's name prefixed withtest_
. - Set up python virtual enviroment and install package dependencies
$: python3.7 -m venv venv
$: venv/bin/pip install -r requirements.txt
- Use
make
to run linters, tests and app itself. Seemake help
for more information.