Software ArchitectureΒΆ

The software architecture defines the modular structure of the BrewMaster Pro 3000’s embedded control system. The architecture follows a layered approach with clear separation of concerns: safety-critical functions are isolated in dedicated modules, control algorithms are encapsulated for reusability, and user interface logic is decoupled from core brewing operations. This modular design enables independent testing, facilitates maintenance, and provides clear interfaces between components.

The architecture emphasizes fail-safe design principles. The Safety Monitor Module operates with the highest priority and can override all other subsystems. Module dependencies are carefully managed to prevent circular references and ensure deterministic behavior. The following diagram shows the architectural modules and their relationships:

LayersΒΆ

Static ViewΒΆ

@startuml

' Config

top to bottom direction


' Nodes definition 

package "<size:12>Architectural Layer</size>\n**Application**\n**Layer**\n<size:10>LAYER_APP</size>" as LAYER_APP [[../coffee-machine/architecture.html#LAYER_APP]] #8e44ad{
'child needs:
component "<size:12>Component</size>\n**Brew Controller**\n**Module**\n<size:10>COMP_BREW_CTRL</size>" as COMP_BREW_CTRL [[../coffee-machine/architecture.html#COMP_BREW_CTRL]] #3498db
component "<size:12>Component</size>\n**User Interface**\n**Module**\n<size:10>COMP_UI_MODULE</size>" as COMP_UI_MODULE [[../coffee-machine/architecture.html#COMP_UI_MODULE]] #3498db
interface "<size:12>Interface</size>\n**Brew Controller**\n**Safety Status**\n**Interface**\n<size:10>INTF_BREW_CTRL_STATUS</size>" as INTF_BREW_CTRL_STATUS [[../coffee-machine/architecture.html#INTF_BREW_CTRL_STATUS]] #16a085
interface "<size:12>Interface</size>\n**User Command**\n**Interface**\n<size:10>INTF_USER_CMD</size>" as INTF_USER_CMD [[../coffee-machine/architecture.html#INTF_USER_CMD]] #16a085
}
package "<size:12>Architectural Layer</size>\n**Control Layer**\n<size:10>LAYER_CTRL</size>" as LAYER_CTRL [[../coffee-machine/architecture.html#LAYER_CTRL]] #8e44ad{
'child needs:
component "<size:12>Component</size>\n**Temperature**\n**Controller**\n**Module**\n<size:10>COMP_TEMP_CTRL</size>" as COMP_TEMP_CTRL [[../coffee-machine/architecture.html#COMP_TEMP_CTRL]] #3498db
interface "<size:12>Interface</size>\n**Temperature**\n**Controller**\n**Safety Status**\n**Interface**\n<size:10>INTF_TEMP_CTRL_STATUS</size>" as INTF_TEMP_CTRL_STATUS [[../coffee-machine/architecture.html#INTF_TEMP_CTRL_STATUS]] #16a085
interface "<size:12>Interface</size>\n**Temperature**\n**Status**\n**Interface**\n<size:10>INTF_TEMP_STATUS</size>" as INTF_TEMP_STATUS [[../coffee-machine/architecture.html#INTF_TEMP_STATUS]] #16a085
}
package "<size:12>Architectural Layer</size>\n**Safety Layer**\n<size:10>LAYER_SAFETY</size>" as LAYER_SAFETY [[../coffee-machine/architecture.html#LAYER_SAFETY]] #8e44ad{
'child needs:
component "<size:12>Component</size>\n**Safety Monitor**\n**Module**\n<size:10>COMP_SAFETY_MON</size>" as COMP_SAFETY_MON [[../coffee-machine/architecture.html#COMP_SAFETY_MON]] #3498db
interface "<size:12>Interface</size>\n**Safety Command**\n**Interface**\n<size:10>INTF_SAFETY_CMD</size>" as INTF_SAFETY_CMD [[../coffee-machine/architecture.html#INTF_SAFETY_CMD]] #16a085
}
package "<size:12>Architectural Layer</size>\n**Hardware**\n**Abstraction**\n**Layer**\n<size:10>LAYER_HAL</size>" as LAYER_HAL [[../coffee-machine/architecture.html#LAYER_HAL]] #8e44ad{
'child needs:
component "<size:12>Component</size>\n**ADC Driver**\n<size:10>COMP_ADC_DRV</size>" as COMP_ADC_DRV [[../coffee-machine/architecture.html#COMP_ADC_DRV]] #3498db
component "<size:12>Component</size>\n**GPIO Driver**\n<size:10>COMP_GPIO_DRV</size>" as COMP_GPIO_DRV [[../coffee-machine/architecture.html#COMP_GPIO_DRV]] #3498db
component "<size:12>Component</size>\n**PWM Driver**\n<size:10>COMP_PWM_DRV</size>" as COMP_PWM_DRV [[../coffee-machine/architecture.html#COMP_PWM_DRV]] #3498db
component "<size:12>Component</size>\n**SPI Driver**\n<size:10>COMP_SPI_DRV</size>" as COMP_SPI_DRV [[../coffee-machine/architecture.html#COMP_SPI_DRV]] #3498db
interface "<size:12>Interface</size>\n**GPIO Interface**\n<size:10>INTF_GPIO</size>" as INTF_GPIO [[../coffee-machine/architecture.html#INTF_GPIO]] #16a085
interface "<size:12>Interface</size>\n**PWM Control**\n**Interface**\n<size:10>INTF_PWM_CTRL</size>" as INTF_PWM_CTRL [[../coffee-machine/architecture.html#INTF_PWM_CTRL]] #16a085
interface "<size:12>Interface</size>\n**Sensor Data**\n**Interface**\n<size:10>INTF_SENSOR_DATA</size>" as INTF_SENSOR_DATA [[../coffee-machine/architecture.html#INTF_SENSOR_DATA]] #16a085
interface "<size:12>Interface</size>\n**SPI Bus**\n**Interface**\n<size:10>INTF_SPI_BUS</size>" as INTF_SPI_BUS [[../coffee-machine/architecture.html#INTF_SPI_BUS]] #16a085
}

' Connection definition 

COMP_UI_MODULE -[dashed]-( INTF_GPIO: uses\n
COMP_UI_MODULE -[dashed]-( INTF_SPI_BUS: uses\n
COMP_BREW_CTRL -[dashed]-( INTF_GPIO: uses\n
COMP_BREW_CTRL -[dashed]-( INTF_SAFETY_CMD: uses\n
COMP_BREW_CTRL -[dashed]-( INTF_TEMP_STATUS: uses\n
COMP_BREW_CTRL -[dashed]-( INTF_USER_CMD: uses\n
COMP_TEMP_CTRL -[dashed]-( INTF_PWM_CTRL: uses\n
COMP_TEMP_CTRL -[dashed]-( INTF_SAFETY_CMD: uses\n
COMP_TEMP_CTRL -[dashed]-( INTF_SENSOR_DATA: uses\n
COMP_SAFETY_MON -[dashed]-( INTF_BREW_CTRL_STATUS: uses\n
COMP_SAFETY_MON -[dashed]-( INTF_SENSOR_DATA: uses\n
COMP_SAFETY_MON -[dashed]-( INTF_TEMP_CTRL_STATUS: uses\n
INTF_USER_CMD -[bold]- COMP_UI_MODULE: provided by\n
INTF_BREW_CTRL_STATUS -[bold]- COMP_BREW_CTRL: provided by\n
INTF_TEMP_STATUS -[bold]- COMP_TEMP_CTRL: provided by\n
INTF_TEMP_CTRL_STATUS -[bold]- COMP_TEMP_CTRL: provided by\n
INTF_SAFETY_CMD -[bold]- COMP_SAFETY_MON: provided by\n
INTF_PWM_CTRL -[bold]- COMP_PWM_DRV: provided by\n
INTF_GPIO -[bold]- COMP_GPIO_DRV: provided by\n
INTF_SPI_BUS -[bold]- COMP_SPI_DRV: provided by\n
INTF_SENSOR_DATA -[bold]- COMP_ADC_DRV: provided by\n

@enduml

Dynamic ViewΒΆ

The sequence diagrams below show how the architectural components interact at runtime. Participants map directly to the components defined in the Static View.

The diagrams are generated by needsequence, which traverses the startup_calls / shutdown_calls links defined on each component need. Each seq_msg (SEQSTART_01) need in the chain represents one message; odd hops are participants, even hops are messages.

Startup SequenceΒΆ

On power-on the system initialises hardware, validates initial sensor readings, then brings all control modules online in dependency order before signalling readiness to the user.

The sequence message needs (SEQSTART_01–SEQSTART_10) are defined below. COMP_UI_MODULE is the starting participant.

Startup Sequence Messages

@startuml

' Nodes definition 

participant "User Interface Module" as COMP_UI_MODULE
participant "ADC Driver" as COMP_ADC_DRV
participant "Safety Monitor Module" as COMP_SAFETY_MON
participant "Temperature Controller Module" as COMP_TEMP_CTRL
participant "Brew Controller Module" as COMP_BREW_CTRL

' Connection definition 

COMP_UI_MODULE -> COMP_ADC_DRV: init()
COMP_ADC_DRV -> COMP_UI_MODULE: init_ok
COMP_ADC_DRV -> COMP_SAFETY_MON: temp=22Β°C, water_level=85%
COMP_SAFETY_MON -> COMP_ADC_DRV: read_sensors()
COMP_SAFETY_MON -> COMP_TEMP_CTRL: start() β€” Temp Controller
COMP_TEMP_CTRL -> COMP_SAFETY_MON: started (INTF_TEMP_CTRL_STATUS heartbeat)
COMP_SAFETY_MON -> COMP_BREW_CTRL: start() β€” Brew Controller
COMP_BREW_CTRL -> COMP_SAFETY_MON: started (INTF_BREW_CTRL_STATUS heartbeat)
COMP_SAFETY_MON -> COMP_UI_MODULE: system_ready
COMP_UI_MODULE -> COMP_SAFETY_MON: start() β€” Safety Monitor

@enduml

Startup SequenceΒΆ

Safety Shutdown SequenceΒΆ

If the Safety Monitor detects an over-temperature condition it issues an EMERGENCY_STOP command on INTF_SAFETY_CMD to all controlled subsystems. All modules must respond within 100 ms.

The sequence message needs (SEQSHTDWN_01–SEQSHTDWN_06) are defined below. COMP_ADC_DRV is the starting participant (it is the source of the over-temperature sensor reading).

Safety Shutdown Sequence Messages

@startuml

' Nodes definition 

participant "ADC Driver" as COMP_ADC_DRV
participant "Safety Monitor Module" as COMP_SAFETY_MON
participant "Temperature Controller Module" as COMP_TEMP_CTRL
participant "Brew Controller Module" as COMP_BREW_CTRL

' Connection definition 

COMP_ADC_DRV -> COMP_SAFETY_MON: temp=102Β°C (INTF_SENSOR_DATA β€” over-temp)
COMP_SAFETY_MON -> COMP_TEMP_CTRL: EMERGENCY_STOP β†’ Temp Controller
COMP_TEMP_CTRL -> COMP_SAFETY_MON: fault_flags=OVERTEMP (INTF_TEMP_CTRL_STATUS)
COMP_SAFETY_MON -> COMP_BREW_CTRL: EMERGENCY_STOP β†’ Brew Controller
COMP_BREW_CTRL -> COMP_SAFETY_MON: fault_flags=ABORT (INTF_BREW_CTRL_STATUS)
COMP_SAFETY_MON -> COMP_UI_MODULE: fault_event(OVERTEMP)

@enduml

Safety Shutdown SequenceΒΆ