nyxa
Standalone, convention-first backend framework for Python — AI-first.
Nyxa is a batteries-included async web framework: a compiled router, a
dependency-injection container, an ORM with migrations and seeding, a
provider/plugin system, an Artisan-style console, and a first-party
package ecosystem (nyxa-cache, nyxa-auth, nyxa-ai, …). Apps are
convention projects — nyxa.toml, config/, start/, app/ — that
boot through a provider lifecycle and serve over ASGI, RSGI, WSGI, or
the optional native Rust server.
Features
- Routing — ambient
routerproxy replayed into the app at boot:get/post/put/patch/delete, groups withprefix()/middleware(),resource(),view(),redirect(),fallback(), named routes, andws()WebSocket endpoints. Routes compile to dispatch plans; pluginroute_compilers()extend the pipeline per route. - HTTP surface —
HttpContextper request,Request/ResponseplusResponseBuilder, typed param extractors (Query,Path,Body,Form,Files,Header,Cookie,Ip),accepts()/returns()contract models (pydantic/msgspec), SSE helpers, and a fullHttpExceptionhierarchy with pluggable renderers. - Dependency injection —
Containerwith singleton/transient/scoped bindings,Injectmarkers,Scopecontrol, andCircularDependencyError/ResolutionErrordiagnostics. - Provider lifecycle —
ServiceProviderhooks (register→boot→ready→shutdown) plus plugin surfaces:commands(),config(),macros(),route_compilers(),contract_kinds(),queue_drivers(),cache_drivers(),adapters(),exception_renderers(). TheIgnitororchestrates the boot sequence. - ORM & database —
Model(fillable guards, dirty tracking,SoftDeletes, relations via@relation, class-levelupdate/update_or_failwithRETURNING), fluentQueryBuilder,DBfacade,Schemabuilder,Migrations,Factory/Seeder, andConnection.lease()/Model.using()for pinning pooled connections. Drivers: SQLite built in, Postgres (asyncpg) and MySQL (asyncmy) via extras. - Console —
Commandsubclasses with Artisan-stylesignaturestrings ("mail:send {user} {--f|force}"), kernel-registered, lazily loaded plugin commands. - CLI —
nyxaentrypoint:new,dev,start,build,deploy,add,make:*scaffolding (~20 generators),migrate/db:seedfamily,queue:*family,schedule:*,routes,doctor,repl,test,inspect,plugins,up/down,key:generate, and more. - Config & env —
config/*.pyfiles expose aconfigdict (namespaced by filename) read viaconfig.get/setwith typed getters;define_config()builds a standalone typed config object (env-overriding) for app code to import;Envloader with casts;nyxa.tomlmanifest sections ([app],[plugins],[deploy]). - Events, scheduling, queue —
EventEmitter(app.events),app.scheduleentries (call/job/command/exec+cron(),daily(),hourly(), …) served bynyxa schedule:work, and a pluggable queue (QueueProvider, driver factories). - Testing —
TestClient(sync + async) over the in-process app, provider/config/route/publish assertions, apytestplugin, andfake()utilities shipped by first-party packages. - OpenAPI & playground — generated spec and interactive playground,
gated by
app.debug/NYXA_ENV. - Transports & deployment — ASGI/WSGI/RSGI bridges,
nyxa buildfrozen-bundle production boots,nyxa deploy/promote/rollback, deployment adapters, warmup, and process management (Process).
Install
pip install nyxa
# or
uv add nyxa
The nyxa command and the Rust accelerators (nyxa-speedups +
nyxa-minijinja) are bundled by default — the cli/speed extras stay
declared for back-compat but add nothing. Accelerator wheels ship for
tier-1 platforms; elsewhere pip builds from the sdist (Rust toolchain)
or use pip install --no-deps nyxa plus the deps you want. Useful
extras: starlette,
blacksheep, granian, uvicorn, msgspec, postgres, mysql,
encrypt, hash-argon2, hash-bcrypt, server (native Rust server),
all.
Usage
A convention project
nyxa new my-api && cd my-api
nyxa dev
nyxa new scaffolds nyxa.toml (the manifest), config/*.py,
start/routes.py, start/schedule.py, app/ (providers, middleware,
commands), and bootstrap/app.py. The Application resolves its root
from the manifest or an explicit path:
from nyxa import Application
app = Application("path/to/project") # or Application() inside a project
Routing
Route files declare against the ambient router proxy; declarations
replay into the app router at boot:
from nyxa import router
router.get("/health", lambda ctx: {"status": "ok"}).named("health")
async def show(ctx, id: int): # path param injected by name
return {"user": id}
def api(r):
r.get("/users/:id", show)
r.post("/users", "app.actions.create_user")
router.group(api, prefix="/api").name("api.").middleware(Auth)
Path patterns accept :param, :param?, {param}, {param:int},
and ...name/...name? catch-alls; converters and
.where_ulid()-style constraints are built in. Groups, router.controller()/resource() controllers,
router.view(), router.redirect(), router.fallback(),
router.ws() WebSockets, and sse_stream/sse_event server-sent
events are all first-class.
Middleware is a class with a handle coroutine — referenced per-route
via .use(Cls)/route.use("name") or on groups; scope = "server"
runs it globally:
class Auth:
async def handle(self, ctx, next):
if ctx.request.header("authorization") is None:
abort(401)
return await next()
Dependency injection & providers
from nyxa import Inject, ServiceProvider
class Billing:
def charge(self, cents: int) -> str: ...
class AppProvider(ServiceProvider):
def register(self) -> None:
self.app.container.singleton(Billing)
async def invoice(ctx, billing: Billing = Inject(Billing)):
return {"id": billing.charge(500)}
ORM
from nyxa import Model
class Post(Model):
fillable = ["title", "body"]
post = await Post.create({"title": "Hello", "body": "..."})
post = await Post.find(1)
posts = await Post.query().where("published", True).order_by("id").all()
await Post.update({"title": "Hi"}, "id", 1) # class-level UPDATE
nyxa migrate, nyxa make:model, factories, and seeders cover the rest
of the lifecycle; DB and Schema facades handle raw queries and DDL.
Console commands
from nyxa import Command
class SendMail(Command):
signature = "mail:send {user : user id} {--f|force : skip confirm}"
async def handle(self, app, user: int, force: bool) -> int:
...
return 0
Register via a provider's commands() or drop the class into
app/commands/ — discovered lazily by the nyxa kernel.
Testing
from nyxa import Application, TestClient
app = Application("path/to/project")
client = TestClient(app)
response = client.get("/health")
assert response.status_code == 200
nyxa.testing also ships assert_provider_registered,
assert_config_merged, assert_route_registered, and
assert_publish_tag for package tests, plus a pytest plugin.
Public API
The package surface (from nyxa import …, lazily bound) groups as:
- App & lifecycle —
Application,ServiceProvider,Env,define_config,__version__ - Container —
Container,Provider,Inject,Scope,ContainerError,CircularDependencyError,ResolutionError - Routing —
router(ambient proxy),Router,Route,RouteError,Controller,Middleware,MiddlewareRegistry - HTTP —
HttpContext,Request,Response,ResponseBuilder,get_request,use,use_response,sse_event,sse_stream,Ws,WsClosed; paramsQuery,Path,Body,Form,Files,Header,Cookie,Ip - Exceptions —
HttpException,abort,ExceptionHandler,HttpExceptionHandler,BadRequestException,UnauthorizedException,ForbiddenException,NotFoundException,MethodNotAllowedException,ConflictException,ValidationException,ModelNotFound,TooManyRequestsException,InternalServerErrorException,ServiceUnavailableException,NyxaError - Database —
Model,DB,Schema,Collection,Query(param extractor — the builder isModel.query()),Migration,Factory,Seeder,SoftDeletes - Runtime —
Command,Context,Process,EventEmitter,TestClient
Configuration
Project config lives in config/*.py files exporting a config dict
(namespaced by filename — config/http.py → http.*); nyxa.toml
carries [app] (name, env, debug, providers_dir,
middleware_dir, env_file, auto_discover_plugins), [plugins]
(discover allowlist), and [deploy] (adapter). Environment
resolution: NYXA_ENV → [app] env → "development";
NYXA_DEBUG/[app] debug/debug= for the debug flag.
License
MIT — see LICENSE.
Metadata
Release files for nyxa 0.0.1
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 |
|---|---|---|---|---|
| nyxa-0.0.1.tar.gz | 641.9 kB | Without provenance | Details for nyxa-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nyxa-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for nyxa-0.0.1-py3-none-any.whl |
Total release size: 1.4 MB
Release files / nyxa-0.0.1.tar.gz
| Download URL | nyxa-0.0.1.tar.gz |
|---|---|
| Size | 641.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d4db3303714bd3373a39f466964cbb5cb55343573ab1021446cfb11e2c2fdee
|
|
BLAKE2b-256 checksum How to use checksums |
aafb32de3d0e898b8f5fc523550b2c7b18546056af37c9af9859f8c149c4e741
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / nyxa-0.0.1-py3-none-any.whl
| Download URL | nyxa-0.0.1-py3-none-any.whl |
|---|---|
| Size | 777.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2ae2f0bd99e755a9e05b7cf3986e79e82cbf44c45a2c97a97a59d677fa32e96
|
|
BLAKE2b-256 checksum How to use checksums |
55ca8e1058da82ac5077246ba81912bb377f252064eaa9f3279e68ceaf7dae47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for nyxa 0.0.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.