Skip to main content

User system with hexagonal architecture

Project description

Vexen-User

Sistema de gestión de usuarios con arquitectura hexagonal, diseñado para integrarse con vexen-rbac y vexen-auth.

Características

  • Arquitectura Hexagonal: Separación clara entre dominio, aplicación e infraestructura
  • Async/Await: Totalmente asíncrono usando SQLAlchemy 2.0+ con asyncpg
  • Type Safe: Completamente tipado para mejor soporte en IDEs
  • API Pública Simple: Similar a FastAPI, fácil de usar
  • Paginación y Filtros: Soporte completo para búsqueda, filtros y paginación
  • Estadísticas: Obtén métricas sobre usuarios del sistema

Implementado

Entidades: User entity completa con validaciones ✅ Repositorios: IUserRepositoryPort (interface) e implementación SQLAlchemy ✅ DTOs: Todas las estructuras de request/response según especificaciones ✅ Casos de Uso: list, get, create, update, delete, stats ✅ Servicio: UserService que orquesta los casos de uso ✅ API Pública: VexenUser class (similar a RBAC) ✅ Adapters: Gestión de sesiones SQLAlchemy ✅ Ejemplo funcional: example_usage.py

Uso Rápido

import asyncio
from vexen_user import VexenUser
from vexen_user.application.dto import CreateUserRequest

async def main():
    user_system = VexenUser(
        database_url="postgresql+asyncpg://user:pass@localhost/db"
    )

    await user_system.init()

    # Crear usuario
    user = await user_system.service.create(
        CreateUserRequest(
            email="user@example.com",
            name="John Doe"
        )
    )

    # Listar usuarios
    users = await user_system.service.list(page=1, page_size=20)

    # Obtener estadísticas
    stats = await user_system.service.stats()

    await user_system.close()

if __name__ == "__main__":
    asyncio.run(main())

Instalación

pip install vexen-user

Estructura del Proyecto

vexen_user/
├── domain/              # Capa de dominio (entidades, puertos)
│   ├── entity/         # User entity
│   └── repository/     # IUserRepositoryPort
├── application/        # Capa de aplicación (casos de uso, DTOs)
│   ├── dto/           # Request/Response DTOs
│   ├── usecase/       # Casos de uso
│   └── service/       # UserService
└── infraestructure/   # Capa de infraestructura (adaptadores)
    └── output/
        └── persistence/
            └── sqlalchemy/  # SQLAlchemy adapter

DTOs Disponibles

Request DTOs

  • CreateUserRequest: Crear nuevo usuario
  • UpdateUserRequest: Actualizar usuario completo
  • PatchUserRequest: Actualizar campos específicos

Response DTOs

  • UserResponse: Información básica de usuario
  • UserExpandedResponse: Información completa con metadatos
  • PaginatedUsersResponse: Lista paginada de usuarios
  • UserStatsResponse: Estadísticas del sistema

Casos de Uso

  • ListUsers: Listar usuarios con paginación y filtros
  • GetUser: Obtener usuario por ID o email
  • CreateUser: Crear nuevo usuario
  • UpdateUser: Actualizar usuario
  • DeleteUser: Eliminar usuario (soft delete)
  • GetUserStats: Obtener estadísticas

Integración con otros sistemas

Este paquete está diseñado para trabajar con:

  • vexen-rbac: Sistema de control de acceso basado en roles
  • vexen-auth: Sistema de autenticación

Desarrollo

# Instalar dependencias de desarrollo
pip install -e ".[dev]"

# Ejecutar tests
pytest

# Formatear código
ruff format .

# Linting
ruff check . --fix

Licencia

MIT

Links

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

vexen_user-0.1.4.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

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

vexen_user-0.1.4-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file vexen_user-0.1.4.tar.gz.

File metadata

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

File hashes

Hashes for vexen_user-0.1.4.tar.gz
Algorithm Hash digest
SHA256 decae88da5a67e9c0a086c9cc2b370084aaf296632e8788c37131349bd74a840
MD5 4437d795a4622cb0288e6bfccba35c71
BLAKE2b-256 2f333a7f6f639657a6e9fbf9afad6b96c836b0a98e3e9df3eb3d1f427c2d4843

See more details on using hashes here.

Provenance

The following attestation bundles were made for vexen_user-0.1.4.tar.gz:

Publisher: python-publish.yml on vexen-labs/vexen-user

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

File details

Details for the file vexen_user-0.1.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for vexen_user-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f91e57e551e858b8afbde81ffbcdc4eb4384cb170315cd9dd7b7b143cf8f9e94
MD5 076902258436fe700a8154217865371e
BLAKE2b-256 81a14b68c9edd59e3d6f56a19b4f4ef456f55da62ef180f4a5e0c77087f2fb61

See more details on using hashes here.

Provenance

The following attestation bundles were made for vexen_user-0.1.4-py3-none-any.whl:

Publisher: python-publish.yml on vexen-labs/vexen-user

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