Skip to main content

user-registration-fastapi

FastAPI integration for the user-registration Python package.

This package provides FastAPI-specific request/response models, dependency integration, and HTTP exception handling while keeping the core registration business logic framework-independent.

Features

  • FastAPI registration endpoint integration
  • Pydantic request and response models
  • Dependency injection for RegistrationService
  • HTTP 201 Created for successful registration
  • HTTP 409 Conflict for duplicate users
  • HTTP 422 Unprocessable Entity for request/validation errors
  • HTTP 500 Internal Server Error for persistence failures
  • Compatible with the framework-agnostic user-registration package

Installation

Install the core package and FastAPI adapter:

pip install user-registration user-registration-fastapi

Or install the adapter directly:

pip install user-registration-fastapi

The adapter declares user-registration and fastapi as dependencies.

Basic Usage

The adapter exposes a FastAPI router that delegates registration to the core RegistrationService.

A typical application structure can look like:

my_app/
├── main.py
├── dependencies.py
└── ...

Example:

from fastapi import FastAPI

from user_registration_fastapi import router

app = FastAPI()

app.include_router(router)

The registration endpoint is:

POST /users/register

Example request:

{
  "username": "test",
  "email": "test@example.com",
  "password": "SecurePassword123!"
}

Example successful response:

{
  "user_id": "550e8400-e29b-41d4-a716-446655440000"
}

The response contains the ID assigned to the newly registered user.

Dependency Injection

The adapter intentionally does not create a database repository or application-specific RegistrationService automatically.

Instead, the application configures the service and provides it through FastAPI dependency injection.

Conceptually:

from fastapi import Depends


def get_registration_service() -> RegistrationService:
    return registration_service

The adapter then uses the configured service when handling:

POST /users/register

This keeps application infrastructure outside the adapter.

For example:

FastAPI
   │
   ▼
user-registration-fastapi
   │
   ▼
RegistrationService
   │
   ├── PasswordHasher
   ├── PasswordValidator
   ├── UserRepository
   └── ValidationRegistry

HTTP Behavior

The adapter translates domain/application results into HTTP responses.

Condition HTTP Status
Registration successful 201 Created
Invalid request/validation 422 Unprocessable Entity
Duplicate username/email 409 Conflict
Persistence/application failure 500 Internal Server Error

The adapter does not contain the registration business rules themselves. Those remain in user-registration.

Architecture

The package follows an adapter architecture:

                FastAPI Application
                        │
                        ▼
            user-registration-fastapi
                        │
                        ▼
              RegistrationService
                        │
             ┌──────────┼──────────┐
             ▼          ▼          ▼
        Validation   Password    Repository
         Registry     Hasher      Protocol
                                    │
                                    ▼
                            Application Storage

The repository implementation can be supplied by another adapter, such as:

user-registration-sqlalchemy

or by an application's own repository implementation.

Testing

From the repository root:

.venv/bin/python -m pytest tests/integration/test_fastapi_registration.py -v

Run the complete test suite:

.venv/bin/python -m pytest -v

Development

Install the adapter in editable mode:

.venv/bin/python -m pip install -e "./adapters/fastapi[dev]"

Run Ruff:

.venv/bin/python -m ruff check adapters/fastapi

Check formatting:

.venv/bin/python -m ruff format --check adapters/fastapi

Run MyPy:

.venv/bin/python -m mypy adapters/fastapi

Compatibility

The adapter requires:

  • Python 3.12+
  • FastAPI >=0.115,<1.0
  • user-registration >=0.1.0,<1.0.0

Core package:

SQLAlchemy adapter:

License

MIT License.

Visit https://github.com/ShamimurRahmanShuvo/user_registration/tree/main/docs for more detials.

Metadata

Release files for user-registration-fastapi 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for user-registration-fastapi 1.0.0
File Size Uploaded
user_registration_fastapi-1.0.0.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for user-registration-fastapi 1.0.0
File Interpreter ABI Platform
user_registration_fastapi-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / user_registration_fastapi-1.0.0.tar.gz

Download URL user_registration_fastapi-1.0.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7d50101ebd6b13f810bbf69b4afbf9eb869df7cd83b93776492fc54e7aba52d2
BLAKE2b-256 checksum
How to use checksums
75749f0b73ce1f068943dd1cdae3083f24a4ff4e0c974fd3198e63c50bf3d1cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / user_registration_fastapi-1.0.0-py3-none-any.whl

Download URL user_registration_fastapi-1.0.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
371982e162ca84c5ca5779bc88f30dd5e36bfbb34e65197bdd2ec067adeb186c
BLAKE2b-256 checksum
How to use checksums
fc44f64ae52a499e69e98a53f6196321d12b69f76de3161a5b25e98dc5146660
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.1

2 release files

This release

1.0.0 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page