R-TF-012-029 Software Architecture Description
Purpose
This document describes the software architecture for the device, including the system structure, software items, interfaces, data flows, and design rationale. It provides the architectural framework that guides implementation of the requirements defined in the Software Requirements Specification (SRS) and establishes the foundation for detailed design activities.
This architecture description is developed in accordance with IEC 62304:2006+AMD1:2015 and serves as the primary reference for understanding how the software system is organized and how its components interact.
Scope
This architecture description covers:
- High-level software architecture and system decomposition into software items
- Responsibilities of each software item and its constituent software units
- Interfaces between software items and with external systems
- Integration of SOUP (Software of Unknown Provenance) components
- Data flow and control flow through the system
- Architectural decisions and their justifications
This document does not cover detailed design specifications for individual software units, which are addressed in the Software Detailed Design documentation. Complete API specifications are maintained in a separate API reference document.
Terminology
The following terms are used throughout this document. Terms marked with (IEC 62304) are defined in accordance with that standard:
IEC 62304 terms:
- Software item (IEC 62304): A separately identifiable part of the software system, composed of one or more software units.
- Software unit (IEC 62304): The smallest testable element of a software item.
- SOUP (IEC 62304): Software of Unknown Provenance—software that was not developed for the purpose of being incorporated into the medical device.
Domain-specific terms:
- Expert: A specialized software item that executes a specific AI model for clinical analysis (e.g., classification, segmentation, or detection).
- Integrator: A third-party organization or developer that incorporates the device's API into their own application to provide clinical functionality to end users.
- Canonical: A standardized, internal data format used for communication between software items, independent of external interface formats.
- Workflow: A defined sequence of processing steps that the device executes to fulfill a clinical request (e.g., the diagnosis support workflow or severity assessment workflow).
Architectural pattern terms:
- ACL (Anti-Corruption Layer): A pattern that isolates one subsystem from another by translating between their data models, preventing external schemas from leaking into domain logic.
- DTO (Data Transfer Object): A simple object that carries data between processes or layers without containing business logic.
- Port: An interface that defines how a component interacts with external systems, enabling substitution of implementations.
- Adapter: A concrete implementation of a port that connects to a specific external system or technology.
Architectural overview
This section presents the system's purpose, clinical workflows, main functions, and external interfaces at a conceptual level. Subsequent sections provide detailed decomposition of each software item.
System purpose and clinical workflows
The device provides image analysis workflows for dermatological conditions as specified in the Intended Use. Integrators access these workflows through a RESTful API that supports two primary clinical functions:
- Diagnosis support: Accepts up to 5 images of a skin condition and returns a probability distribution across ICD diagnostic categories.
- Severity assessment: Accepts a single image plus optional patient-reported information (e.g., itch intensity, sleep disturbance) and returns quantified clinical sign assessments.
Both workflows follow a common processing pipeline:
- Request submission: The integrator selects a workflow type and submits the required data (images and optional parameters).
- Validation: The device validates submitted images for quality and domain relevance before proceeding with analysis.
- Expert analysis: The device routes the request to the appropriate AI model experts, which process the images and generate clinical findings.
- Report generation: Results from the experts are assembled into a structured clinical report and returned to the integrator.
Diagnosis support workflow
The diagnosis support workflow accepts up to 5 images of a skin condition. After validating images for quality and domain relevance, the device invokes the Condition Classification expert, which performs multi-image analysis with aggregation. The response includes:
- Aggregated ICD probability distribution across the image set (SRS-Q3Q)
- Per-image ICD diagnosis with explainability heat maps (SRS-0AB)
- Model sensitivity and specificity metrics (SRS-1XR)
- Entropy score indicating prediction uncertainty (SRS-58W)
- Clinical risk indicators:
- High priority referral indicator (SRS-71I)
- Malignancy indicator (SRS-8HY)
- Pigmented lesion indicator (SRS-D08)
- Condition presence indicator (SRS-JLM)
- Urgent referral indicator (SRS-KAS)
Severity assessment workflow
The severity assessment workflow accepts a single image along with optional patient-reported information. After image validation, the device invokes the requested expert services—which may include sign classifiers, segmenters, and detectors—to process the image in parallel. The combined results provide a quantitative assessment of clinical signs.
The architecture supports four categories of expert outputs:
- Classification: Binary presence/absence detection and continuous severity scoring for clinical signs (e.g., erythema intensity, wound characteristics, tissue depth)
- Segmentation: Pixel-level masks quantifying the spatial extent of features (e.g., lesion area, erythema coverage), with both probabilistic and binary outputs
- Detection: Object localization with bounding boxes for discrete structures (e.g., papules, nodules, pustules), including counts and confidence scores
- Staging: Multi-class classification for standardized severity scales (e.g., wound staging, Hurley staging for hidradenitis suppurativa, IGA grading for acne)
The specific clinical signs and expert models supported are documented in the Software Requirements Specification.
Main functions
The software architecture supports the following primary functions:
| Function | Description |
|---|---|
| Image quality assessment | Assesses image quality using CNN-based scoring (1-10 scale) combined with technical requirements validation (minimum size, aspect ratio, color detection) to determine acceptability for clinical analysis |
| Image domain and modality classification | Classifies images as dermatological or non-dermatological, and for dermatological images, identifies the imaging modality (clinical photograph vs. dermoscopy) |
| Diagnosis support | Generates a probability distribution across ICD categories by analyzing one or more images, with per-condition confidence scores and explainability outputs |
| Severity assessment | Quantifies clinical signs through classification (intensity), segmentation (spatial extent), and detection (lesion counts) |
| Report generation | Transforms raw expert outputs into structured clinical reports with standardized medical terminology (ICD-11, SNOMED CT) |
| API exposure | Provides secure, versioned access to device functionality through a RESTful interface with authentication and audit logging |
External interfaces
The device exposes its functionality exclusively through a RESTful API, which serves as the sole interface for integrators. All communication uses JSON over HTTPS with JWT-based authentication.
API structure
The API Gateway organizes endpoints into four categories:
| Category | Purpose | Authentication |
|---|---|---|
| Authentication | User login and token management | None |
| Clinical | Diagnosis support and severity assessment | Required |
| Device | Device information and health checks | Required |
| Internal | System monitoring (not in public API schema) | Required |
Authentication model
Integrators authenticate using the OAuth2 Password Grant flow:
- The integrator submits credentials (username and password) to
POST /auth/login - Upon successful authentication, the API returns a signed JWT with a limited validity period
- The integrator includes this JWT as a Bearer token in subsequent requests
- When the token expires, the integrator must re-authenticate
This model ensures that access is credential-based, time-limited, and regularly re-validated.
POST /auth/login
Authenticates a user with username and password and returns a JWT access token for accessing protected endpoints.
Request headers:
Content-Type: application/json
Request body:
{
"username": "integrator@example.com",
"password": "securePassword123"
}
Response body (200 OK):
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer",
"expires_in": 3600
}
Error responses:
401 Unauthorized: Invalid username or password, or password has expired403 Forbidden: Account is locked due to excessive failed login attempts429 Too Many Requests: Login temporarily delayed after failed attempts (includesRetry-Afterheader)
Clinical endpoints
The clinical endpoints correspond directly to the device's clinical workflows.
POST /clinical/diagnosis-support
Accepts 1–5 base64-encoded images of the suspected lesion from different perspectives and returns a report with possible diagnoses, including:
- A probability distribution across ICD diagnostic categories (both aggregated across all images and per-image)
- Explainability outputs (saliency heat maps) for top predictions
- Clinical risk indicators (malignancy, urgent referral, etc.)
Request headers:
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Request body:
{
"images": [
{
"identifier": "550e8400-e29b-41d4-a716-446655440000",
"data": "/9j/4AAQSkZJRgABAQEASABIAAD...",
"color_model": "RGB",
"file_format": "JPEG"
}
],
"extra_parameters": {
"common": {},
"expert_specific": {}
}
}
| Field | Type | Required | Description |
|---|---|---|---|
images | array | Yes | 1 –5 base64-encoded images representing different views of the target area |
images[].identifier | UUID | No | Unique identifier for the image (auto-generated if omitted) |
images[].data | string | Yes | Base64-encoded image data |
images[].color_model | string | No | Color model of the image (default: RGB) |
images[].file_format | string | No | Image file format (default: JPEG) |
extra_parameters | object | No | Additional configuration parameters for the analysis experts |
Response body (200 OK):
{
"study_aggregate": {
"findings": {
"hypotheses": [
{
"identifier": "psoriasis",
"concepts": [
{
"name": "Psoriasis",
"code": "9014002",
"terminology_system": "SNOMED CT"
}
],
"probability": 78.5,
"explanation": {
"attention_map": {
"data": "/9j/4AAQSkZJRgABAQEASABI...",
"color_model": "RGB",
"file_format": "PNG"
}
}
},
{
"identifier": "eczema",
"concepts": [
{
"name": "Eczema",
"code": "43116000",
"terminology_system": "SNOMED CT"
}
],
"probability": 15.2,
"explanation": null
}
],
"risk_metrics": {
"any_condition_probability": 95.8,
"malignant_condition_probability": 2.1,
"pigmented_condition_probability": 5.4,
"urgent_referral_probability": 3.2,
"high_priority_referral_probability": 12.7
},
"entropy": 28.4
}
},
"image_analyses": [
{
"source_image": {
"identifier": "550e8400-e29b-41d4-a716-446655440000"
},
"findings": {
"hypotheses": [...],
"risk_metrics": {...},
"entropy": 25.1
}
}
]
}
POST /clinical/severity-assessment
Accepts a single base64-encoded image and a list of visual sign expert identifiers, and returns:
- Sign assessments including intensity scores, segmentation masks, and detection counts
- Annotated images showing detected regions
Request headers:
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Request body:
{
"image": {
"identifier": "550e8400-e29b-41d4-a716-446655440001",
"data": "/9j/4AAQSkZJRgABAQEASABIAAD...",
"color_model": "RGB",
"file_format": "JPEG"
},
"experts": ["erythema", "scaling", "induration"],
"extra_parameters": {
"common": {},
"expert_specific": {}
}
}
| Field | Type | Required | Description |
|---|---|---|---|
image | object | Yes | Base64-encoded image representing the target area to be analyzed |
experts | array | Yes | List of visual sign expert identifiers to be consulted (e.g., erythema, scaling, induration, excoriation) |
extra_parameters | object | No | Additional configuration parameters for the analysis experts |
Response body (200 OK):
{
"image_analysis": {
"source_image": {
"identifier": "550e8400-e29b-41d4-a716-446655440001"
},
"findings": [
{
"sign_identifier": "erythema",
"overall_severity_summary": "Moderate erythema",
"presence": {
"is_present": true,
"confidence": 98.2
},
"intensity": {
"grade": 2.5,
"grading_scale": "Legit.Health",
"confidence": 87.3
},
"extent": {
"regions": [
{
"mask": {
"data": "/9j/4AAQSkZJRgABAQEASABI...",
"color_model": "RGB",
"file_format": "PNG"
},
"threshold": 0.5,
"confidence_map": {
"data": "/9j/4AAQSkZJRgABAQEASABI...",
"color_model": "RGB",
"file_format": "PNG"
},
"percentage": 35.2,
"label": "affected_area"
}
],
"annotated_image": {
"data": "/9j/4AAQSkZJRgABAQEASABI...",
"color_model": "RGB",
"file_format": "PNG"
}
}
},
{
"sign_identifier": "scaling",
"overall_severity_summary": "Mild scaling",
"intensity": {
"grade": 1.2,
"grading_scale": "Legit.Health",
"confidence": 91.5
}
}
]
}
}
GET /clinical/severity-experts
Returns the list of valid visual sign expert identifiers that can be used in the severity-assessment endpoint.
Request headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Response body (200 OK):
{
"experts": [
"erythema",
"scaling",
"induration",
"excoriation",
"lichenification",
"dryness",
"edema",
"vesiculation"
]
}
Both clinical endpoints return structured JSON responses with standardized medical terminology codes (ICD-11, SNOMED CT) where applicable.
Device endpoints
GET /device/about
Returns device labeling information including manufacturer details, regulatory clearances, UDI, and applicable standards.
Request headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Response body (200 OK):
{
"device_name": "Device Name",
"description": "AI-powered clinical decision support system for dermatological conditions...",
"version": "1.1.0.0",
"release_date": "2024-01-15",
"manufacturer": {
"name": "Manufacturer Name",
"description": "Digital health solutions developer",
"country_code": "ES",
"website": "https://example.com"
},
"udi": "(01)08437025130011(10)1.1.0.0(21)PROD-001",
"alternate_identifiers": [
{
"system": "GMDN",
"code": "47905",
"issuing_authority": "GMDN Agency",
"description": "Software as a medical device"
}
],
"standards": [
{
"standard_name": "ISO 13485",
"standard_version": "2016"
},
{
"standard_name": "IEC 62304",
"standard_version": "2006+AMD1:2015"
}
],
"regulatory_clearances": [
{
"regulation": "EU_MDR_2017_745",
"risk_class": "IIa",
"notified_body": "BSI",
"authorization_id": "CE123456",
"authorization_date": "2024-01-10"
}
],
"claims": [
{
"description": "User may request IFU in paper format",
"reference": "EU MDR Article 7(2)"
}
],
"contact_email": "support@example.com",
"instructions_url": "https://ifu.example.com/eu-mdr"
}
GET /device/health
Returns the operational status of the device and its downstream services.
Request headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Response body (200 OK):
{
"status": "healthy",
"services": {
"control_plane": {
"status": "healthy",
"latency_ms": 45
},
"expert_orchestrator": {
"status": "healthy",
"latency_ms": 120
},
"database": {
"status": "healthy",
"latency_ms": 12
}
}
}
Error handling
All endpoints use standard HTTP status codes:
| Status | Meaning |
|---|---|
200 OK | Request succeeded |
401 Unauthorized | Missing or invalid authentication token |
403 Forbidden | User account is locked or inactive |
429 Too Many Requests | Rate limit exceeded or login delayed |
503 Service Unavailable | Downstream service (e.g., Control Plane) unavailable |
Error response format:
All error responses follow a consistent JSON structure:
{
"detail": "Invalid username or password"
}
For rate-limited requests, the response includes a Retry-After header indicating when the client may retry:
HTTP/1.1 429 Too Many Requests
Retry-After: 30
Content-Type: application/json
{
"detail": "Too many failed login attempts. Please wait 30 seconds before retrying."
}
Global system views
This section presents the system from multiple architectural perspectives—deployment topology, component connections, data flow, and security boundaries—before the detailed decomposition of individual software items in the following section.
Deployment architecture
The device is deployed on AWS infrastructure. The following diagram illustrates the deployment topology and key AWS services used:
Component connections
The following diagram shows the communication paths between software items. External integrators access the device through the API Gateway over HTTPS. Internal communication between software items uses HTTP within the private network. The experts—specialized software items that execute AI models—are accessed through the Expert Orchestrator.
Data flow
Data flows through the system as JSON payloads. The following diagram shows the data paths and the types of data exchanged between components:
The following sequence diagram illustrates the general request processing flow, showing how data transforms as it passes through each layer:
Updatability and versioning
The architecture supports controlled updates through a defined versioning scheme and deployment process:
Software versioning follows a four-digit scheme (W.X.Y.Z) as defined in GP-012:
- W (major): Reserved for fundamental architectural changes
- X (feature): Incremented for significant feature additions or backward-incompatible changes
- Y (minor): Incremented for minor improvements
- Z (patch): Incremented for bug fixes
API versioning follows an independent scheme (vA.B) decoupled from the software version. API version changes reflect contract modifications; backward compatibility requirements are documented in the API Gateway to ensure integrators can plan transitions.
Deployment process: New software versions are deployed to production only after completing all required verification and validation activities. The containerized architecture allows individual software items to be updated independently, enabling targeted patches without full system redeployment.
Security architecture
This section describes the security mechanisms implemented at the architectural level to protect data confidentiality, integrity, and system access.
API access control
Integrators access the device API using secure, credential-based authentication. Each integrator is assigned unique username and password pairs, which they use to log in via the API's authentication endpoint. Upon successful login, the API issues a signed JWT (JSON Web Token) that grants temporary access to clinical endpoints. This token is valid for a limited period; once it expires, the integrator must re-authenticate to obtain a new JWT and continue accessing the API. This mechanism ensures that only authorized users can interact with the device API, and that access is regularly validated.
User database access control
The DynamoDB table containing user records is protected through AWS IAM and the principle of least privilege:
- No long-lived credentials: The API service assumes a dedicated IAM role rather than using static credentials.
- Temporary credentials: AWS issues short-lived, automatically rotated credentials each time the role is assumed.
- Minimum permissions: The IAM role grants only the permissions required for user management operations.
- No direct external access: Only the API Gateway can access the user database; integrators and external systems have no direct connection to DynamoDB.
- Request signing: All requests to DynamoDB use AWS Signature Version 4, ensuring authenticity and integrity.
Audit log protection
Audit records are stored in a dedicated DynamoDB table with controls designed to ensure immutability and tamper resistance:
- Write-only access: The API service assumes a specialized IAM role that grants write permissions only—no read, modify, or delete operations are permitted.
- Append-only design: The API cannot modify or delete existing audit entries, preserving a reliable chronological record of system activity.
- No external access: Audit writes can only occur through the API service; no external system or integrator has direct access to the audit table.
- Request signing: All writes use AWS Signature Version 4, ensuring the authenticity and integrity of every audit record.
Software item decomposition
This section describes each software item in detail, including its responsibilities, constituent software units, SOUP dependencies, and interfaces with other software items. Each software item is presented using a consistent structure:
- Overview: Purpose and primary responsibilities
- Software units: Internal components that implement the software item's functionality
- SOUPs: Third-party libraries on which the software item depends
- Interfaces: Connections to other software items and external systems
System overview
The software system comprises five categories of software items:
- API Gateway, which exposes the device's functionalities to integrators through a RESTful API and handles authentication, authorization, and audit logging.
- Control Plane, which orchestrates the device's internal operations, manages requests, and coordinates interactions between the Expert Orchestrator and Report Builder.
- Expert Orchestrator, which coordinates the execution of expert services, routing analysis requests to the appropriate experts and aggregating their results.
- Report Builder, which transforms expert analysis results into canonical clinical reports with standardized medical terminology.
- Experts, which are individual software items that implement specific AI models for diagnosis support, severity assessment, and other clinical and non-clinical functionalities.
The following diagram illustrates the high-level decomposition of the software system and the relationships between its components:
API Gateway (User Interface)
The API Gateway software item provides an HTTP-based entry point that allows integrator applications to access the device's clinical services. It exposes RESTful endpoints for authentication, diagnosis support, severity assessment, and device information retrieval. All requests and responses use JSON format, and protected endpoints require JWT-based authentication. The API Gateway delegates clinical processing to the Control Plane and records all API calls for audit purposes.
The API Gateway is composed of the following software units:
-
HTTP Routes: FastAPI router modules (
auth,clinical,device,internal) that define endpoint handlers for authentication (/auth/login), clinical analysis (/clinical/diagnosis-support,/clinical/severity-assessment), device information (/device/about,/device/health), and internal status monitoring (/internal/status). -
Authentication Dependencies: Middleware components that extract and validate JWT bearer tokens from incoming requests and verify that the authenticated user is active in the system.
-
Use Cases: Application layer components (
LoginUseCase,DiagnosisUseCase,SeverityAssessmentUseCase,GetDeviceLegalInfoUseCase,GetDeviceHealthUseCase,GetDeviceStatusUseCase,RecordCallUseCase) that orchestrate business operations by coordinating domain services and outbound adapters. -
Domain Services: The
AccountSecurityServiceimplements account lockout policies, managing failed login attempts and determining when to lock accounts based on configurable thresholds. -
Outbound Adapters: Implementations of port interfaces including:
HTTPControlPlaneClient: HTTP client adapter that communicates with the Control Plane for clinical analysis requests and device information.DynamoDBUserRepository,DynamoDBLockoutRepository,DynamoDBCallRecordRepository: Persistence adapters for user accounts, lockout records, and API call audit logs.Argon2AuthenticationService: Password hashing and verification using the Argon2 algorithm.JwtTokenService: JWT generation and validation for access tokens.
-
Call Recording Middleware: A Starlette middleware (
CallRecorderMiddleware) that intercepts all API requests and responses, capturing metadata (timing, authentication context, HTTP details, client information) and asynchronously persisting audit records. -
Dependency Injection Container: A Dependency Injector container (
Container) that wires together all services, repositories, use cases, and configuration, ensuring proper initialization and dependency management.
SOUPs
The API Gateway leverages the following SOUP items:
- FastAPI: Web framework for building the HTTP API with automatic validation and OpenAPI documentation.
- Uvicorn: ASGI server for running the FastAPI application.
- Authlib: JWT encoding and decoding for access token generation and validation.
- Argon2-cffi: Secure password hashing using the Argon2 algorithm.
- HTTPX: Asynchronous HTTP client for communication with the Control Plane.
- aioboto3: Asynchronous AWS SDK client for DynamoDB operations.
- Pydantic: Data validation and settings management for request/response models and configuration.
- Dependency Injector: Dependency injection framework for wiring application components.