Skip to content

Structure and Architecture

Antoine Théate edited this page Feb 22, 2023 · 3 revisions

Client Side

Pages and Components

Razor files and associated code are split on two different file : {nameOfTheComponent}.razor and {nameOfTheComponent}.razor.cs.

Splitting those files provide more readability.

The file structure tries to follow as much as possible route for pages.

For example : the page with the route /Administration/ProjectManagement with the following file structure Pages/Administration/ProjectManagement.razor)

MVVM Pattern

The application is based on the MVVM pattern. Following this pattern provide a highly separation between views and data.

For each razor page/components, creates a view model class with the following naming convention {nameOfTheComponent}ViewModel. Each view model also have its own interface : I{nameOfTheViewModel}. It is needed for the Dependency Injection. All view models are automatically register.

A view model can be passed by Injection (preferable for a Page) or by Parameter (preferable for Component).

A folder ViewModels stores all view model, and the structure follow the exact structure as Pages and Components.

For example : The file Pages/Administration/ProjectManagement.razor will have the view model _ViewModels/Pages/Adminitration/ProjectManagementViewModel.cs

ReactiveUI

View model are ReactiveObject. For any properties of a View model that the view needs to react, you have to subscribe to that event with the following :

this.disposables.Add(this.WhenAnyValue(x => x.ViewModel.Role).Subscribe(_ => this.InvokeAsync(this.StateHasChanged)));

Services

For any access to the REST API, a service is created. All services will provides some functions to be able to get/set data to/from the server.

Views

Each view extends the GenericBaseView component and the associated ViewModel extends the BaseViewViewModel class. The view should have the same name as the Enumeration value (for example: View.DocumentBased as a component DocumentBased with DocumentBasedViewModel as ViewModel)

Context Panel

When something is selected inside a View, information related to the item are provided. Based on the type of the selected item, a matching is done inside the SelectedItemCardViewModel between the item and the component to display.

Server Side

Carter

All routes are defined with Carter.

The main route of a module can be defined by a RouteAttribute.

The EntityModule class provides routes and methods that are reusable by a lot of Module

Modules access to data through Managers. Remarks : Due to the way that Carter modules are registered (As Singleton), we have to inject the Manager into the method, not by the constructor of the class.

Manager

A Manager is a class that will provide a layer between the REST API and the Database access. This separation between the REST API and the Database provide the opportunity to easily switch the Database layer.

Entity Framework

In this project, the Database is handle by the Entity Framework.

Clone this wiki locally