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.4.tar.gz (102.9 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.4-py3-none-any.whl (89.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deepsel-0.14.4.tar.gz
  • Upload date:
  • Size: 102.9 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.4.tar.gz
Algorithm Hash digest
SHA256 67e29bf2dc96634ff6b8c22c087cee640115c5f03bc7f2d800b8c4b7f3011ef6
MD5 f8c79ba1cc8e8376f286164815fbd314
BLAKE2b-256 47907a412831a4c49df6269d4ad3eccceddbddf34d2b308da9ff1d3eb6985d97

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepsel-0.14.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: deepsel-0.14.4-py3-none-any.whl
  • Upload date:
  • Size: 89.8 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9337f7322aa403dd84dac03dd73cf1aa35e4e1a06dc6dfdc382726e86e246a99
MD5 4442a679cc41862f5cf4abe1c7d7e2f7
BLAKE2b-256 116a92464b3f9f31714c4c2f9bb80640c154fd39184ed8bee51865385ee4423e

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepsel-0.14.4-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