Architecture - nonduality345/Convos GitHub Wiki

Architecture

The API is built using Microsoft .Net Web API projects and the 4.5 framework. The database is built for SQL Server 2008 and above.

The basic architecture of the application is split into two layers. The "front end" handles the immediate request from the client, parsing all of the necessary information from the request and formulating a call to the "back end" which handles any business logic of the system and serializes the data to the persistent store. All of the basic code for the front end is in the /Convos/Controllers directory and the basic code for the back end is in the /Convos/Managers directory.

Every incoming request from the API is handled by the ConvosController class in /Convos/Controllers. The request is routed to the appropriate method in that class based on .Net Web API's routing logic. The ConvosController class has a dependency on an IConvoContract instance. It is the IConvoContract instance (in this case, an instance of the ConvoContract class) that handles extracting the information from the incoming request and interfacing with the backend. The front end is extensible by using the decorator pattern. For illustrative purposes only, I have included an implementation of the IConvoContract interface in a class called ServerCacheDecorator. If, say, we wanted to add server-side caching to the application, which in some instances can prove to be beneficial to an API, we can easily wrap the IConvoContract instance with a ServerCacheDecorator which houses all of the logic related to server side caching. The classes are wrapped using the Microsoft Unity Dependency Injection framework. The code that actually wraps the classes is in /Convos/App_Start/UnityConfig.cs.

The ConvoContract class has a dependency on an IConvoManager instance to interface with the database. The IConvoManager instance is an instance of ConvoManager. This class actually interfaces with the database to read and write objects. The back end is also extensible using the Decorator patterns. For illustrative purposes only, I have included an implementation of the IConvoManager interface in a class called LoggingDecorator. If we wanted to add functionality to log exceptions to a log store, we could easily wrap the IConvoManager instance with this Decorator to add that functionality. Again, the code to wrap the classes is in /Convos/App_Start/UnityConfig.cs.

Helper classes that service both the front end and the back end can be found in the /Convos/Utilities directory. Data transfer objects are defined in the /Convos/Entities directory and the ResultCode enumeration is located in the /Convos/Enums directory.