{"conversations": [{"from": "user", "value": "Mostra'm un exemple d'una API feta amb una arquitectura Hexagonal usant FastAPI"}, {"from": "assistant", "value": "Exemple: import fastapi from fastapi.encoders import jsonable_encoder from starlette. context Request # Definim les interf\u00edcies del Domini class UserService: def get_user( self, user_id): # implementaci\u00f3 de la l\u00f2gica de negoci passas # Definim la capa d' Aplicaci\u00f3 class UserResource: def _ init__ self, user_ service: self.user_ service = user_ service async def get( self, request: Request, user_ id: str): user = self. user_ service.get_ user_ id) return jsonable_ encoder( user) # Definim la capa d' Infraestructura app = fastapi.FastAPI (\"/users/ {user_ user) usos_urcet_ ruret( ster)_ sterzet_ st)"}]}