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": "shuvo",
  "email": "shuvo@example.com",
  "password": "SecurePassword123!"
}

Example successful response:

{
  "id": "...",
  "username": "shuvo",
  "email": "shuvo@example.com"
}

The exact response fields depend on the adapter version and configured registration service.

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.

Release files for user-registration-fastapi 0.1.3

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 0.1.3
File Size Uploaded
user_registration_fastapi-0.1.3.tar.gz 3.5 kB Details

Built distribution (wheel)

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

Total release size: 8.3 kB

Release files / user_registration_fastapi-0.1.3.tar.gz

Download URL user_registration_fastapi-0.1.3.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
17fa74f152aa7ef9b1452ccb8a5d8381962c445677ccfd9f8cdc3a0104d269c2
BLAKE2b-256 checksum
How to use checksums
afd4fe4a32c891a54c0b3660cd7454d4d5cef175feaaa80675dc74e1042760b2
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 Sep 25, 2026.

Transparency log

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

Download URL user_registration_fastapi-0.1.3-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a177add6187d221be2e0e160a98f672db6564379d8fc07286d06708c3c1e5f6
BLAKE2b-256 checksum
How to use checksums
2764485e020a68f34af544bfe6cb76bacc613369592912d3f4bad1f2c850ec55
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 Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.3 This release

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