This is a test project, that implements an asynchronous API service that:
- Provides an authenticated FastAPI endpoint to query Tao dividends from the Bittensor blockchain
- Caches blockchain query results in Redis for 2 minutes
- Optionally triggers background stake/unstake operations based on Twitter sentiment:
- Queries Twitter via Datura.ai API for tweets about the subnet
- Analyzes tweet sentiment using Chutes.ai LLM
- Stakes or unstakes TAO proportional to sentiment score (-100 to +100)
- Uses Celery workers to handle async blockchain and sentiment analysis tasks
- Stores historical data in a high-concurrency asynchronous database
The architecture follows modern async patterns:
- FastAPI handles HTTP requests
- Redis serves as cache and message broker
- Celery workers process background tasks
- Async database stores results
- Docker containers orchestrate all components
- Clone it
git clone git@github.com:Kulv3r/fast-api-task.git - Do
cp .env_example .envand update API keys and secrets (if needed) there - Run it:
docker-compose up - Do the DB migrations:
docker-compose run --rm backend alembic upgrade head - Check it at GET http://localhost:8000/api/v1/ping
- Docs:
- http://localhost:8000/redoc - ReDoc
- http://localhost:8000/docs - Swagger