The data layer for async FastAPI microservices: Django-style models, transactional outbox, caching, and ClickHouse - built on SQLAlchemy 2.0
Project description
alchemiq
The data layer for async FastAPI microservices: Django-style models, transactional outbox, caching, and ClickHouse - built on SQLAlchemy 2.0.
30-second example
import alchemiq
from alchemiq import Model, Repository
from alchemiq.types import PK, Email
class User(Model):
id: PK[int]
name: str
email: Email
alchemiq.configure("postgresql+asyncpg://user:password@localhost/mydb")
await alchemiq.create_all()
users = Repository(User)
user = await users.create(name="Ada Lovelace", email="ada@example.com")
found = await users.get(id=user.id)
print(found.name) # Ada Lovelace
Features
- Async PostgreSQL and ClickHouse - a single query DSL covers both backends.
- Django-flavoured models - declare fields with plain type annotations;
Qobjects,QuerySetchaining,order_by,limit, andoffsetwork exactly as you would expect. - Repository + UnitOfWork - full CRUD, bulk operations, cursor/keyset pagination, and
aggregations (
Count,Sum,Avg,Min,Max) out of the box. - Soft-delete and optimistic locking - opt in per model via a
Metaclass. - Signals - async pre/post hooks for create, update, and delete lifecycle events.
- Serialization -
to_dict,to_schema,to_pydanticwith field inclusion/exclusion. - Outbox + Relay - atomic event capture in the same transaction, published to any broker (RabbitMQ, Kafka, NATS) via TaskIQ or FastStream.
- FastAPI integration - auto-generated CRUD router, DI-ready repository and UoW providers,
Pydantic schema generation, and a
/health/ready·/health/liverouter. - FastStream consumer DI - inject sessions, UoW, and repositories into message handlers.
- Redis caching - per-repository cache with automatic invalidation on write.
- Migrations - Alembic wrapper for PostgreSQL; a custom engine for ClickHouse.
- Scaffolding -
alchemiq initgenerates a production-ready layered project skeleton.
Installation
pip install "alchemiq[all]"
| Extra | Installs |
|---|---|
email |
email-validator |
phone |
phonenumbers |
argon2 |
argon2-cffi |
bcrypt |
bcrypt (not in all) |
crypto |
cryptography |
outbox |
taskiq, taskiq-aio-pika |
fastapi |
fastapi |
faststream |
faststream |
redis |
redis |
postgres |
asyncpg (the PostgreSQL driver) |
clickhouse |
clickhouse-connect[async], clickhouse-sqlalchemy |
migrations |
alembic |
all |
all of the above except bcrypt |
Documentation
Full guide and API reference: https://alchemiq.readthedocs.io
Links
- Source: https://github.com/TrifoN-off/alchemiq
- Changelog: CHANGELOG.md
- License: MIT - see LICENSE
What's not in v1
alchemiq v1 does not include a visual admin, MySQL/SQLite support, synchronous mode,
multi-database routing, audit logs, geolocation fields, or file-field storage adapters.
See the What's not in v1 guide for the full list and the reasoning behind each deferral.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alchemiq-0.1.0.tar.gz.
File metadata
- Download URL: alchemiq-0.1.0.tar.gz
- Upload date:
- Size: 438.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69326d4555668c39e13a8d6f5b0a5aaa76b5f4536d31cd2511e7265d5fa235f9
|
|
| MD5 |
c18b6e8d79c2b98bac77615d65215773
|
|
| BLAKE2b-256 |
926e4b466847f9a11b8686b4c0845f335440c70ef8b4f7bdd1cf5ffd50633cf1
|
Provenance
The following attestation bundles were made for alchemiq-0.1.0.tar.gz:
Publisher:
release.yml on TrifoN-off/alchemiq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alchemiq-0.1.0.tar.gz -
Subject digest:
69326d4555668c39e13a8d6f5b0a5aaa76b5f4536d31cd2511e7265d5fa235f9 - Sigstore transparency entry: 2074559817
- Sigstore integration time:
-
Permalink:
TrifoN-off/alchemiq@d088fb162f8fb127416330a3644c01856beb1fc3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/TrifoN-off
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d088fb162f8fb127416330a3644c01856beb1fc3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file alchemiq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: alchemiq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 183.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cb977290629b528a713ae3ab3fad25c4fd0c905d6af3e64a5175a31c3e76b1f
|
|
| MD5 |
0dd4f19183abaffdd5eb30019e787fd3
|
|
| BLAKE2b-256 |
a65efeaf29605360a0d7d23c5c5cad58bc5b16d75a25b8cb46cfd5214b3a1971
|
Provenance
The following attestation bundles were made for alchemiq-0.1.0-py3-none-any.whl:
Publisher:
release.yml on TrifoN-off/alchemiq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alchemiq-0.1.0-py3-none-any.whl -
Subject digest:
9cb977290629b528a713ae3ab3fad25c4fd0c905d6af3e64a5175a31c3e76b1f - Sigstore transparency entry: 2074559880
- Sigstore integration time:
-
Permalink:
TrifoN-off/alchemiq@d088fb162f8fb127416330a3644c01856beb1fc3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/TrifoN-off
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d088fb162f8fb127416330a3644c01856beb1fc3 -
Trigger Event:
push
-
Statement type: