How koanvi/cli-chat works
cli-chat is a small terminal chat application: a user enters a message and recipient in the CLI, the client sends a JSON request over TCP, and the server routes it to the recipient (or broadcasts to other connected clients). The client processes server responses and received messages and emits state events. The README describes the product only briefly; the sampled implementation shows no separate persistence or authentication layer. Edges reflect the displayed calls; the client/server wire interaction is evident from their implementations, though no shared protocol module is shown.
Main entry points: server.ts TCP server · client.ts TCP client · src/index.ts Prompt input · src/index.ts Server startup
Components 10
Terminal client
- CLI entry
wsClient/src/index.ts - Prompt input
wsClient/src/index.ts - TCP client
wsClient/src/client.ts - Client events
wsClient/src/client.ts
Chat server
- Server startup
wsServer/src/index.ts - TCP server
wsServer/src/server.ts - Client registry
wsServer/src/server.ts - Method dispatch
wsServer/src/server.ts - Message routing
wsServer/src/server.ts
Other components
- Chat user
Connections 12
- Chat user → Prompt input: enters message
wsClient/src/index.ts - CLI entry → TCP client: creates client
wsClient/src/index.ts - CLI entry → Prompt input: starts prompts
wsClient/src/index.ts - Prompt input → TCP client: sends request
wsClient/src/index.ts - TCP client → Client events: emits events
wsClient/src/client.ts - Server startup → TCP server: starts server
wsServer/src/index.ts - TCP client → TCP server: sends TCP JSON
- TCP server → Client registry: registers clients
wsServer/src/server.ts - TCP server → Method dispatch: processes requests
wsServer/src/server.ts - Method dispatch → Message routing: invokes method
wsServer/src/server.ts - Message routing → Client registry: routes messages
wsServer/src/server.ts - TCP server → TCP client: returns responses