# goplasmatic/swiftmtmessage architecture

> Architecture diagram of the GitHub repository goplasmatic/swiftmtmessage, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/goplasmatic/swiftmtmessage
- Repository: https://github.com/goplasmatic/swiftmtmessage

## Overview

SwiftMTMessage is a Rust library for parsing, validating, and building SWIFT MT financial messages. The main workflow accepts a raw message through SwiftParser, extracts headers and fields, parses a selected message type into typed structures, and exposes the result for validation or serialization. Its domain coverage includes 30+ MT types and multi-sequence messages; separate capabilities include sample generation and dataflow plugin operations. The map follows documented architecture and sampled code; unsampled plugin and validation wiring is kept at subsystem level.

Main entry points: [`src/parser/swift_parser.rs`](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parser/swift_parser.rs) (SwiftParser), [`src/plugin/mod.rs`](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/mod.rs) (Plugin Registration), [`src/messages/mod.rs`](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/messages/mod.rs) (MT Message Types), [`src/sample.rs`](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/sample.rs) (Sample Generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_parse["Parsing"]
  node_swift_parser["SwiftParser<br/>[swift_parser.rs]"]
  node_block_parser["Field Extraction<br/>[field_extractor.rs]"]
  node_generated_parser["Tag Parsing<br/>[generated.rs]"]
  node_sequence_parser["Sequence Parsing<br/>[sequence_parser.rs]"]
end

subgraph group_domain["Message Domain"]
  node_headers["FIN Headers<br/>[mod.rs]"]
  node_message_types["MT Message Types<br/>[mod.rs]"]
  node_fields["Typed Fields<br/>[mod.rs]"]
  node_swift_message["SwiftMessage<br/>[swift_message.rs]"]
  node_parsed_message["Parsed Message Enum<br/>[parsed_message.rs]"]
end

subgraph group_validate["Validation"]
  node_validation["Network Validation"]
  node_error_codes["SWIFT Error Codes"]
  node_errors["Parse and Validation Errors<br/>[errors.rs]"]
end

subgraph group_generate["Generation"]
  node_sample_generator["Sample Generator<br/>[sample.rs]"]
  node_scenario_config["Scenario Configuration<br/>[scenario_config.rs]"]
end

subgraph group_plugin["Dataflow Plugin"]
  node_plugin_register["Plugin Registration<br/>[mod.rs]"]
  node_plugin_parse["Parse Handler<br/>[parse.rs]"]
  node_plugin_validate["Validate Handler<br/>[validate.rs]"]
  node_plugin_generate["Generate Handler<br/>[generate.rs]"]
  node_plugin_publish["Publish Handler<br/>[publish.rs]"]
end

node_caller(("Library Caller"))
node_raw["Raw MT Message"]
node_dataflow_engine["Dataflow Engine"]
node_result["Typed MT Result"]

node_caller -->|"provides"| node_raw
node_caller -->|"calls"| node_swift_parser
node_swift_parser -->|"parses headers"| node_headers
node_swift_parser -->|"extracts fields"| node_block_parser
node_block_parser -->|"normalizes tags"| node_generated_parser
node_swift_parser -->|"splits sequences"| node_sequence_parser
node_swift_parser -->|"parses as type"| node_message_types
node_message_types -->|"uses typed fields"| node_fields
node_message_types -->|"validates rules"| node_validation
node_validation -->|"reports codes"| node_error_codes
node_swift_parser -->|"returns failures"| node_errors
node_message_types -->|"forms message"| node_swift_message
node_swift_parser -->|"auto-detects type"| node_parsed_message
node_swift_parser -->|"returns parsed data"| node_result
node_caller -->|"requests samples"| node_sample_generator
node_sample_generator -->|"uses configuration"| node_scenario_config
node_sample_generator -->|"generates samples"| node_result
node_plugin_register -->|"registers"| node_plugin_parse
node_plugin_register -->|"registers"| node_plugin_validate
node_plugin_register -->|"registers"| node_plugin_generate
node_plugin_register -->|"registers"| node_plugin_publish
node_dataflow_engine -->|"registers functions"| node_plugin_register
node_dataflow_engine -->|"dispatches"| node_plugin_parse
node_dataflow_engine -->|"dispatches"| node_plugin_validate
node_dataflow_engine -->|"dispatches"| node_plugin_generate
node_dataflow_engine -->|"dispatches"| node_plugin_publish

click node_swift_parser "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parser/swift_parser.rs"
click node_block_parser "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parser/field_extractor.rs"
click node_generated_parser "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parser/generated.rs"
click node_sequence_parser "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parser/sequence_parser.rs"
click node_headers "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/headers/mod.rs"
click node_message_types "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/messages/mod.rs"
click node_fields "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/fields/mod.rs"
click node_swift_message "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/swift_message.rs"
click node_parsed_message "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parsed_message.rs"
click node_validation "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/validation_result.rs"
click node_error_codes "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/swift_error_codes.rs"
click node_errors "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/errors.rs"
click node_sample_generator "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/sample.rs"
click node_scenario_config "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/scenario_config.rs"
click node_plugin_register "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/mod.rs"
click node_plugin_parse "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/parse.rs"
click node_plugin_validate "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/validate.rs"
click node_plugin_generate "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/generate.rs"
click node_plugin_publish "https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/publish.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_swift_parser,node_block_parser,node_generated_parser,node_sequence_parser toneBlue
class node_headers,node_message_types,node_fields,node_swift_message,node_parsed_message toneAmber
class node_validation,node_error_codes,node_errors toneMint
class node_sample_generator,node_scenario_config toneRose
class node_plugin_register,node_plugin_parse,node_plugin_validate,node_plugin_generate,node_plugin_publish,node_caller,node_raw,node_dataflow_engine,node_result toneIndigo
```

## Components

### Parsing

- [SwiftParser](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parser/swift_parser.rs): `src/parser/swift_parser.rs`
- [Field Extraction](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parser/field_extractor.rs): `src/parser/field_extractor.rs`
- [Tag Parsing](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parser/generated.rs): `src/parser/generated.rs`
- [Sequence Parsing](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parser/sequence_parser.rs): `src/parser/sequence_parser.rs`

### Message Domain

- [FIN Headers](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/headers/mod.rs): `src/headers/mod.rs`
- [MT Message Types](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/messages/mod.rs): `src/messages/mod.rs`
- [Typed Fields](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/fields/mod.rs): `src/fields/mod.rs`
- [SwiftMessage](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/swift_message.rs): `src/swift_message.rs`
- [Parsed Message Enum](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/parsed_message.rs): `src/parsed_message.rs`

### Validation

- [Network Validation](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/validation_result.rs): `src/validation_result.rs`
- [SWIFT Error Codes](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/swift_error_codes.rs): `src/swift_error_codes.rs`
- [Parse and Validation Errors](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/errors.rs): `src/errors.rs`

### Generation

- [Sample Generator](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/sample.rs): `src/sample.rs`
- [Scenario Configuration](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/scenario_config.rs): `src/scenario_config.rs`

### Dataflow Plugin

- [Plugin Registration](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/mod.rs): `src/plugin/mod.rs`
- [Parse Handler](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/parse.rs): `src/plugin/parse.rs`
- [Validate Handler](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/validate.rs): `src/plugin/validate.rs`
- [Generate Handler](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/generate.rs): `src/plugin/generate.rs`
- [Publish Handler](https://github.com/goplasmatic/swiftmtmessage/blob/main/src/plugin/publish.rs): `src/plugin/publish.rs`

### Other components

- **Library Caller**
- **Raw MT Message**
- **Dataflow Engine**
- **Typed MT Result**

## Connections

- Library Caller → Raw MT Message: provides
- Library Caller → SwiftParser: calls
- SwiftParser → FIN Headers: parses headers
- SwiftParser → Field Extraction: extracts fields
- Field Extraction → Tag Parsing: normalizes tags
- SwiftParser → Sequence Parsing: splits sequences
- SwiftParser → MT Message Types: parses as type
- MT Message Types → Typed Fields: uses typed fields
- MT Message Types → Network Validation: validates rules
- Network Validation → SWIFT Error Codes: reports codes
- SwiftParser → Parse and Validation Errors: returns failures
- MT Message Types → SwiftMessage: forms message
- SwiftParser → Parsed Message Enum: auto-detects type
- SwiftParser → Typed MT Result: returns parsed data
- Library Caller → Sample Generator: requests samples
- Sample Generator → Scenario Configuration: uses configuration
- Sample Generator → Typed MT Result: generates samples
- Plugin Registration → Parse Handler: registers
- Plugin Registration → Validate Handler: registers
- Plugin Registration → Generate Handler: registers
- Plugin Registration → Publish Handler: registers
- Dataflow Engine → Plugin Registration: registers functions
- Dataflow Engine → Parse Handler: dispatches
- Dataflow Engine → Validate Handler: dispatches
- Dataflow Engine → Generate Handler: dispatches
- Dataflow Engine → Publish Handler: dispatches
