Infrastructure Service
Description
Provides technical capabilities or integrations with external systems (e.g., email service, payment gateway client), part of an Infrastructure Module.
Definition Schema
The definition for a infrastructure_service
component expects the following structure:
{
"$defs": {
"ServiceDependencyInputDTO": {
"description": "Defines a dependency to be injected into the Service's __init__.",
"example": {
"assigned_attribute_name": "_emailer",
"param_name": "email_service",
"param_type_str": "EmailService"
},
"example_with_explicit_import": {
"param_import_from_module": "sqlalchemy.ext.asyncio",
"param_import_names": [
"AsyncSession"
],
"param_name": "async_session_factory",
"param_type_str": "AsyncSession"
},
"properties": {
"param_name": {
"description": "Name of the parameter in __init__ (e.g., 'user_repository')",
"title": "Param Name",
"type": "string"
},
"param_type_str": {
"description": "Type hint string for the parameter (e.g., 'UserRepository')",
"title": "Param Type Str",
"type": "string"
},
"assigned_attribute_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Name of the attribute to assign the dependency to on self (e.g., '_repo'). Defaults to '_' + param_name if None.",
"title": "Assigned Attribute Name"
},
"param_import_from_module": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional: Explicit module to import the dependency type from (e.g., 'sqlalchemy.ext.asyncio').",
"title": "Param Import From Module"
},
"param_import_names": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional: Explicit list of names to import from the module (e.g., ['AsyncSession']). Used if param_import_from_module is set.",
"title": "Param Import Names"
}
},
"required": [
"param_name",
"param_type_str"
],
"title": "ServiceDependencyInputDTO",
"type": "object"
}
},
"description": "DTO for defining an Infrastructure Service class.",
"example": {
"dependencies": [],
"infrastructure_module_name": "database",
"name": "DatabaseConnectionService"
},
"properties": {
"name": {
"description": "Name of the service class (e.g., 'UserManagementService')",
"title": "Name",
"type": "string"
},
"dependencies": {
"description": "List of dependencies for the __init__ method.",
"items": {
"$ref": "#/$defs/ServiceDependencyInputDTO"
},
"title": "Dependencies",
"type": "array"
},
"infrastructure_module_name": {
"description": "Name of the infrastructure module (e.g., 'database', 'email')",
"title": "Infrastructure Module Name",
"type": "string"
}
},
"required": [
"name",
"infrastructure_module_name"
],
"title": "InfrastructureServiceInputDTO",
"type": "object"
}
Naming and Location Conventions
Class: PascalCase, typically ends with 'Service'. File: ${infrastructure_service_name}.py
(based on ${infrastructure_service_name}
). Location: app/infrastructure/${infrastructure_module_name}
. (Requires context: ['infrastructure_module_name'])
Example Definition
{
"name": "DatabaseConnectionService",
"infrastructure_module_name": "database",
"dependencies": []
}