You are on page 1of 10

© AmadGroup,

SALEEM

Architecture
V1.0
1. Brief Description

This document is describing the system architecture of Saleem solution as well as


describing the architecture components.

2. Aim of Document

This document is to cover the system layers based on the known standards to enhance
performance, ease control of application, reduce modifications, and manage system
mobility through applying N-Tier Methodology. Also the document will discuss
categorizing the application to the well-known modules according to the contract, and
how the solution will coordinate and array these modules according to the pre
mentioned layers.

3. Targeted Audience

This document will target mainly the NT responsible team members in order to stick to
the system architecture described. It also can target any customer of SALEEM.

4. Table of Contents

a. The Used System Architecture Pattern (MVC


Architecture)

There are three primary components of an MVC framework: one or more models,
views, and controllers. These components define the response cycle of a user
interaction with an application.

 Model: A domain-specific set of classes that provide an interface into the


data, implement domain-specific business rules, and reflect application
state. The model may or may not wrap a persistent data store such as SQL
Server or other database server. Usually the model will consist of a data
access layer or some kind of object-relational tool such as LINQ to SQL,
Entity Framework, or NHibernate.
 View: The application’s user interface, which serves to render the model in a
form that the user can interact with. An application will typically have
multiple views associated with a single model, each used for different
purposes. In a web application, the view is generally defined by HTML and
contains no code or logic, other than what is necessary to display the view
to the user and allow the user to interact with the view.
 Controller: Receives requests from the user and initiates a
response, interacting with the model as necessary. The controller also

NT, 2016 1
handles the overall application flow. In a web application, the
controller usually responds to HTTP GET or POST inputs, hands the
request over to the model that implements the business rules, and then
selects the view subsequently displayed to the user.

