Alpha
Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction.
Badges
TL;DR
Alpha provides a comprehensive set of tools for building Python applications that interact with APIs and databases, including API code generation, authentication and authorization, database access layers, error handling, logging, and more. It is designed to be the first dependency you add to your project, providing a solid foundation for your application's architecture.
Documentation
Full documentation is available at alpha-python.readthedocs.io.
Installation
The library is still in development, but you can already install it using pip:
pip install alpha-python
If you want to use the alpha cli for generating API code, you can install it using pip as well:
pip install alpha-python[api-generator]
If you want to add the library to your API project, you can add it to your pyproject.toml file:
# Poetry example
poetry add alpha-python --extras "flask, postgresql"
poetry add --dev alpha-python --extras "api-generator"
# UV example
uv add alpha-python --extra flask --extra postgresql
uv add --dev alpha-python --extra api-generator
Features
- API code generation
- Authentication and authorization
- Database interaction
- Logging
- Error handling
- And much more!
Usage
The library contains many components. Below are a few practical examples that map to the guides in the documentation.
1) API code generation using OpenAPI spec
alpha api gen --spec-file specification/openapi.yaml --service-package my_app
alpha api run --port 8080
2) Authenticate with Keycloak (OIDC)
from alpha import KeyCloakOIDCConnector, KeyCloakProvider, PasswordCredentials
keycloak_connector = KeyCloakOIDCConnector(
base_url="https://keycloak.example.com",
realm="myrealm",
client_id="myclient",
client_secret="myclientsecret",
)
keycloak_provider = KeyCloakProvider(connector=keycloak_connector)
credentials = PasswordCredentials(username="user1", password="user1_password")
identity = keycloak_provider.authenticate(credentials)
3) Query data using SqlAlchemyDatabase + SqlAlchemyRepository
from alpha import SqlAlchemyDatabase, SqlAlchemyRepository
from my_app import User
db = SqlAlchemyDatabase(conn_str="postgresql://user:password@localhost:5432/mydatabase")
with db.get_session() as session:
users = SqlAlchemyRepository[User](session=session, default_model=User)
user = users.get_by_id(1)
4) Use Unit of Work for transactional operations
from alpha import (
RepositoryModel,
SqlAlchemyDatabase,
SqlAlchemyRepository,
SqlAlchemyUnitOfWork,
)
from my_app import User, OrmMapper
db = SqlAlchemyDatabase(..., mapper=OrmMapper)
repositories = [
RepositoryModel(
name="users",
repository=SqlAlchemyRepository[User],
default_model=User,
)
]
uow = SqlAlchemyUnitOfWork(db=db, repos=repositories)
with uow:
user = uow.users.get_by_id(1)
See also:
- Design principles and patterns: https://alpha-python.readthedocs.io/en/latest/concepts/design-principles/
- Dependency injection concept: https://alpha-python.readthedocs.io/en/latest/concepts/dependency-injection/
- API code generation guide: https://alpha-python.readthedocs.io/en/latest/guides/api-generation/
- Authentication guide: https://alpha-python.readthedocs.io/en/latest/guides/authentication/
- Database interaction guide: https://alpha-python.readthedocs.io/en/latest/guides/database-interaction/
Contributing
If you want to contribute to the development of this library, you can fork the repository and create a pull request with your changes.
Support
If Alpha saves you time in production, consider supporting development by buying me a coffee! Your support helps me to continue improving the library and adding new features. Thank you!
License
This library is licensed under the MIT License. See the LICENSE file for more information.
Metadata
Release files for alpha-python 0.8.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| alpha_python-0.8.3.tar.gz | 134.0 kB | With provenance | Details for alpha_python-0.8.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| alpha_python-0.8.3-py3-none-any.whl | Python 3 | none | any | Details for alpha_python-0.8.3-py3-none-any.whl |
Total release size: 314.9 kB
Release files / alpha_python-0.8.3.tar.gz
| Download URL | alpha_python-0.8.3.tar.gz |
|---|---|
| Size | 134.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bd169510abd0c7012f227ec60ee14a99a361eb7852c0f878dbc25d23f0e2561
|
|
BLAKE2b-256 checksum How to use checksums |
baa5dbcd3b1a81afcb63a5807f16512a7b37c83fa10c67193f61a69313a38ecc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 5, 2026.
Transparency logRelease files / alpha_python-0.8.3-py3-none-any.whl
| Download URL | alpha_python-0.8.3-py3-none-any.whl |
|---|---|
| Size | 180.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aef67ca364782e7414f750119b71432ea63bc97de70bce4b97499b6c64b01370
|
|
BLAKE2b-256 checksum How to use checksums |
42dc738d5eee4ab44af40c47ae463663bc22fb13ae52c596743f8f110035eb31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 5, 2026.
Transparency logSecurity for alpha-python 0.8.3
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for alpha_python-0.8.3.tar.gz
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 Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.