A service for creating short links.
- Clone the repository:
git clone https://github.com/Nottezz/fastapi-url-shortener.git cd url_shortener - Mark the
url_shortenerdirectory as "Sources Root" in your IDE (for better imports).
Use uv to install packages:
uv installInstall and activate pre-commit:
pre-commit installThis ensures formatting, linting, and other checks before each commit.
-
Ensure you're in the working directory:
cd url_shortener -
Make sure Redis is running:
docker run -d -p 6379:6379 redis
-
Start the FastAPI dev server:
fastapi dev
The server will be available at http://localhost:8000.
-
Make sure that the Redis test container is running.:
docker run -d -p 6380:6380 redis
-
Set env variables: REDIS_PORT=6380;TESTING=1
-
Run the test suite:
pytest
- Use a virtual environment (
uv,venv, orpoetry) to manage dependencies. - Follow PEP8 style guidelines (auto-enforced via
pre-commit). - Use descriptive commit messages (consider Conventional Commits).
- Document public endpoints and services clearly with docstrings and OpenAPI schemas.