// PRJ_011 · 2025
Microservicio e-Bike Autolocke-Bike Autolock Microservice
Clean Architecture · PythonClean Architecture · Python
El sistema que bloquea y desbloquea bicicletas eléctricas según su ubicación y la contraseña del usuario.The system that locks and unlocks e-bikes based on their location and the user's password.
En detalleIn detailMicroservicio para sistema de bloqueo automático de e-bikes. Clean Architecture en Python: domain, use cases, interfaces API y capa de infraestructura. Simulación GPS, triggers, hashing de contraseñas, Docker, tests de dominio (pytest) y CI.Microservice for an e-bike automatic locking system. Clean Architecture in Python: domain, use cases, API interfaces and infrastructure layer. GPS simulation, triggers, password hashing, Docker, domain tests (pytest) and CI.
// IMPACTO// IMPACT
El problemaThe problem
Un sistema de bloqueo automático de e-bikes necesita validar contraseñas, registrar eventos GPS y manejar triggers de bloqueo y desbloqueo, todo desacoplado y testeable sin hardware presente.An e-bike automatic locking system needs to validate passwords, log GPS events and handle lock/unlock triggers, all decoupled and testable with no hardware present.
Cómo lo resolvíHow I solved it
Implementé Clean Architecture en Python: capa de dominio pura, casos de uso independientes de frameworks, interfaces Flask como capa de entrada, e infraestructura (DB, GPS) en la capa más externa. Docker para el entorno.Implemented Clean Architecture in Python: pure domain layer, framework-independent use cases, Flask interfaces as the entry layer, and infrastructure (DB, GPS) in the outermost layer. Docker for the environment.
Arquitectura y stackArchitecture & stack
- [01]Dispositivo e-Bike
- [02]Flask API
- [03]Use Cases
- [04]Domain
- [05]PostgreSQL
- Python
- Flask
- PostgreSQL
- Docker
- Clean Architecture
# domain/usecases/unlock_bike.py
class UnlockBikeUseCase:
def __init__(self, bike_repo, gps_service):
self.bike_repo = bike_repo
self.gps_service = gps_service
def execute(self, bike_id, password):
bike = self.bike_repo.find(bike_id)
if not bike.verify_password(password):
raise InvalidCredentials()
location = self.gps_service.get(bike_id)
bike.unlock(location)
return self.bike_repo.save(bike) Lo que aprendíWhat I learned
01 //
Clean Architecture
Invertir la dependencia hace el dominio 100% testeable sin base de datos.
02 //
GPS simulation
Simular hardware desde código desbloquea el desarrollo sin dispositivos físicos.
03 //
Hashing en dominio
El hashing de contraseñas pertenece al dominio, no a la infraestructura.
01 //
Clean Architecture
Inverting dependencies makes the domain 100% testable without a database.
02 //
GPS simulation
Simulating hardware in code enables development without physical devices.
03 //
Hashing in domain
Password hashing belongs to the domain, not the infrastructure.