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.11.0.tar.gz (91.1 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.11.0-py3-none-any.whl (82.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for deepsel-0.11.0.tar.gz
Algorithm Hash digest
SHA256 11baefbc7c96ca8998d8ae4f464797b70e3f67a1374e0418cd519ff16dbed4e8
MD5 7b679a0d325406f9410b991631e53fba
BLAKE2b-256 3517c88765aa9b62930d49472cfc1fa24c9406198edae6db98c5d8597e24fd59

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for deepsel-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 08e7f20db08b7300bad54c35e9c258a15743efb766cd2aaf663705d96390c87a
MD5 6a38c8ece0ab755b40a082eb8779f6fd
BLAKE2b-256 4a2acd6fcdfc9908f375e90da1dadaa7c6850254f365ec75d519709fc9508d21

See more details on using hashes here.

Provenance

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