smart_message 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/deploy-github-pages.yml +38 -0
  3. data/.gitignore +5 -0
  4. data/CHANGELOG.md +30 -0
  5. data/Gemfile.lock +35 -4
  6. data/README.md +169 -71
  7. data/Rakefile +29 -4
  8. data/docs/assets/images/ddq_architecture.svg +130 -0
  9. data/docs/assets/images/dlq_architecture.svg +115 -0
  10. data/docs/assets/images/enhanced-dual-publishing.svg +136 -0
  11. data/docs/assets/images/enhanced-fluent-api.svg +149 -0
  12. data/docs/assets/images/enhanced-microservices-routing.svg +115 -0
  13. data/docs/assets/images/enhanced-pattern-matching.svg +107 -0
  14. data/docs/assets/images/fluent-api-demo.svg +59 -0
  15. data/docs/assets/images/performance-comparison.svg +161 -0
  16. data/docs/assets/images/redis-basic-architecture.svg +53 -0
  17. data/docs/assets/images/redis-enhanced-architecture.svg +88 -0
  18. data/docs/assets/images/redis-queue-architecture.svg +101 -0
  19. data/docs/assets/images/smart_message.jpg +0 -0
  20. data/docs/assets/images/smart_message_walking.jpg +0 -0
  21. data/docs/assets/images/smartmessage_architecture_overview.svg +173 -0
  22. data/docs/assets/images/transport-comparison-matrix.svg +171 -0
  23. data/docs/assets/javascripts/mathjax.js +17 -0
  24. data/docs/assets/stylesheets/extra.css +51 -0
  25. data/docs/{addressing.md → core-concepts/addressing.md} +5 -7
  26. data/docs/{architecture.md → core-concepts/architecture.md} +78 -138
  27. data/docs/{dispatcher.md → core-concepts/dispatcher.md} +21 -21
  28. data/docs/{message_filtering.md → core-concepts/message-filtering.md} +2 -3
  29. data/docs/{message_processing.md → core-concepts/message-processing.md} +17 -17
  30. data/docs/{troubleshooting.md → development/troubleshooting.md} +7 -7
  31. data/docs/{examples.md → getting-started/examples.md} +115 -89
  32. data/docs/{getting-started.md → getting-started/quick-start.md} +47 -18
  33. data/docs/guides/redis-queue-getting-started.md +697 -0
  34. data/docs/guides/redis-queue-patterns.md +889 -0
  35. data/docs/guides/redis-queue-production.md +1091 -0
  36. data/docs/index.md +64 -0
  37. data/docs/{dead_letter_queue.md → reference/dead-letter-queue.md} +2 -3
  38. data/docs/{logging.md → reference/logging.md} +1 -1
  39. data/docs/{message_deduplication.md → reference/message-deduplication.md} +1 -0
  40. data/docs/{proc_handlers_summary.md → reference/proc-handlers.md} +7 -6
  41. data/docs/{serializers.md → reference/serializers.md} +3 -5
  42. data/docs/{transports.md → reference/transports.md} +133 -11
  43. data/docs/transports/memory-transport.md +374 -0
  44. data/docs/transports/redis-enhanced-transport.md +524 -0
  45. data/docs/transports/redis-queue-transport.md +1304 -0
  46. data/docs/transports/redis-transport-comparison.md +496 -0
  47. data/docs/transports/redis-transport.md +509 -0
  48. data/examples/README.md +98 -5
  49. data/examples/city_scenario/911_emergency_call_flow.svg +99 -0
  50. data/examples/city_scenario/README.md +515 -0
  51. data/examples/city_scenario/ai_visitor_intelligence_flow.svg +108 -0
  52. data/examples/city_scenario/citizen.rb +195 -0
  53. data/examples/city_scenario/city_diagram.svg +125 -0
  54. data/examples/city_scenario/common/health_monitor.rb +80 -0
  55. data/examples/city_scenario/common/logger.rb +30 -0
  56. data/examples/city_scenario/emergency_dispatch_center.rb +270 -0
  57. data/examples/city_scenario/fire_department.rb +446 -0
  58. data/examples/city_scenario/fire_emergency_flow.svg +95 -0
  59. data/examples/city_scenario/health_department.rb +100 -0
  60. data/examples/city_scenario/health_monitoring_system.svg +130 -0
  61. data/examples/city_scenario/house.rb +244 -0
  62. data/examples/city_scenario/local_bank.rb +217 -0
  63. data/examples/city_scenario/messages/emergency_911_message.rb +81 -0
  64. data/examples/city_scenario/messages/emergency_resolved_message.rb +43 -0
  65. data/examples/city_scenario/messages/fire_dispatch_message.rb +43 -0
  66. data/examples/city_scenario/messages/fire_emergency_message.rb +45 -0
  67. data/examples/city_scenario/messages/health_check_message.rb +22 -0
  68. data/examples/city_scenario/messages/health_status_message.rb +35 -0
  69. data/examples/city_scenario/messages/police_dispatch_message.rb +46 -0
  70. data/examples/city_scenario/messages/silent_alarm_message.rb +38 -0
  71. data/examples/city_scenario/police_department.rb +316 -0
  72. data/examples/city_scenario/redis_monitor.rb +129 -0
  73. data/examples/city_scenario/redis_stats.rb +743 -0
  74. data/examples/city_scenario/room_for_improvement.md +240 -0
  75. data/examples/city_scenario/security_emergency_flow.svg +95 -0
  76. data/examples/city_scenario/service_internal_architecture.svg +154 -0
  77. data/examples/city_scenario/smart_message_ai_agent.rb +364 -0
  78. data/examples/city_scenario/start_demo.sh +236 -0
  79. data/examples/city_scenario/stop_demo.sh +106 -0
  80. data/examples/city_scenario/visitor.rb +631 -0
  81. data/examples/{10_message_deduplication.rb → memory/01_message_deduplication_demo.rb} +1 -1
  82. data/examples/{09_dead_letter_queue_demo.rb → memory/02_dead_letter_queue_demo.rb} +13 -40
  83. data/examples/{01_point_to_point_orders.rb → memory/03_point_to_point_orders.rb} +1 -1
  84. data/examples/{02_publish_subscribe_events.rb → memory/04_publish_subscribe_events.rb} +2 -2
  85. data/examples/{03_many_to_many_chat.rb → memory/05_many_to_many_chat.rb} +4 -4
  86. data/examples/{show_me.rb → memory/06_pretty_print_demo.rb} +1 -1
  87. data/examples/{05_proc_handlers.rb → memory/07_proc_handlers_demo.rb} +2 -2
  88. data/examples/{06_custom_logger_example.rb → memory/08_custom_logger_demo.rb} +17 -14
  89. data/examples/{07_error_handling_scenarios.rb → memory/09_error_handling_demo.rb} +4 -4
  90. data/examples/{08_entity_addressing_basic.rb → memory/10_entity_addressing_basic.rb} +8 -8
  91. data/examples/{08_entity_addressing_with_filtering.rb → memory/11_entity_addressing_with_filtering.rb} +6 -6
  92. data/examples/{09_regex_filtering_microservices.rb → memory/12_regex_filtering_microservices.rb} +2 -2
  93. data/examples/{10_header_block_configuration.rb → memory/13_header_block_configuration.rb} +6 -6
  94. data/examples/{11_global_configuration_example.rb → memory/14_global_configuration_demo.rb} +19 -8
  95. data/examples/{show_logger.rb → memory/15_logger_demo.rb} +1 -1
  96. data/examples/memory/README.md +163 -0
  97. data/examples/memory/memory_transport_architecture.svg +90 -0
  98. data/examples/memory/point_to_point_pattern.svg +94 -0
  99. data/examples/memory/publish_subscribe_pattern.svg +125 -0
  100. data/examples/{04_redis_smart_home_iot.rb → redis/01_smart_home_iot_demo.rb} +5 -5
  101. data/examples/redis/README.md +230 -0
  102. data/examples/redis/alert_system_flow.svg +127 -0
  103. data/examples/redis/dashboard_status_flow.svg +107 -0
  104. data/examples/redis/device_command_flow.svg +113 -0
  105. data/examples/redis/redis_transport_architecture.svg +115 -0
  106. data/examples/{smart_home_iot_dataflow.md → redis/smart_home_iot_dataflow.md} +4 -116
  107. data/examples/redis/smart_home_system_architecture.svg +133 -0
  108. data/examples/redis_enhanced/README.md +319 -0
  109. data/examples/redis_enhanced/enhanced_01_basic_patterns.rb +233 -0
  110. data/examples/redis_enhanced/enhanced_02_fluent_api.rb +331 -0
  111. data/examples/redis_enhanced/enhanced_03_dual_publishing.rb +281 -0
  112. data/examples/redis_enhanced/enhanced_04_advanced_routing.rb +419 -0
  113. data/examples/redis_queue/01_basic_messaging.rb +221 -0
  114. data/examples/redis_queue/01_comprehensive_examples.rb +508 -0
  115. data/examples/redis_queue/02_pattern_routing.rb +405 -0
  116. data/examples/redis_queue/03_fluent_api.rb +422 -0
  117. data/examples/redis_queue/04_load_balancing.rb +486 -0
  118. data/examples/redis_queue/05_microservices.rb +735 -0
  119. data/examples/redis_queue/06_emergency_alerts.rb +777 -0
  120. data/examples/redis_queue/07_queue_management.rb +587 -0
  121. data/examples/redis_queue/README.md +366 -0
  122. data/examples/redis_queue/enhanced_01_basic_patterns.rb +233 -0
  123. data/examples/redis_queue/enhanced_02_fluent_api.rb +331 -0
  124. data/examples/redis_queue/enhanced_03_dual_publishing.rb +281 -0
  125. data/examples/redis_queue/enhanced_04_advanced_routing.rb +419 -0
  126. data/examples/redis_queue/redis_queue_architecture.svg +148 -0
  127. data/ideas/README.md +41 -0
  128. data/ideas/agents.md +1001 -0
  129. data/ideas/database_transport.md +980 -0
  130. data/ideas/improvement.md +359 -0
  131. data/ideas/meshage.md +1788 -0
  132. data/ideas/message_discovery.md +178 -0
  133. data/ideas/message_schema.md +1381 -0
  134. data/lib/smart_message/.idea/.gitignore +8 -0
  135. data/lib/smart_message/.idea/markdown.xml +6 -0
  136. data/lib/smart_message/.idea/misc.xml +4 -0
  137. data/lib/smart_message/.idea/modules.xml +8 -0
  138. data/lib/smart_message/.idea/smart_message.iml +16 -0
  139. data/lib/smart_message/.idea/vcs.xml +6 -0
  140. data/lib/smart_message/addressing.rb +15 -0
  141. data/lib/smart_message/base.rb +0 -2
  142. data/lib/smart_message/configuration.rb +1 -1
  143. data/lib/smart_message/logger.rb +15 -4
  144. data/lib/smart_message/plugins.rb +5 -2
  145. data/lib/smart_message/serializer.rb +14 -0
  146. data/lib/smart_message/transport/redis_enhanced_transport.rb +399 -0
  147. data/lib/smart_message/transport/redis_queue_transport.rb +555 -0
  148. data/lib/smart_message/transport/registry.rb +1 -0
  149. data/lib/smart_message/transport.rb +34 -1
  150. data/lib/smart_message/version.rb +1 -1
  151. data/lib/smart_message.rb +5 -52
  152. data/mkdocs.yml +184 -0
  153. data/p2p_plan.md +326 -0
  154. data/p2p_roadmap.md +287 -0
  155. data/smart_message.gemspec +2 -0
  156. data/smart_message.svg +51 -0
  157. metadata +170 -44
  158. data/docs/README.md +0 -57
  159. data/examples/dead_letters.jsonl +0 -12
  160. data/examples/temp.txt +0 -94
  161. data/examples/tmux_chat/README.md +0 -283
  162. data/examples/tmux_chat/bot_agent.rb +0 -278
  163. data/examples/tmux_chat/human_agent.rb +0 -199
  164. data/examples/tmux_chat/room_monitor.rb +0 -160
  165. data/examples/tmux_chat/shared_chat_system.rb +0 -328
  166. data/examples/tmux_chat/start_chat_demo.sh +0 -190
  167. data/examples/tmux_chat/stop_chat_demo.sh +0 -22
  168. /data/docs/{properties.md → core-concepts/properties.md} +0 -0
  169. /data/docs/{ideas_to_think_about.md → development/ideas.md} +0 -0
