Skip to content

VAHub Back End Overview

Kantemir Tvorogov edited this page Aug 9, 2023 · 2 revisions

Technologies in use

Below is the list of main libraries and technologies used in the project.
You may explore their manuals beforehand to better understand project source code.

Overall description

VAHub is a Spring Java application. It's built with Maven and should be normally run using the spring-boot-maven-plugin. It works with PostgreSQL database and uses MyBatis as an ORM tool. Frontend part is based on Angular and written in Typescript (see frontend part description). To improve performance VAHub widely uses backend caching of data.

VAHub main goal is to provide data presentation to the user, not to modify them somehow, so it performs mostly data querying and only a little of data modification (personal user settings, filters etc).

Modular structure

Project contains several Maven modules:

  • vahub — is in charge of relations between frontend and backend and contains all REST-based resources providing access to the backend data. It stores the frontend code itself too. Also, this module contains the whole application entry point (com.acuity.visualisations.rest.config.ApplicationWeb class).
  • vahub-model — contains the most part of application logic: data querying from the DB, data preparation for presentation and data providing to the vahub module.
  • vahub-cohorteditor-model — contains the backend logic of Cohort Editor, a specific part of VAHub functionality that allows user to compose custom investigation subject combinations
  • vahub-config — contains configuration files and classes and some caching logic
  • vahub-common — contains common logic used by all other modules

Layered structure

Architecturally, the application has several layers of logic. They are implemented for most business logic entities (for some, though, the list is different). They are:

  • Repositories (the lowest level) - this layer provides access to the database data. Typically, a repository is a Java interface annotated with @Repository Spring annotation that extends RawDataRepository interface and overrides its method getRawData, annotating it with MyBatis annotations @Select and @Results. The only repository method usually returns Java objects of data directly mapped to a corresponding database table, "as is", without any custom logic, enrichment etc. This data type is named "raw" below. Repositories are stored in vahub-model module.
  • Data providers - this layer receives raw data from the repository layer and wraps the raw data object into a more complex one that has some additional properties, either calculated from basic ones or provided by some enrichment operations (the main such operation for ordinary domain data object is normally the addition of investigation subject data). These wrapper classes usually extend the SubjectAwareWrapper class. This data type is named "enriched" below. Data provider class typically extends the DatasetsDataProvider abstract class and is an ordinary Spring @Component. Data providers are stored in vahub-model module.
  • Services - this layer uses enriched data from data providers to prepare it for UI. Main groups of services are plot services and filter services. Filter services calculate filter values basing on enriched data from data providers. Plot services filter data accordingly with received filters settings, prepare data for visual presentation on different plot types etc. Also, plot services normally provide details-on-demand (DoD) data — it's the transformed enriched data from data providers that may be requested by user to get additional information about the data drawn on the plot itself. There is also some more special services, e. g., for most domain entities a Timeline service exists. Typical service is an ordinary Spring @Service. Services are stored in vahub-model module.
  • Resources (the highest level) - this layer provides REST resources to which frontend part may send data requests; then a resource returns the data provided by corresponding service. Return types of REST resource methods are (or should be, at least) included (directly, or through wildcards, or through transitive dependencies) in Typescript classes generation list (in settings of typescript-generator-maven-plugin inside some of pom.xml configs) — it allows to use them also on the frontend. For a domain entity, there are typically either several Resource classes separated by task type or one big Resource class that contains all REST resouces related to it. Typical resource class is an ordinary Spring @RestController. Resources are stored in vahub module.

VAHub widely uses caching. As users can't change anyway the most part of data, it's quite handy to cache the precalculated data and avoid their recalculation when they are requested again.

Clone this wiki locally