This release is a pre-release and may not be stable for production use.
Status: alpha (0.1.0a3). The API may change before 0.1.
pip install --pre django-neolith
What it is
Neolith makes the Django app, not the Django project, the unit of deployment. An app can run inside a shared process or on its own as a service, with its models, migrations, admin and tests intact, and without changing its code. Apps talk to each other only through typed contracts, so the same code and the same tests hold in both arrangements. Neolith is defined by a specification that is independent of Django and of Python, and django-neolith is its reference implementation.
Features
What this version does. The changelog has the details.
- Typed contracts. A contract is a
Protocolclass with@contractand@action, and an implementation is marked with@implements. Request and reply types are Pydantic models in a portable type system, and every check runs when the module is imported. - Typed errors.
ContractErrorcarries akind, a message and a detail. An action can declare its own error kinds with their detail records. - Calls cross as JSON, in-process too. Every request, reply and error detail is written and read through its declared type, so an in-process call carries exactly what a remote one will.
- App declaration. An app declares what it provides, requires and owns on its
NeolithAppConfig, and the declaration is checked when the class is defined. - Checks before serving. At start-up the host resolves every required contract to a provider and validates each implementation, listing every refusal in one error; once those pass, it runs its system checks on the settings and reports all their errors together.
- One database per app.
neolith.routers.AppRouterkeeps each app's data on a database alias of its own. - Call context. A principal, a trace, a deadline and the calling app travel with each call. A root is opened for each request by
RootMiddleware, and for a command or background work bycommand_scope. - Request principal.
NEOLITH["PRINCIPAL_BACKENDS"]lists ordered principal backends, such asneolith.principals.DjangoUserBackendfor the logged-in Django user. They name who a request is for, andPrincipalMiddlewarefixes that principal for the request's calls. - HTTP transport.
NEOLITH["REMOTE_PROVIDERS"]names a provider that another host serves, and a connector then sends that contract's calls over HTTP with a token signed by the calling app's key inNEOLITH["SIGNING_SECRETS"]. The host serves its own contract endpoints, names the app that calls them throughNEOLITH["CALLER_BACKENDS"], and serves an OpenAPI 3.1.2 document at/.well-known/neolith/openapi.json; the client uses only the standard library. local-firstrouting.NEOLITH["ROUTING_POLICIES"]can namelocal-firstfor a contract version with two or more providers, tried in order; an idempotent call moves to the next onunavailable, within its one deadline.- Conformance suite. Spec 06's suite runs each contract case over the in-process and the HTTP transports and checks that they give one outcome.
- One app alone.
neolith run <app>boots apps from their declarations and serves them, andneolith migrate <app>applies each app's migrations to its own database.
Not yet in this version: the boundary check (neolith check) and events. See the roadmap below.
A short example
A contract, in a contract package other apps may import:
# inventory/contracts.py
from typing import Protocol
from pydantic import BaseModel
from neolith import action, contract
class ReserveRequest(BaseModel):
sku: str
qty: int
class ReserveReply(BaseModel):
reserved: int
@contract("inventory.v1")
class Inventory(Protocol):
@action(idempotent=True)
def reserve(self, request: ReserveRequest) -> ReserveReply: ...
Its implementation, private to the app that provides it:
# inventory/services.py
from neolith import CallContext, implements
from inventory.contracts import Inventory, ReserveReply, ReserveRequest
@implements(Inventory)
class InventoryService:
def reserve(self, request: ReserveRequest, ctx: CallContext) -> ReserveReply:
return ReserveReply(reserved=request.qty)
The two apps' declarations:
# inventory/apps.py
from neolith import NeolithAppConfig, Provided
from inventory.contracts import Inventory
class InventoryConfig(NeolithAppConfig):
name = "inventory"
label = "inventory"
provides = (
Provided(
Inventory,
implementation="inventory.services.InventoryService",
principal_from=("shop",), # apps that may pass a principal on their calls
),
)
# shop/apps.py
from neolith import NeolithAppConfig
from inventory.contracts import Inventory
class ShopConfig(NeolithAppConfig):
name = "shop"
label = "shop"
requires = (Inventory,)
And a call from the shop app, which knows the contract and nothing else of inventory:
# shop/orders.py
from neolith import ContractError, connect
from inventory.contracts import ReserveRequest
inventory = connect("inventory.v1")
def place_order(sku: str, qty: int) -> int:
try:
reply = inventory.reserve(ReserveRequest(sku=sku, qty=qty))
except ContractError as error:
print(error.kind) # "unavailable", "conflict", ...
raise
return reply.reserved
The settings, beside the project's usual ones such as SECRET_KEY. They end with the host's builder, which builds INSTALLED_APPS, DATABASES and DATABASE_ROUTERS from the apps' declarations and NEOLITH, and checks the rest before the host serves:
# settings.py
from neolith.host import build_settings
MIDDLEWARE = [
"neolith.middleware.RootMiddleware", # first, and listed once
"neolith.middleware.PrincipalMiddleware", # listed once
]
NEOLITH = {}
globals().update(build_settings(["inventory", "shop"], globals()))
With these, a view in the shop app can call place_order directly; a command opens its root first, with neolith.command_scope("shop"). A test runs every Python block on this page under these settings.
To run apps without a project, put the deployer's names (SECRET_KEY, MIDDLEWARE, ROOT_URLCONF, NEOLITH and the rest) in a module that does not call the builder, then apply the migrations and serve:
$ neolith migrate inventory shop --settings deploy
$ neolith run inventory shop --settings deploy --bind 127.0.0.1:8000
neolith run uses Django's development server, which is not for production; in production, serve a settings module like the one above with any WSGI or ASGI server. On SIGINT or SIGTERM it stops taking requests and gives each request in flight until NEOLITH["REQUEST_DEADLINE"], or 30 seconds when that is None. Under another server, give its graceful shutdown a timeout no shorter than the request deadline. In a host built by a settings module, manage.py migrateapps is the migrate step, and manage.py migrateapps --check reports what the host would refuse at start-up.
Roadmap
The steps to 0.1 are in the roadmap.
Links
- Vision
- Specification (draft 0.1)
- Roadmap to 0.1
- Guiding principles
- Architecture decision records
- Open questions
- Contributing
- Code of conduct
Licensed under the BSD 3-Clause License.
Metadata
Release files for django-neolith 0.1.0a3
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 |
|---|---|---|---|---|
| django_neolith-0.1.0a3.tar.gz | 1.2 MB | With provenance | Details for django_neolith-0.1.0a3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_neolith-0.1.0a3-py3-none-any.whl | Python 3 | none | any | Details for django_neolith-0.1.0a3-py3-none-any.whl |
Total release size: 1.4 MB
Release files / django_neolith-0.1.0a3.tar.gz
| Download URL | django_neolith-0.1.0a3.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
791c55e96d216c67cd1aba14e9acf800ca6f7dc81f06d4328bc85eaa79965bdb
|
|
BLAKE2b-256 checksum How to use checksums |
fdba2021bb9dbac173bbaa4c65bc3cddb8dd6ce65964ea2b39876dc3abc6a3f3
|
| 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 19, 2026.
Transparency logRelease files / django_neolith-0.1.0a3-py3-none-any.whl
| Download URL | django_neolith-0.1.0a3-py3-none-any.whl |
|---|---|
| Size | 235.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43db49091eb2cd04b8eed19680adb9129b0ceb6cd8a9033e0bb57517200d6d69
|
|
BLAKE2b-256 checksum How to use checksums |
0d8724cc585e11db9d4607dc40362bad6d0caba47bc811f8622b27fa4ad0a5eb
|
| 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 19, 2026.
Transparency logSecurity for django-neolith 0.1.0a3
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 django_neolith-0.1.0a3.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 19, 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.