Skip to main content

Database utilities, ORM framework, and authentication for SQLAlchemy, FastAPI Python applications

Project description

Deepsel

A full-featured Python framework for building data-driven applications with FastAPI and SQLAlchemy. Provides an ORM layer with built-in CRUD, multi-tenancy, authentication, automatic API generation (REST + GraphQL), and more.

Packages

  • deepsel.orm - Declarative ORM with base models, mixins, and advanced query support
  • deepsel.sqlalchemy - Automatic database schema migration and management
  • deepsel.auth - Authentication (JWT, OAuth, SAML, 2FA)
  • deepsel.utils - CRUD routers, schema generation, GraphQL, storage clients, email, encryption

Installation

pip install deepsel

Optional Dependencies

pip install deepsel[auth]       # JWT, password hashing, 2FA
pip install deepsel[oauth]      # Google OAuth
pip install deepsel[saml]       # SAML authentication
pip install deepsel[s3]         # AWS S3 storage
pip install deepsel[azure]      # Azure Blob storage
pip install deepsel[storage]    # Both S3 and Azure
pip install deepsel[graphql]    # GraphQL support via Strawberry

Quick Start

Define Models

from deepsel import BaseModel
from sqlalchemy import Column, String

class User(BaseModel):
    __tablename__ = "users"

    name = Column(String, nullable=False)
    email = Column(String, unique=True, nullable=False)

BaseModel automatically provides created_at, updated_at, string_id, active, and system fields, plus built-in query methods for searching, filtering, and pagination.

Automatic CRUD API

from deepsel import CRUDRouter, generate_CRUD_schemas, configure_crud_router

# Configure dependencies
configure_crud_router(db_session_factory=get_db, auth_dependency=get_current_user)

# Generate Pydantic schemas from your ORM model
schemas = generate_CRUD_schemas(User)

# Create a router with full CRUD endpoints
router = CRUDRouter(model=User, schemas=schemas)
app.include_router(router)

This gives you paginated list, search, create, read, update, and bulk delete endpoints out of the box.

Authentication

from deepsel import AuthService

auth = AuthService(secret_key="your-secret-key")

# JWT tokens
token = auth.create_token(user_id=123)
payload = auth.decode_token(token)

# Password hashing
hashed = auth.hash_password("my_password")

Also supports Google OAuth (GoogleOAuthService), SAML (SamlService), and 2FA with recovery codes.

Database Migrations

from deepsel import DatabaseManager

db_manager = DatabaseManager(
    sqlalchemy_declarative_base=Base,
    db_session_factory=get_db,
    models_pool={"users": User, "products": Product}
)

Automatically detects and applies schema changes: new tables/columns, type changes, foreign keys, indexes, enums, and composite keys.

GraphQL

from deepsel import init_graphql, AutoGraphQLFactory

factory = AutoGraphQLFactory(models=[User, Product])
schema = factory.create_auto_schema()
init_graphql(app, schema)

ORM Mixins

Extend your models with feature-rich mixins:

Mixin Description
UserMixin User authentication, roles, permissions, email
OrganizationMixin Multi-tenant organization management
AttachmentMixin File uploads with pluggable storage (S3, Azure, local)
EmailTemplateMixin Email template management
CronMixin Scheduled task execution
ActivityMixin Field-level change tracking and audit logs

Query & Search

Built-in support for complex queries with AND/OR logic, operators (eq, ne, in_, contains, between, like, ilike, gt, lt, etc.), permission scoping (own, org, all), and ordering.

Utilities

  • Storage: S3 and Azure Blob clients with filename sanitization
  • Email: Rate-limited email sending via fastapi-mail
  • Encryption: encrypt()/decrypt(), password hashing, recovery code generation
  • App helpers: install_routers(), install_seed_data(), import_csv_data(), lifecycle hooks

Supported Databases

  • PostgreSQL (primary support)

Development

make install-dev    # Install with dev dependencies
make test           # Run tests with coverage
make lint           # Run flake8
make security       # Run bandit security checks
make format         # Format with black
make prepush        # Run all checks before pushing
make build          # Build distribution packages

License

MIT License - see LICENSE file for details.

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

deepsel-0.14.3.tar.gz (100.7 kB view details)

Uploaded Source

Built Distribution

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

deepsel-0.14.3-py3-none-any.whl (88.5 kB view details)

Uploaded Python 3

File details

Details for the file deepsel-0.14.3.tar.gz.

File metadata

  • Download URL: deepsel-0.14.3.tar.gz
  • Upload date:
  • Size: 100.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deepsel-0.14.3.tar.gz
Algorithm Hash digest
SHA256 df76a9fca95ac9416dc335659086105da5e8ab99188ac6942ba27ef113ca4a10
MD5 a3bfbecd550d04cd9d71acd02c9c4f8f
BLAKE2b-256 1549cdd6243efb4362265aeed8b902fafbe1ee96d27288f52421f558761e7460

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepsel-0.14.3.tar.gz:

Publisher: publish.yml on DeepselSystems/deepsel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepsel-0.14.3-py3-none-any.whl.

File metadata

  • Download URL: deepsel-0.14.3-py3-none-any.whl
  • Upload date:
  • Size: 88.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deepsel-0.14.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cc29231359008f29cfc6067d8932a551f207ca6a439df6e7e9519b5beac292c1
MD5 ccc76c388fc76da478443e816aad1192
BLAKE2b-256 078fb0538a82586ffa8ab01f90dab59b9561bc2ce9b99236a16b92827c3efed3

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepsel-0.14.3-py3-none-any.whl:

Publisher: publish.yml on DeepselSystems/deepsel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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