@@ -0,0 +1,240 @@
1
+ # Room for Improvement - Common Patterns Analysis
2
+
3
+ ## Overview
4
+ Analysis of Ruby service implementations in the multi_program_demo identified several common patterns that could be extracted into reusable mixin modules to reduce code duplication and improve maintainability.
5
+
6
+ ## Common Patterns Identified
7
+
8
+ ### 1. Signal Handlers (100% Duplication)
9
+ All services have identical signal handler setup code:
10
+ ```ruby
11
+ def setup_signal_handlers
12
+ %w[INT TERM].each do |signal|
13
+ Signal.trap(signal) do
14
+ puts "\n[emoji] Service shutting down..."
15
+ logger.info("Service shutting down")
16
+ exit(0)
17
+ end
18
+ end
19
+ end
20
+ ```
21
+ **Files affected:** All 6 service files
22
+
23
+ ### 2. Message Header Configuration
24
+ Services follow similar patterns for setting message headers:
25
+ - Setting `from` attribute on message classes
26
+ - Publishing with `_sm_header.from` and `_sm_header.to` assignments
27
+ - Consistent header manipulation patterns
28
+
29
+ **Files affected:** All services that publish messages
30
+
31
+ ### 3. Active Incident Management
32
+ Fire Department and Police Department share nearly identical patterns:
33
+ - Hash tracking active incidents (`@active_fires`, `@active_incidents`)
34
+ - Resolution checking loops with duration-based logic
35
+ - Unit assignment and return-to-pool mechanisms
36
+ - Publishing `EmergencyResolvedMessage` when resolved
37
+
38
+ **Shared logic:**
39
+ - `check_fire_resolutions` / `check_incident_resolutions`
40
+ - `resolve_fire` / `resolve_incident`
41
+ - Unit assignment based on severity
42
+ - Duration-based resolution (10-15 seconds)
43
+
44
+ ### 4. Resource Unit Management
45
+ Both emergency services track and manage available units:
46
+ ```ruby
47
+ # Fire Department
48
+ @available_engines = ['Engine-1', 'Engine-2', 'Engine-3', 'Ladder-1', 'Rescue-1']
49
+ assigned_engines = @available_engines.take(engines_needed)
50
+ @available_engines = @available_engines.drop(engines_needed)
51
+
52
+ # Police Department
53
+ @available_units = ['Unit-101', 'Unit-102', 'Unit-103', 'Unit-104']
54
+ assigned_units = @available_units.take(units_needed)
55
+ @available_units = @available_units.drop(units_needed)
56
+ ```
57
+
58
+ ### 5. Dispatch Response Handling
59
+ House and LocalBank handle dispatch responses similarly:
60
+ - Display colored output based on priority/severity
61
+ - Log response details
62
+ - Start resolution thread with random delay
63
+ - Update internal state when resolved
64
+
65
+ ### 6. Service Status Pattern
66
+ All services maintain consistent status tracking:
67
+ - `@service_name` instance variable
68
+ - `@status` instance variable ('healthy', 'warning', 'critical', 'failed')
69
+ - `@start_time` timestamp
70
+ - Status determination logic based on service-specific conditions
71
+
72
+ ### 7. Main Service Loop
73
+ Most services share similar loop structure:
74
+ ```ruby
75
+ def start_service/start_monitoring/start_operations
76
+ loop do
77
+ # Service-specific activity
78
+ sleep(interval)
79
+ end
80
+ rescue => e
81
+ puts "[emoji] Error in service: #{e.message}"
82
+ logger.error("Error in service: #{e.message}")
83
+ retry
84
+ end
85
+ ```
86
+
87
+ ## Recommended New Mixin Modules
88
+
89
+ ### 1. **Common::SignalHandler**
90
+ **Priority: HIGH** - 100% code duplication
91
+ ```ruby
92
+ module Common
93
+ module SignalHandler
94
+ def setup_signal_handlers
95
+ %w[INT TERM].each do |signal|
96
+ Signal.trap(signal) do
97
+ shutdown_message
98
+ exit(0)
99
+ end
100
+ end
101
+ end
102
+
103
+ def shutdown_message
104
+ puts "\n#{service_emoji} #{@service_name} shutting down..."
105
+ logger.info("#{@service_name} shutting down")
106
+ end
107
+ end
108
+ end
109
+ ```
110
+
111
+ ### 2. **Common::IncidentManager**
112
+ **Priority: HIGH** - Significant shared logic between Fire/Police
113
+ ```ruby
114
+ module Common
115
+ module IncidentManager
116
+ def initialize_incident_tracking
117
+ @active_incidents = {}
118
+ @available_units = []
119
+ end
120
+
121
+ def assign_units(units_needed)
122
+ units_needed = [@available_units.size, units_needed].min
123
+ assigned = @available_units.shift(units_needed)
124
+ assigned
125
+ end
126
+
127
+ def return_units(units)
128
+ @available_units.concat(units)
129
+ end
130
+
131
+ def check_incident_resolutions(base_duration = 10..15)
132
+ @active_incidents.each do |id, incident|
133
+ duration = (Time.now - incident[:start_time]).to_i
134
+ if duration > rand(base_duration)
135
+ resolve_incident(id, incident, duration)
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
141
+ ```
142
+
143
+ ### 3. **Common::MessageSetup**
144
+ **Priority: MEDIUM** - Reduces boilerplate
145
+ ```ruby
146
+ module Common
147
+ module MessageSetup
148
+ def setup_message_defaults(*message_classes)
149
+ message_classes.each do |klass|
150
+ klass.from = @service_name
151
+ end
152
+ end
153
+
154
+ def publish_with_headers(message, to: nil)
155
+ message._sm_header.from = @service_name
156
+ message._sm_header.to = to if to
157
+ message.publish
158
+ end
159
+ end
160
+ end
161
+ ```
162
+
163
+ ### 4. **Common::DispatchResponder**
164
+ **Priority: MEDIUM** - Shared by House and Bank
165
+ ```ruby
166
+ module Common
167
+ module DispatchResponder
168
+ def handle_dispatch_response(dispatch, dispatch_type)
169
+ display_dispatch(dispatch, dispatch_type)
170
+ log_dispatch(dispatch, dispatch_type)
171
+ start_resolution_thread(dispatch)
172
+ end
173
+
174
+ private
175
+
176
+ def display_dispatch(dispatch, type)
177
+ # Colored output logic
178
+ end
179
+
180
+ def start_resolution_thread(dispatch)
181
+ Thread.new do
182
+ sleep(rand(180..600))
183
+ resolve_dispatch(dispatch)
184
+ end
185
+ end
186
+ end
187
+ end
188
+ ```
189
+
190
+ ### 5. **Common::ServiceLoop**
191
+ **Priority: LOW** - Minor benefit
192
+ ```ruby
193
+ module Common
194
+ module ServiceLoop
195
+ def run_service_loop(activity_method, sleep_interval)
196
+ loop do
197
+ send(activity_method)
198
+ sleep(sleep_interval)
199
+ end
200
+ rescue => e
201
+ handle_service_error(e)
202
+ retry
203
+ end
204
+
205
+ def handle_service_error(error)
206
+ puts "#{service_emoji} Error in #{@service_name}: #{error.message}"
207
+ logger.error("Error in #{@service_name}: #{error.message}")
208
+ end
209
+ end
210
+ end
211
+ ```
212
+
213
+ ## Implementation Priority
214
+
215
+ 1. **Immediate Implementation:**
216
+ - `Common::SignalHandler` - Zero risk, 100% duplication
217
+ - `Common::IncidentManager` - High value for Fire/Police departments
218
+
219
+ 2. **Next Phase:**
220
+ - `Common::MessageSetup` - Simplifies message handling
221
+ - `Common::DispatchResponder` - Consolidates House/Bank response logic
222
+
223
+ 3. **Consider Later:**
224
+ - `Common::ServiceLoop` - Minor improvement, may reduce flexibility
225
+
226
+ ## Benefits of Refactoring
227
+
228
+ - **Reduced Code Duplication:** ~200-300 lines of duplicated code can be eliminated
229
+ - **Consistency:** Ensures all services handle common operations identically
230
+ - **Maintainability:** Bug fixes and improvements in one place benefit all services
231
+ - **Testability:** Common behaviors can be tested once in isolation
232
+ - **Onboarding:** New developers can understand patterns more quickly
233
+
234
+ ## Migration Strategy
235
+
236
+ 1. Start with `Common::SignalHandler` as a proof of concept
237
+ 2. Test thoroughly with one service before applying to all
238
+ 3. Implement one mixin at a time to avoid breaking changes
239
+ 4. Keep service-specific behavior in the service classes
240
+ 5. Document the mixins clearly for future developers
@@ -0,0 +1,95 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="700" height="500" viewBox="0 0 700 500" xmlns="http://www.w3.org/2000/svg">
3
+ <defs>
4
+ <style>
5
+ .bg { fill: transparent; }
6
+ .bank { fill: #3a2a1a; stroke: #ffcc4a; stroke-width: 2; rx: 8; }
7
+ .police { fill: #1a2a3a; stroke: #4aafff; stroke-width: 2; rx: 8; }
8
+ .all-services { fill: #2a2a3a; stroke: #4a9eff; stroke-width: 2; rx: 8; }
9
+ .message { stroke: #ff4a9e; stroke-width: 3; fill: none; marker-end: url(#arrowhead); }
10
+ .broadcast { stroke: #4aff4a; stroke-width: 2; fill: none; marker-end: url(#arrowhead-green); }
11
+ .text { fill: #ffffff; font-family: 'Arial', sans-serif; font-size: 12px; }
12
+ .title { fill: #4a9eff; font-family: 'Arial', sans-serif; font-size: 18px; font-weight: bold; }
13
+ .subtitle { fill: #ffaa4a; font-family: 'Arial', sans-serif; font-size: 11px; }
14
+ .note { fill: #aaaaaa; font-family: 'Arial', sans-serif; font-size: 10px; }
15
+ .process { fill: #2a1a3a; stroke: #4aafff; stroke-width: 1; rx: 4; }
16
+ </style>
17
+ <marker id="arrowhead" markerWidth="8" markerHeight="6"
18
+ refX="8" refY="3" orient="auto">
19
+ <polygon points="0 0, 8 3, 0 6" fill="#ff4a9e" />
20
+ </marker>
21
+ <marker id="arrowhead-green" markerWidth="8" markerHeight="6"
22
+ refX="8" refY="3" orient="auto">
23
+ <polygon points="0 0, 8 3, 0 6" fill="#4aff4a" />
24
+ </marker>
25
+ </defs>
26
+
27
+ <!-- Background -->
28
+ <rect class="bg" width="700" height="500"/>
29
+
30
+ <!-- Title -->
31
+ <text x="350" y="25" text-anchor="middle" class="title">Security Emergency Flow</text>
32
+ <text x="350" y="45" text-anchor="middle" class="subtitle">Bank Robbery Detection and Police Response</text>
33
+
34
+ <!-- Participants -->
35
+ <rect x="50" y="80" width="120" height="80" class="bank"/>
36
+ <text x="110" y="105" text-anchor="middle" class="text">🏦 Bank</text>
37
+ <text x="110" y="125" text-anchor="middle" class="subtitle">Security System</text>
38
+ <text x="110" y="145" text-anchor="middle" class="subtitle">Silent Alarm</text>
39
+
40
+ <rect x="290" y="80" width="120" height="80" class="police"/>
41
+ <text x="350" y="105" text-anchor="middle" class="text">👮 Police</text>
42
+ <text x="350" y="125" text-anchor="middle" class="text">Department</text>
43
+ <text x="350" y="145" text-anchor="middle" class="subtitle">Law Enforcement</text>
44
+
45
+ <rect x="530" y="80" width="120" height="80" class="all-services"/>
46
+ <text x="590" y="105" text-anchor="middle" class="text">📢 All Services</text>
47
+ <text x="590" y="125" text-anchor="middle" class="subtitle">City Emergency</text>
48
+ <text x="590" y="145" text-anchor="middle" class="subtitle">Network</text>
49
+
50
+ <!-- Vertical lifelines -->
51
+ <line x1="110" y1="160" x2="110" y2="450" stroke="#666" stroke-width="2" stroke-dasharray="3,3"/>
52
+ <line x1="350" y1="160" x2="350" y2="450" stroke="#666" stroke-width="2" stroke-dasharray="3,3"/>
53
+ <line x1="590" y1="160" x2="590" y2="450" stroke="#666" stroke-width="2" stroke-dasharray="3,3"/>
54
+
55
+ <!-- Message Flow -->
56
+ <!-- 1. Silent alarm triggered -->
57
+ <path d="M 110 200 L 350 200" class="message"/>
58
+ <text x="230" y="195" text-anchor="middle" class="text">SilentAlarmMessage</text>
59
+ <rect x="160" y="210" width="140" height="50" fill="#1a1a1a" stroke="#ff4a9e" rx="4"/>
60
+ <text x="230" y="225" text-anchor="middle" class="note">Robbery detected</text>
61
+ <text x="230" y="240" text-anchor="middle" class="note">Alarm type: break_in/robbery</text>
62
+ <text x="230" y="255" text-anchor="middle" class="note">Threat level: high/critical</text>
63
+
64
+ <!-- 2. Police assessment -->
65
+ <rect x="290" y="280" width="120" height="30" class="process"/>
66
+ <text x="350" y="300" text-anchor="middle" class="note">Assess threat level</text>
67
+
68
+ <rect x="290" y="320" width="120" height="40" class="process"/>
69
+ <text x="350" y="340" text-anchor="middle" class="note">Assign units:</text>
70
+ <text x="350" y="355" text-anchor="middle" class="note">Unit-101, Unit-102, SWAT</text>
71
+
72
+ <!-- 3. Police dispatch broadcast -->
73
+ <path d="M 350 380 L 590 380" class="broadcast"/>
74
+ <text x="470" y="375" text-anchor="middle" class="text">PoliceDispatchMessage</text>
75
+ <rect x="420" y="390" width="120" height="40" fill="#2a3a2a" stroke="#4aff4a" rx="4"/>
76
+ <text x="480" y="405" text-anchor="middle" class="note">Units dispatched</text>
77
+ <text x="480" y="420" text-anchor="middle" class="note">Priority: emergency/critical</text>
78
+
79
+ <!-- 4. Resolution broadcast -->
80
+ <path d="M 350 440 L 590 440" class="broadcast"/>
81
+ <text x="470" y="435" text-anchor="middle" class="text">EmergencyResolvedMessage</text>
82
+ <text x="470" y="455" text-anchor="middle" class="note">Suspects apprehended • Scene secure</text>
83
+
84
+ <!-- Process flow indicators -->
85
+ <circle cx="350" cy="320" r="3" fill="#4aafff"/>
86
+ <circle cx="350" cy="350" r="3" fill="#4aafff"/>
87
+
88
+ <!-- Police units details -->
89
+ <rect x="50" y="380" width="200" height="80" fill="#1a1a1a" stroke="#4aafff" rx="6"/>
90
+ <text x="60" y="400" class="text">Police Department Units:</text>
91
+ <text x="60" y="415" class="note">• Unit-101: First response patrol</text>
92
+ <text x="60" y="430" class="note">• Unit-102: Backup patrol unit</text>
93
+ <text x="60" y="445" class="note">• Detective-1: Investigation specialist</text>
94
+ <text x="60" y="460" class="note">• SWAT-Alpha: Tactical response team</text>
95
+ </svg>
@@ -0,0 +1,154 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="900" height="700" viewBox="0 0 900 700" xmlns="http://www.w3.org/2000/svg">
3
+ <defs>
4
+ <style>
5
+ .bg { fill: transparent; }
6
+ .dispatch-group { fill: #2a1a1a; stroke: #ff4a4a; stroke-width: 2; rx: 12; }
7
+ .citizen-group { fill: #1a2a1a; stroke: #4aff4a; stroke-width: 2; rx: 12; }
8
+ .visitor-group { fill: #1a1a2a; stroke: #4a4aff; stroke-width: 2; rx: 12; }
9
+ .component { fill: #3a3a3a; stroke: #ffaa4a; stroke-width: 1; rx: 6; }
10
+ .flow { stroke: #ffaa4a; stroke-width: 2; fill: none; marker-end: url(#arrowhead); }
11
+ .text { fill: #ffffff; font-family: 'Arial', sans-serif; font-size: 11px; }
12
+ .group-title { fill: #4a9eff; font-family: 'Arial', sans-serif; font-size: 14px; font-weight: bold; }
13
+ .title { fill: #4a9eff; font-family: 'Arial', sans-serif; font-size: 18px; font-weight: bold; }
14
+ .subtitle { fill: #ffaa4a; font-family: 'Arial', sans-serif; font-size: 12px; }
15
+ </style>
16
+ <marker id="arrowhead" markerWidth="8" markerHeight="6"
17
+ refX="8" refY="3" orient="auto">
18
+ <polygon points="0 0, 8 3, 0 6" fill="#ffaa4a" />
19
+ </marker>
20
+ </defs>
21
+
22
+ <!-- Background -->
23
+ <rect class="bg" width="900" height="700"/>
24
+
25
+ <!-- Title -->
26
+ <text x="450" y="25" text-anchor="middle" class="title">Service Internal Architecture</text>
27
+ <text x="450" y="45" text-anchor="middle" class="subtitle">Emergency Services Communication System Components</text>
28
+
29
+ <!-- Emergency Dispatch Center Group -->
30
+ <rect x="50" y="80" width="350" height="200" class="dispatch-group"/>
31
+ <text x="60" y="100" class="group-title">📞 Emergency Dispatch Center (911)</text>
32
+
33
+ <!-- Dispatch components -->
34
+ <rect x="70" y="120" width="130" height="40" class="component"/>
35
+ <text x="135" y="145" text-anchor="middle" class="text">911 Call Listener</text>
36
+
37
+ <rect x="230" y="120" width="130" height="40" class="component"/>
38
+ <text x="295" y="145" text-anchor="middle" class="text">Call Analysis Engine</text>
39
+
40
+ <rect x="150" y="180" width="130" height="40" class="component"/>
41
+ <text x="215" y="205" text-anchor="middle" class="text">Department Router</text>
42
+
43
+ <rect x="70" y="240" width="90" height="30" class="component"/>
44
+ <text x="115" y="260" text-anchor="middle" class="text">Fire Dispatcher</text>
45
+
46
+ <rect x="190" y="240" width="90" height="30" class="component"/>
47
+ <text x="235" y="260" text-anchor="middle" class="text">Police Dispatcher</text>
48
+
49
+ <rect x="300" y="180" width="90" height="30" class="component"/>
50
+ <text x="345" y="200" text-anchor="middle" class="text">Call Tracking</text>
51
+
52
+ <rect x="300" y="220" width="90" height="30" class="component"/>
53
+ <text x="345" y="240" text-anchor="middle" class="text">Statistics Engine</text>
54
+
55
+ <!-- Dispatch flows -->
56
+ <path d="M 200 140 L 230 140" class="flow"/>
57
+ <path d="M 295 160 L 215 180" class="flow"/>
58
+ <path d="M 180 205 L 115 240" class="flow"/>
59
+ <path d="M 250 205 L 235 240" class="flow"/>
60
+ <path d="M 280 195 L 300 195" class="flow"/>
61
+ <path d="M 345 210 L 345 220" class="flow"/>
62
+
63
+ <!-- Citizen Group -->
64
+ <rect x="50" y="320" width="350" height="160" class="citizen-group"/>
65
+ <text x="60" y="340" class="group-title">👤 Citizen</text>
66
+
67
+ <!-- Citizen components -->
68
+ <rect x="70" y="360" width="120" height="30" class="component"/>
69
+ <text x="130" y="380" text-anchor="middle" class="text">Emergency Scenarios</text>
70
+
71
+ <rect x="210" y="360" width="100" height="30" class="component"/>
72
+ <text x="260" y="380" text-anchor="middle" class="text">Random Selection</text>
73
+
74
+ <rect x="140" y="410" width="120" height="30" class="component"/>
75
+ <text x="200" y="430" text-anchor="middle" class="text">911 Call Generator</text>
76
+
77
+ <rect x="280" y="410" width="100" height="30" class="component"/>
78
+ <text x="330" y="430" text-anchor="middle" class="text">Message Publisher</text>
79
+
80
+ <rect x="70" y="450" width="90" height="20" class="component"/>
81
+ <text x="115" y="463" text-anchor="middle" class="text">Interactive Mode</text>
82
+
83
+ <rect x="190" y="450" width="90" height="20" class="component"/>
84
+ <text x="235" y="463" text-anchor="middle" class="text">Automatic Mode</text>
85
+
86
+ <!-- Citizen flows -->
87
+ <path d="M 190 375 L 210 375" class="flow"/>
88
+ <path d="M 260 390 L 200 410" class="flow"/>
89
+ <path d="M 260 425 L 280 425" class="flow"/>
90
+ <path d="M 115 450 L 235 390" class="flow"/>
91
+ <path d="M 235 450 L 260 390" class="flow"/>
92
+
93
+ <!-- Smart Visitor Group -->
94
+ <rect x="450" y="80" width="400" height="400" class="visitor-group"/>
95
+ <text x="460" y="100" class="group-title">🧑‍💼 Smart Visitor (AI-Powered)</text>
96
+
97
+ <!-- Main AI flow -->
98
+ <rect x="470" y="120" width="110" height="30" class="component"/>
99
+ <text x="525" y="140" text-anchor="middle" class="text">Incident Observer</text>
100
+
101
+ <rect x="470" y="170" width="120" height="30" class="component"/>
102
+ <text x="530" y="190" text-anchor="middle" class="text">AI Message Analyzer</text>
103
+
104
+ <rect x="470" y="220" width="120" height="30" class="component"/>
105
+ <text x="530" y="240" text-anchor="middle" class="text">RubyLLM Integration</text>
106
+
107
+ <rect x="470" y="270" width="110" height="30" class="component"/>
108
+ <text x="525" y="290" text-anchor="middle" class="text">Message Generator</text>
109
+
110
+ <rect x="470" y="320" width="110" height="30" class="component"/>
111
+ <text x="525" y="340" text-anchor="middle" class="text">Emergency Publisher</text>
112
+
113
+ <!-- Secondary AI analysis flow -->
114
+ <rect x="650" y="170" width="120" height="30" class="component"/>
115
+ <text x="710" y="190" text-anchor="middle" class="text">Message Discovery</text>
116
+
117
+ <rect x="650" y="220" width="120" height="30" class="component"/>
118
+ <text x="710" y="240" text-anchor="middle" class="text">Property Analysis</text>
119
+
120
+ <rect x="650" y="270" width="130" height="30" class="component"/>
121
+ <text x="715" y="290" text-anchor="middle" class="text">AI Content Generation</text>
122
+
123
+ <!-- Visitor flows -->
124
+ <path d="M 525 150 L 525 170" class="flow"/>
125
+ <path d="M 530 200 L 530 220" class="flow"/>
126
+ <path d="M 530 250 L 525 270" class="flow"/>
127
+ <path d="M 525 300 L 525 320" class="flow"/>
128
+
129
+ <path d="M 710 200 L 710 220" class="flow"/>
130
+ <path d="M 710 250 L 715 270" class="flow"/>
131
+
132
+ <!-- Cross-connections -->
133
+ <path d="M 590 185 L 650 185" class="flow"/>
134
+ <path d="M 650 235 L 590 235" class="flow"/>
135
+ <path d="M 650 285 L 580 285" class="flow"/>
136
+
137
+ <!-- System Integration Notes -->
138
+ <rect x="50" y="520" width="800" height="160" fill="#1a1a1a" stroke="#4a9eff" rx="8"/>
139
+ <text x="70" y="545" class="group-title">System Integration Features</text>
140
+
141
+ <text x="70" y="570" class="text">🔄 Message Flow Coordination:</text>
142
+ <text x="90" y="585" class="text">• Emergency Dispatch routes calls based on emergency type analysis</text>
143
+ <text x="90" y="600" class="text">• Citizens can operate in interactive or automatic mode for testing scenarios</text>
144
+ <text x="90" y="615" class="text">• AI Visitor uses RubyLLM for intelligent message type selection and content generation</text>
145
+
146
+ <text x="450" y="570" class="text">🤖 AI Intelligence Components:</text>
147
+ <text x="470" y="585" class="text">• Dynamic message discovery analyzes available SmartMessage classes</text>
148
+ <text x="470" y="600" class="text">• Property analysis determines required fields for each message type</text>
149
+ <text x="470" y="615" class="text">• Content generation creates realistic data for emergency scenarios</text>
150
+
151
+ <text x="70" y="640" class="text">📊 System Monitoring:</text>
152
+ <text x="90" y="655" class="text">• Call tracking maintains statistics on emergency response coordination</text>
153
+ <text x="90" y="670" class="text">• Statistics engine provides performance analytics and response time metrics</text>
154
+ </svg>