Chat Application Architecture – Design Verification

Architecturejavamessaging

So for my newest hobby project, I want to create a simple chat application where users can just log in with a nickname (no passwords) and talk to anybody on the network.

Off the top of my head, I'm thinking about this design where a frontend Client acquires a User object by registering with a nickname.

A Message object can behave like packets in the network, with a Postman delivering a given Message object to the intended recipient.

When a user sends a message, they call:

    postman.addMessage(message);

and the Postman then delivers this to the inTray located in Server.

The receiver's Postman eventually finds a Message object intended for them in the outTray and fetches it for its Client.

Chat - UML Diagram

Any thoughts on the design? For all I know, it probably sucks but some constructive criticism is always welcome.

Best Answer

According to your explanations, the user interacts with a postman to send and receive messages, which are stored on a server.

That's a good start. But I'm not sure that the class diagram fully reflects your explanations; It also raises some questions:

  • the user would be "composed" of several clients ?? I thought that the user user would register to a client. Or eventually that a client would own several users.
  • is the client supposed to represent the user interface ?
  • the postman would be composed of several users ?? Do you mean that a postman serves several users. And what is the relationship between a postman a client and a server ?
  • are the intray/outray on the sever organized by postman ? by user ? or is it global for the all the users/postman ?
  • are messages stored twice on the server: in outray (send by user) and in the intray (adressed to user) ?
  • when the message is sent to the server, is a copy kept in the postman ? when a message is retrieved from the server, is it removed there ?
  • the notion of user session is not represented here. What if a user logs off, and logs in later ? What will happens to the messages that he has received in the meantime ? will the same postman always serve the same user ?

As you can see above, you are very much at the beginning of your design. Without addressing all these points, I'd already propose you a reviewed diagram:

enter image description here

Some key aspects:

  • There is no permanent relation between postman and server: a posman is not structurally related to a server. There is only a dependency, because when a postman is told to connect with a server, he has to know the interface of the server (yet to be defined)
  • The messages are either stored in a postman, or on a server (see the black diamonds).
  • there is a link to be clarified between a user and a postman (e.g. the user has a link to the postman, or the postman has a list of users).
  • there is a link to be clarified beteween a user and a ClientUI. As the user seems to be created when connecting to UI, we could imagine that the User is created by the UI.
  • it has to be clarified how the servers are managed: does every client manage a server ? Is teh server given when login ? Are server operated independently ? are server searched via a network protocol by the postman when he needs it ? You need to clarify this.
Related Topic