Skip to content

Nottezz/fastapi-url-shortener

Repository files navigation

URL Shortener

A service for creating short links.

Python checks 🐍 codecov FastAPI Python version mypy: strict code style: ruff uv: managed

🧑‍💻 Getting Started

🛠️ Setup

  1. Clone the repository:
    git clone https://github.com/Nottezz/fastapi-url-shortener.git
    cd url_shortener
    
    
  2. Mark the url_shortener directory as "Sources Root" in your IDE (for better imports).

📦 Install Dependencies

Use uv to install packages:

uv install

⚙️ Configure Pre-commit Hooks

Install and activate pre-commit:

pre-commit install

This ensures formatting, linting, and other checks before each commit.


🚀 Run Development Server

  1. Ensure you're in the working directory:

    cd url_shortener
  2. Make sure Redis is running:

    docker run -d -p 6379:6379 redis
  3. Start the FastAPI dev server:

    fastapi dev

The server will be available at http://localhost:8000.


✅ Running Tests

  1. Make sure that the Redis test container is running.:

    docker run -d -p 6380:6380 redis
  2. Set env variables: REDIS_PORT=6380;TESTING=1

  3. Run the test suite:

    pytest

👨‍🔧 For Developers

  • Use a virtual environment (uv, venv, or poetry) 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.

About

A service for creating short links.

Resources

Stars

Watchers

Forks

Languages