+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                         SETUP / BUILD TIME                                                                                           |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                                                                                                                                      |
|  [ User App ] ---> ClientBuilder::new(connector, state) ---> [ ClientBuilder ] ---> .with_module<M>() ---> [ ClientBuilder ] ---> .build() --+--> ( [Client], [ClientRunner] )                       |
|                                                                    |                      |                                        |                                                                 |
|                                                                    |                      |                                        +---> Creates (runner_cmd), (to_ws) channels.                     |
|                                                                    |                      +---> For each module, a factory is created that:                                                          |
|                                                                    |                            1. Creates channels: (cmd_tx/rx), (cmd_ret_tx/rx), (msg_tx/rx).                                      |
|                                                                    |                            2. Calls M::new_combined to create module instance and its handle.                                   |
|                                                                    +--------------------------> 3. Spawns the module's `run()` method in a new Tokio task.                                           |
|                                                                                               4. Spawns a task to add the clonable handle to {Module Handles}.                                       |
|                                                                                               5. Adds the module's `routing_rule` to the `Router`.                                                   |
|                                                                                                                                                                                                      |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                                RUNTIME                                                                                               |
+---------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------+
|                   USER-FACING / APPLICATION LOGIC                   |                                                BACKGROUND TASKS / CORE SYSTEM                                                  |
|---------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
|                                                                     |                                                                                                                                |
|   [ User Code ]                                                     |                                                                                                                                |
|   (e.g., main())                                                    |                                                                                                                                |
|        |                                                            |  +-------------------------------------------------------------------------------------------------------------------------+   |
|        v                                                            |  |                                                [ ClientRunner Task ]                                                    |   |
| +-----------------+ <--- .get_handle<M>() ----+                     |  |  (The main control loop. Manages connection state, listens for commands, and spawns/despawns I/O tasks)                 |   |
| | [Client Handle] |                           |                     |  |                                                                                                                         |   |
| +-----------------+                           |                     |  | <---[RunnerCommand]--- ((runner_cmd_rx)) <---(sends Disconnect/Shutdown)-----------------------------------------------------+   |
|   |         |                                 |                     |  +------------------------------------------------^------------------------------------------------------------------------+   |
|   |         |      { Module Handles }         |                     |                                                   | (when connected)                                                         |   |
|   |         |   (Arc<RwLock<HashMap>>)        |                     |                                                   |                                                                          |   |
|   |         +------------------------------>+                       |   +--------------------------+                    +--------------------------+                                                 |   |
|   |                                         |                       |   |  [ WebSocket Writer ]  | ===> To Server     |  [ WebSocket Reader ]  | <=== From Server                               |   |
|   |                                         |                       |   | (spawned by Runner)    |                    | (spawned by Runner)    |                                                 |   |
|   |----(e.g., direct send)---->[Message]--->((to_ws_tx))----------->+-> | (pulls from to_ws_rx)  |                    | (pushes to Router)     | --[Arc<Message>]--> [ Router ]                   |   |
|                                                                     |   +--------------------------+                    +--------------------------+                       |                     |   |
|                                                                     |                                                                                                    |                     |   |
|                                                                     |                                                                         +----------------------------+                     |   |
|                                                                     |                                                                         |                            |                     |   |
| +-----------------+ <-- .echo("Hi") --- [ User Code ]               |                                                (routes to ALL)            (routes to FIRST match)    |                     |   |
| | [Module Handle] |                                                 |                                                      |                            |                     |   |
| +-----------------+                                                 |                                                      v                            v                     |   |
|   |           ^                                                     |                                  [ Lightweight Handler Fn ]             ((msg_rx)) ---[Arc<Message>]---> +-----------------+   |
|   |           |                                                     |                                                                                                          | [ApiModule Task]  |   |
|   |           |                                                     |                                                                                                          | (select! loop)    |   |
|   |           +----[Response]---((cmd_ret_rx)) <---(sends response)--+                                                                                                          |                   |   |
|   |                                                                 |                                                                                                          |                   |   |
|   +----[Command]---->((cmd_tx)) ----(sends command)----------------->                                                                                                          +--------+--------+   |
|                                                                     |                                                                                                                   |            |   |
|                                                                     |                                                                                                                   |            |   |
|                                                                     |                                                                            (sends message to WebSocket) ----> ((to_ws_tx))   |   |
|                                                                     |                                                                                                                                |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+