Presentation Layer
))View
Common
Layer
+ Business Login Layer
)Model(
(Controller, API Controllers)
Entities

Data Access Layer


)Model(

Application Tiers
Graph 1.1.

The system will be divided into 3-Tiers pattern. Each tier layer will be represented by
one or more stand-alone but cooperative DLLs. These dlls are deployed with the
presentation layer folder plus a helper library called Core.

Also MVVM is used for better organizing View code, and for SPA.

SPA is used to use modern technologies, and to enhance performance.

The layers will be as described below in ascending way:

 Common: is a helper DLL that all the layers can use which contains of:
 The system constants and logic constants.

public enum DefaultRole { AdminSecurity = 1, Archiving = 2 }


public enum ObjectType { Root = 1, Parent = 2, Page = 3, Tab = 4 }
public enum PermissionType { Add = 2, Edit = 3, View = 4, Delete = 5,
Print = 6 }
public enum PermissionLevel { Personal = 1, School = 2, Center = 3 }
public enum UserStatus { Logged, NotAuthorized, NoSession }

 Each class represents one table (fields) to standardize passing data


through tiers using either one separate class or collection of classes.

NT, 2016 2
public class SettingsMapping
{
public struct Country
{
public static string EntityName ="[Settings].[CountryName]";
public static string CountryCode ="[Settings].[CountryCode]";
}
public struct Area
{
public static string EntityName ="[Settings].[AreaName]";
public static string Description = "[Settings].[Description]" ;
public static string IsActive ="[Settings].[IsActive]";
}

 File for each database schema contains all schema tables and fields as in
database that can be used in quires and database manipulations.

NT, 2016 3
 Data
namespace Amad.Saleem.Common.Data.Settings
classes which represent each database table.
{
[DataContract]
public class CountryLight
{
public CountryLight () { }
public CountryLight (byte id, string countryName)
{
Id = id;
CountryName = countryName;
}
[DataMember]
public byte Id { get; set; }
[DataMember(IsRequired = true)]
public string countryName { get; set; }
}
[MetadataType(typeof(CountryMetaData))]
public class Country: CountryLight
{
public Country () { }
public Country ( int id, string contryCode, string
countryName, string description, bool isActive): base(id,countryName)
{
ContryCode = contryCode;
CountryName = countryName;
Description = description;
IsActive = isActive;
}
[DataMember(IsRequired = true)]
public string ContryCode { get; set; }
[DataMember(IsRequired = true)]
public string CountryName { get; set; }
[DataMember(IsRequired = false)]
public string Description { get; set; }
[DataMember(IsRequired = true)]
public bool IsActive { get; set; }
}
public class CountryMetaData
{
[ScaffoldColumn(false)]
public int Id { get; set; }

[Display(ResourceType =
typeof(Resources.Settings.DataAnnotations), Name ="CountryName")]
[Required(ErrorMessageResourceType =
typeof(Resources.Settings.DataAnnotations), ErrorMessageResourceName
="RequiredCountryName")]
public string CountryName { get; set; }
[Display(ResourceType =
typeof(Resources.Settings.DataAnnotations), Name ="CountryCode")]
[Required(ErrorMessageResourceType =
typeof(Resources.Settings.DataAnnotations), ErrorMessageResourceName
="CountryCode")]
public string CountryCode { get; set; }
[Display(ResourceType =
typeof(Resources.Settings.DataAnnotations), Name ="IsActive")]
public bool IsActive { get; set; }
}
}

NT, 2016 4
 Common also contains ViewModels which are transferred between
Business and APIs.
 Data Access Layer:
 This layer is responsible for any database access, means that there's
no access either reading or saving can be done to the DB except
through this layer as it acts as the DB interface.
 It contains two correlated subsystems:
 DB Handler: this sub-layer acts as generic low level Handler to
the DB, it means that this layer is designed for the main
operations for any access to any DB when executing any data
instruction i.e.(insert, add, update and delete) and concerns with
the connection and transaction handling.
 DB Infrastructure (Named Data Access): This sub-layer acts as
more specific layer to the DB entities by creating a class for each
DB entity.

 public
Here are static
sampleCountry
of Data Get(int
Access countryId)
class methods representing the
public static AdvancedList<Country> GetList()
Project
public Table in AdvancedList<Country>
static the DB with functions signatures:
GetActiveList()
public static CountryLight GetLight(int countryId)
public static AdvancedList<CountryLight> GetLightList()
public static AdvancedList<CountryLight> GetActiveLightList()
public static ResultType UpdateList(AdvancedList countries)
private static ResultType Update(Project country)
private static ResultType SetActivation(int[]areaIDs,bool active)
public static ResultType AddList(AdvancedList countries)
private static ResultType Add(Project country)
public static ResultType DeleteList(int[] countryIds)
public static ResultType Delete(int countryId)

 These Classes are formatted as the types and names of the tables'
fields in DB. By the Data Access Layer you can access any
AdvancedList (representing a set of one entity classes), or entity class
(representing one record).

 Retrieving values will be like:


;"country.CountryName = "Any Title

 Related classes are grouped into namespace with the module name.
 DB tables and field names are typed through data classes, so no one
can write explicitly any table or field name.
 Generic functions are generated through the DAL-Generator like: (Get,
Get List, Add, Add List, Update, Update List, Delete, and Delete List).
 Any advanced functions you should write by following the rules.

NT, 2016 5
 To implement a function to get only one record you should use the
single Name Category.GetBy (Name), Category.GetBy (Code).
 To implement a function to get a record list you should use the plural
Name Category.GetListBy(Department).
 There is only one Add and Update function and this is the abstraction
we need to, in order to maintain standardization and secure methods
and to reduce maintenance, so when you need to update any record in
the DB you just call the Category.Get method getting the AdvancedList
and update as much as you need of the fields then call the
Category.Update again with the modified AdvancedList.
 Business Logic Layer:
 This Layer is concerned with any business rules, methodologies
 Actually this layer is the system.
 This layer is changed in MVC applications to be inside the presentation
layer.
 It contains two types of Classes:

 Any business rules, validations, checks, calculations, or collecting
should be done here.
 Naming of the functions is according to business needs with respect to
ordinary naming rules discussed before.
 No SQL statements can be written in the Business Logic as well as
handling presentation controls events.

 namespace
This Amad.Saleem.BusinessLogic.Settings
is sample for Business methods
{
public class Country
{
public CountryViewModel Get(short id) { }

public CountriesViewModel GetList(int start, int end, string


searchValue, string orderby, string dir) { }

public ResultType Add(CountryViewModel model) { }

public ResultType Update(CountryViewModel model) { }

public ResultType SetActivation(SetActivationKeysList<byte[]> list)


{ }

public ResultType Delete(byte id) { }

public ResultType DeleteList(KeysList< byte []> list) { }


}
}

NT, 2016 6
 Server Controllers:
 MVC or Normal Controller (System.We.Mvc.Controller).
 Provides methods that respond to HTTP requests that are made
to an ASP.NET MVC Web site.
 Use Controller to render your normal views.
 API Controller (System.Web.Http.ApiController).
 Defines properties and methods for API Controller.
 Api Controller action only returns data that is serialized and sent
to the client.

 namespace
Api Amad.Saleem.Presentation.Areas.Settings.Controllers
Controllers are specialized in returning data. For example,
{
they take
publiccare
classofApiCountryController
transparently serializing the data into the
: ApiExtendedController
{
format requested by the client. Also, they follow a different
[HttpGet]
routing scheme by default (as in:
public CountryViewModel mapping URLs
Empty() { to actions),}
providing[HttpGet]
a REST-full API by convention.
public CountryViewModel Get(short id) { }

[HttpGet]
public CountriesViewModel GetList(int start, int end, string
searchValue, string orderby, string dir) { }

[HttpPost]
public ResultType Add(CountryViewModel model) { }

[HttpPut]
public ResultType Update(CountryViewModel model) { }

[HttpPut]
public ResultType SetActivation(SetActivationKeysList<byte[]>
list) { }

[HttpDelete]
public ResultType Delete(byte id) { }

[HttpDelete]
public ResultType DeleteList(KeysList< byte []> list) { }
}
}

 Presentation Layer (Views):


 This layer is responsible for viewing models by the mean of the word.
 We should isolate from business as much as we can, except mandatory
issues like client validation.

NT, 2016 7
 Containing folders like below:

 Areas will act for any module.


 AngularApp for the SPA code (also separated by each module and
each screen).
 Content is the major folder for any client resources files (JS,
Images, CSS, , Languages, etc.…).
 Controllers and Views outside, or for each module.
 Applying reusability for this layer by using each APIs for each entity
from the main source, and by using server controls, client controls as
much as we can.
 Graphical Design issues are function of the Graphical designer only,
and it’s his responsibility, developers might have contribution to
enhance code for (html, css).
 AngularJS
 Is a JavaScript library that helps you to create rich, responsive
display and editor user interfaces, with a clean underlying data
model. Any time you have sections of UI that update dynamically
(e.g., changing depending on the user’s actions or when an
external data source changes), Angular can help you implement
it more simply and maintain ably.
 Part of the AngularJS is the client routing, application is built
around Routes. Routes define a link between a named state
(usually in the hash or the URL) and the action taken at that
state (as a callback/function).
 Angular Folder for each module mainly contains:

 Controllers: acts in AngularJS 1.5 as a main controller and


also the client ViewModel.
 Directives: is for any client side controls using AngularJS.
 Services: is acting like client side APIs, which connecting
to the server APIs to get data.

NT, 2016 8
b. Response cycle of a user interaction with an
application.

Graph 1.2.

Simple view to show how request go through layers till it backs to the client
As html response. O
P
S

And here’s the whole application structure grouped in a simple graph.

Global and Shared Resources

A Data Access
j API
Controller Managers
a
` Client
Hx J BLL
User Interface t Angular (Bind) s
Html mR o
leU nH
qR
Angular (Routes) t
uL t
MVC
e( p Controller
V DB
s
i
t
e
w
Common Entities (Table Representation)
R
e
Graph 1.3. n
d
e
r
e
d

P
a

NT, 2016 9

You might also like