Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.
Riccardo Crepaldi edited this page Mar 2, 2017 · 1 revision

Summary

This document outlines the core components that make up the chat server. After reading this document you should have a high-level understanding on how the chat server is designed, where to make changes, and how to use the design to your advantage.

Model-View-Controller

The server follows the model-view-controller pattern. The model-view-controller pattern is a design pattern where responsibilities for handling data is separated between three components.

  1. Model. Responsible for storing all the data needed to represent the state of the system.

  2. View. Responsible for providing high-level methods for reading the data from the model.

  3. Controller. Responsible for providing high-level methods for writing data to the model.

Overview

Server Front End

codeu.chat.server.ServerFrontEnd

At the front of the server is the server front end. The server front end is responsible for reading data from the network and converting them into messages. Once it has read in a message it will either call the controller or the view and then write the response to the network. It is the server front end’s responsibility to bridge the gap between the network and the server. This allows the server to avoid having to worry about networking.

Controller

codeu.chat.server.Controller

The server’s controller implementation implements two types of controllers: BasicController and RawController. The server only allows a client to access the BasicController as the RawController offers too much control. The RawController is used to implement the BasicController and is used by the server to merge its data with the Relay Server. The BasicController supports the adding new users, conversations, and messages but does not allow the caller to specify the IDs for each object (whereas the RawController does).

View

codeu.chat.server.View

The server’s view implementation implements two types of views: BasicView and LogicalView. The server allows a client to access both interfaces. The BasicView is used to do simple batch lookups. Methods take a group of ids and return the objects whose ids were found. LogicalView provides higher-level methods for reading data based on their fields.

Model

codeu.chat.server.Model

The server model is a collection of Stores. A store is a data structure specifically designed for the server model. A store is a key-value pair map where multiple values can be mapped to a key. Read operations typically return an iterable object so that all values matching the query can be accessed.

The server model is a collection of users, conversations, and messages. For effective querying the server has multiple stores for each type of data (messages by ID, messages by time, etc.). To keep the data consistent, the model controls adding to stores, but exposes all read functionality.

Clone this wiki locally