Skip to main content

NeuronOS Python Capabilities Library - Provider-agnostic backend capabilities following hexagonal architecture

Project description

NeuronOS Capabilities Library

A collection of provider-agnostic backend capabilities for Python applications, following hexagonal architecture principles.

Each capability exposes well-defined ports and adapters, making implementations swappable without changing your application code.

Installation

pip install neuronos-capabilities

What is a Capability?

A capability is a self-contained backend module that follows hexagonal architecture (ports and adapters pattern):

Capability/
├── ports/              # Abstract interfaces — defines WHAT operations exist
├── adapters/           # Provider implementations — defines HOW they work
├── config/             # Configuration management
├── exceptions/         # Custom exception hierarchy
└── [name]_manager.py   # Public API — single entrypoint for consumers

You interact only with the Manager. The port defines the contract, and adapters implement it for specific providers. Switching from PostgreSQL to MySQL, or from Clerk to Auth0, is just a config change.

Available Capabilities

Capability Description Providers Docs
SQLManager Database management with ORM, migrations, connection pooling PostgreSQL docs/sql-manager.md
AuthManager JWT authentication and role-based authorization for FastAPI Clerk docs/auth-manager.md
S3Manager Object storage with CRUD, listing, multipart uploads, presigned URLs AWS S3 docs/s3-manager.md

SQLManager — Quick Look

from neuronos_capabilities import SQLManager

config = {"host": "localhost", "database": "myapp", "user": "postgres", "password": "secret"}

with SQLManager(config) as db:
    db.create_tables([User])
    user = db.insert(User, {"name": "Alice", "email": "alice@example.com"})
    users = db.query(User, {"name": "Alice"})

AuthManager — Quick Look

from neuronos_capabilities import AuthManager
from fastapi import FastAPI, Depends

auth = AuthManager()  # reads NEURONOS_AUTH_JWKS_URL from env

app = FastAPI()

@app.get("/api/protected")
async def protected(user: dict = Depends(auth.require_auth())):
    return {"user_id": user["sub"]}

@app.get("/api/admin")
async def admin(user: dict = Depends(auth.require_roles(["org:admin"]))):
    return {"message": "Admin access granted"}

S3Manager — Quick Look

from neuronos_capabilities import S3Manager

s3 = S3Manager({"region": "us-east-1"})

# Upload and download
s3.put_object("my-bucket", "hello.txt", b"Hello World")
s3.download_file("my-bucket", "hello.txt", "/tmp/hello.txt")

# Generate a temporary download link
url = s3.generate_presigned_download_url("my-bucket", "hello.txt", expiration=900)

# Recursive listing
for obj in s3.walk("my-bucket", "data/"):
    print(f"{obj['Key']}  {obj['Size']} bytes")

# Multipart upload for large files
upload_id = s3.create_multipart_upload("my-bucket", "large-file.bin")
part = s3.upload_part("my-bucket", "large-file.bin", 1, upload_id, chunk)
s3.complete_multipart_upload("my-bucket", "large-file.bin", upload_id, [part])

Development

git clone https://github.com/neuronos/neuronos_python_capabilities_library
cd neuronos_python_capabilities_library
pip install -e ".[dev]"
pytest -v
pytest --cov=neuronos_capabilities --cov-report=html

Contributing

  1. Follow hexagonal architecture: port → adapter → manager
  2. Implement both sync and async methods
  3. Include tests and documentation
  4. Update this README with the new capability

License

MIT — see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neuronos_capabilities-0.0.1.3.tar.gz (46.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neuronos_capabilities-0.0.1.3-py3-none-any.whl (58.7 kB view details)

Uploaded Python 3

File details

Details for the file neuronos_capabilities-0.0.1.3.tar.gz.

File metadata

  • Download URL: neuronos_capabilities-0.0.1.3.tar.gz
  • Upload date:
  • Size: 46.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for neuronos_capabilities-0.0.1.3.tar.gz
Algorithm Hash digest
SHA256 00103cba1ffcb812fa58496f42fd6682ecf83006cab2a60a8ee99e7d4991d58f
MD5 72a35e021e196307fe2890262094b440
BLAKE2b-256 be1722d267259cb13c80cfac43c00fc17bacbb346a6c8b932b9a8c9184dae662

See more details on using hashes here.

File details

Details for the file neuronos_capabilities-0.0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for neuronos_capabilities-0.0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2dd1f3cfaa13a1bc8a84bd72c17e5a7ec00ff8fcf8bb81d9df77ae0c6acfa603
MD5 92cc2f6eb26dfb2b52652b56d7500746
BLAKE2b-256 4936263b34b02b31ae877cdc611b753a316ef4f08ae503e089f4ca6668fe3e12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page