How enderchx/dsms-go works
Project type and purpose
• This is a Go-based, distributed simulation communication system implementing a publish-subscribe protocol (“DSTP”).
• It provides multiple executables (CLI tools, a simulation broker, GUI client, web client) that interact over network sockets using Protobuf-encoded messages.
File structure
• cmd/ contains five entry points:
• client (generic client CLI)
• server (generic server CLI)
• simulation_center (the pub-sub broker)
• simulation_client (simulation engine client)
• test (test harness)
• internal/ holds core packages:
• app (desktop GUI via Fyne & web GUI via Gin + static HTML)
• auth (login logic, issues JWTs)
• dstp (connection, framing for the DSTP protocol)
• message_hub (in-memory pub-sub broker logic used by simulation_center)
• protobuf (message definitions, compiled Go stubs)
• simulation (simulation logic for both center and client)
• utils/ has cross-cutting concerns: JWT handling, logging (Gin middleware & generic logger)
README
• Confirms the goal: “Design and implementation of a distributed simulation communication protocol based on publish-subscribe.”
Main components
a. Simulation Center (Broker)
• Runs cmd/simulation_center
• Hosts message_hub, simulation_center logic, dstp listener
• Accepts connections from all clients, manages topics, forwards messages
b. Simulation Clients
• cmd/simulation_client runs simulation_client logic
• Publishes simulation data to center, subscribes to topics for control or aggregated data
c. Generic Client & Server CLIs
• cmd/client and cmd/server wrap the same pub-sub mechanism for manual or scripted interactions
d. UI Clients
• Fyne desktop app (internal/app/fyne_app.go)
• Gin-backed web app (internal/app/gin_app.go + static HTML/JS)
• Both connect over DSTP to the center, authenticate via auth/login → JWT
e. Authentication Service
• internal/auth/login.go issues JWTs for clients; used by UI and CLI to obtain credentials
f. Protocol Layer
• internal/dstp/conn.go handles TCP framing, multiplexing, heartbeats
• internal/protobuf defines message schema (data.proto → data.pb.go)
g. Utilities
• JWT utils (utils/jwt/jwt.go)
• Logging (utils/log)
Relationships & data flows
• Clients (Simulation, UI, CLI) → authenticate via Auth service → receive JWT
• Clients establish DSTP connection over TCP to Simulation Center
• Simulation Clients publish “simulation data” topics → Message Hub within Center
• Other clients subscribe to topics → Hub pushes data → Clients process/display
• Simulation Center may run simulation coordination logic (internal/simulation/simulation_center.go)
• A test harness (cmd/test) can simulate multiple clients or test message flows
Architectural patterns & design principles
• Publish–Subscribe: decouples producers/consumers via topics, central hub
• Layered architecture:
• Protocol layer (dstp)
• Messaging layer (message_hub)
• Business logic (simulation, auth)
• Presentation/CLI layer (app, cmd)
• Modularization: everything in internal/, clear separation of concerns
• Technology choices: Go modules, Protobuf for messages, Fyne for desktop GUI, Gin for web GUI, JWT for auth
Final checklist
• Clear, descriptive labels on all nodes (components)
• Annotations for protocols, message formats, ports