Skip to content

About

FastAPI-based authentication service coded from scratch as a learning project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Auth Service

FastAPI-based authentication service with async SQLAlchemy, Redis-backed token controls, and Celery-powered email tasks.

For architecture and workflow deep dives, see TECHNICAL.md.

Features

  • User registration and login
  • Access + refresh token flow
  • Token refresh and logout with blacklist support
  • Email verification and password reset workflows
  • Request-id, timing, error handling, and rate-limiting middleware

Tech Stack

  • Python 3.14+
  • FastAPI
  • SQLAlchemy (async) + asyncpg
  • Redis (async + sync client)
  • Celery
  • Alembic
  • Pytest + pytest-asyncio
  • Ruff (lint + format)

Project Structure

  • app/main.py - FastAPI app entrypoint
  • app/api/v1/ - versioned API routers
  • app/services/ - business logic
  • app/repositories/ - data access layer
  • app/models/ - SQLAlchemy models
  • app/dependencies/ - DI providers for DB/auth/redis
  • app/middleware/ - error/timing/request-id/rate-limit middleware
  • app/tasks/ - Celery task definitions
  • alembic/ - database migrations
  • tests/ - async API/integration tests

Quick Start

  1. Install dependencies:
uv sync
  1. Start local services:
docker compose up -d
  1. Run migrations:
uv run alembic upgrade head
  1. Run API:
uv run uvicorn app.main:app --reload
  1. (Optional) Run worker:
uv run celery -A app.celery_app worker --queues=critical,default --loglevel=info

Development Commands

  • Lint: uv run ruff check .
  • Format: uv run ruff format .
  • Compile check: uv run python -m compileall app tests
  • Run all tests: uv run pytest -q
  • Run test for one file: uv run pytest tests/test_login.py
  • Run test for one test: uv run pytest tests/test_login.py::test_login_success

Health Endpoint

  • GET /health

API Prefix

  • All API routes are mounted under: /api/v1

Notes

  • Configuration is managed in app/core/config.py via environment variables.
  • Local development values can be provided using .env.

About

FastAPI-based authentication service coded from scratch as a learning project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages