An implementation of a Twitter clone project from Redis docs using Python 3.13, FastAPI, Redis as a database and Keycloak as a separate auth service.
Contains a simple API for registering & authenticating users, following other users, adding and viewing posts, as well as users' feeds.
- Create virtual environment & install dependencies.
python -m venv venv --prompt "Redis + Keycloak tutorial"
source venv/bin/activate
pip install -r requirements.txt-
Add a project configuration file
config.yml(seeconfig.yml.example). -
Initialize Keycloak & Redis containers.
python src/container_cli.py run- Start development server.
fastapi dev src/app/main.pyTests are implemented with Pytest + xdist plugin and use development containers for creating temporary Redis databases & Keycloak realms.
Tests can be run using tests module.
# Run all tests
python -m tests
# Run tests in tests/tests/validation dir
python -m tests validationEach test file is executable and can be run on its own.
Keycloak and Redis containers can be created, started, stopped and removed with container CLI utility:
# Run or start existing containers
python src/container_cli.py run
# Stop existing containers
python src/container_cli.py stop
# Remove existing containers
python src/container_cli.py remove