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.3.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.3-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vexen_user-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 16f3c850697ab7350a7ccca46aeab0ae5c46bf37afe64928e9c99e4781f69581
MD5 41cdf65eabfee9024e03cc2ded9c7e8c
BLAKE2b-256 c02bf0737ff103ca0042d216861bff632c0c4c4d8a391f6732476742c9fc4f3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for vexen_user-0.1.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: vexen_user-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4a5f42df88c11f86ba546b096ec272b3f9c1d4133e10b6afd3e331564946cd97
MD5 b036884531e8e3fdc4559346503cba77
BLAKE2b-256 91c3376c452052e2bed380aebaf87032b09a34aa4f1b245a7be6624ad738d024

See more details on using hashes here.

Provenance

The following attestation bundles were made for vexen_user-0.1.3-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