# prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq architecture

> Architecture diagram of the GitHub repository prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq
- Repository: https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq

## Overview

This repository contains Node.js TCP ingestion variants for GPS-device messages. The main workflow in app3.js accepts GT06 connections, associates login IDs with sockets, parses location/status packets, acknowledges logins, and forwards telemetry to RabbitMQ while persisting location records in MySQL. app.js is a simpler direct-to-MySQL variant; app2.js relays unparsed TCP data to RabbitMQ. The graph follows the sampled implementations; app3.js has omitted sections, so only visible or documented relationships are shown.

Main entry points: [`app3.js`](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js) (GT06 server), [`app.js`](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app.js) (Login and location handlers), [`app2.js`](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app2.js) (Raw TCP relay)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Device ingestion"]
  node_app3_server["GT06 server<br/>[app3.js]"]
  node_session["Device sessions<br/>[app3.js]"]
  node_direct_server["Direct TCP server<br/>[app.js]"]
  node_raw_relay["Raw TCP relay<br/>[app2.js]"]
end

subgraph group_processing["Packet processing"]
  node_login_parse["Login parser<br/>[app3.js]"]
  node_login_ack["Login response<br/>[app3.js]"]
  node_location_parse["Location parser<br/>[app3.js]"]
  node_status_parse["Status parser<br/>[app3.js]"]
  node_direct_handlers["Login and location handlers<br/>[app.js]"]
  node_direct_parser["Direct packet parsing<br/>[app.js]"]
end

subgraph group_delivery["Data delivery"]
  node_telemetry_dispatch["Telemetry dispatch<br/>[app3.js]"]
  node_rabbitmq["RabbitMQ queue"]
  node_mysql[("MySQL location store")]
end

node_tracker(("GPS tracker"))

node_tracker -->|"sends packets"| node_app3_server
node_app3_server -->|"parses login"| node_login_parse
node_app3_server -->|"stores device ID"| node_session
node_app3_server -->|"sends response"| node_login_ack
node_app3_server -->|"parses location"| node_location_parse
node_app3_server -->|"parses status"| node_status_parse
node_app3_server -->|"forwards telemetry"| node_telemetry_dispatch
node_telemetry_dispatch -->|"publishes messages"| node_rabbitmq
node_telemetry_dispatch -->|"inserts locations"| node_mysql
node_tracker -->|"sends packets"| node_direct_server
node_direct_server -->|"dispatches packets"| node_direct_handlers
node_direct_handlers -->|"parses messages"| node_direct_parser
node_direct_handlers -->|"saves locations"| node_mysql
node_tracker -->|"sends data"| node_raw_relay
node_raw_relay -->|"relays raw data"| node_rabbitmq

click node_app3_server "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js"
click node_session "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js"
click node_login_parse "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js"
click node_login_ack "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js"
click node_location_parse "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js"
click node_status_parse "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js"
click node_telemetry_dispatch "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js"
click node_direct_server "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app.js"
click node_direct_handlers "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app.js"
click node_direct_parser "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app.js"
click node_raw_relay "https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app2.js"

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_app3_server,node_session,node_direct_server,node_raw_relay toneBlue
class node_login_parse,node_login_ack,node_location_parse,node_status_parse,node_direct_handlers,node_direct_parser toneAmber
class node_telemetry_dispatch,node_rabbitmq,node_mysql toneMint
class node_tracker toneIndigo
```

## Components

### Device ingestion

- [GT06 server](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js): `app3.js`
- [Device sessions](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js): `app3.js`
- [Direct TCP server](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app.js): `app.js`
- [Raw TCP relay](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app2.js): `app2.js`

### Packet processing

- [Login parser](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js): `app3.js`
- [Login response](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js): `app3.js`
- [Location parser](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js): `app3.js`
- [Status parser](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js): `app3.js`
- [Login and location handlers](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app.js): `app.js`
- [Direct packet parsing](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app.js): `app.js`

### Data delivery

- [Telemetry dispatch](https://github.com/prabhath-wijewardhana/nodejs-socket-msg-to-rabbitmq/blob/master/app3.js): `app3.js`
- **RabbitMQ queue**
- **MySQL location store**

### Other components

- **GPS tracker**

## Connections

- GPS tracker → GT06 server: sends packets (evidence: `app3.js`)
- GT06 server → Login parser: parses login (evidence: `app3.js`)
- GT06 server → Device sessions: stores device ID (evidence: `app3.js`)
- GT06 server → Login response: sends response (evidence: `app3.js`)
- GT06 server → Location parser: parses location (evidence: `app3.js`)
- GT06 server → Status parser: parses status (evidence: `app3.js`)
- GT06 server → Telemetry dispatch: forwards telemetry (evidence: `app3.js`)
- Telemetry dispatch → RabbitMQ queue: publishes messages (evidence: `app3.js`)
- Telemetry dispatch → MySQL location store: inserts locations (evidence: `app3.js`)
- GPS tracker → Direct TCP server: sends packets (evidence: `app.js`)
- Direct TCP server → Login and location handlers: dispatches packets (evidence: `app.js`)
- Login and location handlers → Direct packet parsing: parses messages (evidence: `app.js`)
- Login and location handlers → MySQL location store: saves locations (evidence: `app.js`)
- GPS tracker → Raw TCP relay: sends data (evidence: `app2.js`)
- Raw TCP relay → RabbitMQ queue: relays raw data (evidence: `app2.js`)
