Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Architecture

Emily edited this page Nov 17, 2019 · 9 revisions

With three individual applications (as well as a separate dashboard to bring them together) using a fairly complex system of databases and servers, the system architecture of this project is one of the trickier aspects to fully comprehend. As such, a system architecture diagram has been included below.

On the left of the diagram, the frontend is represented by a Vue node. The frontend communicates with the database through an Apollo GraphQL server.

Apollo is responsible for authenticating queries and mutations to the primary database, as well as adding user details to the query context. This is done using GraphQL and UQ Authenticate (formerly UQ Single Sign-On), and the process is discussed in detail in the section on authentication handling. The Apollo server is set up here to run on port 4000.

Queries and mutations to the primary database are sent via the GraphQL server to query the PostgreSQL database. Responses to these queries and mutations are then sent back to the frontend via the same server.

The structure of the database itself, as well as how the various entities are related, is set up using Sequelize, an Object Relational Mapping (ORM). ORMs effectively allow SQL databases (such as the PostgreSQL one in use here) to be queried in an object-oriented manner and without writing any actual SQL queries. Sequelize schema used to model tables can be found here. Throughout the rest of the code queries and mutations which use these Sequelize schemas can be found, with most other related database material found here.

Redis

Redis is an in-memory database which is used by the GraphQL server to send requests to the Stanford MoSS servers on behalf of the Investigate application. It uses the publish/subscribe (or 'pub/sub') pattern to accomplish this. Essentially, both the Apollo GraphQL server and the MoSS server subscribe to the Redis database. Whenever a request needs to be made from the Apollo GraphQL server, it publishes this to the Redis database.

In response, because MoSS is subscribed to Redis, it handles this request. The MoSS results are then published to Redis, and are thereby made available to the express server.

The Redis side of the architecture (with its subscriptions) are also modelled by Sequelize. More information can be found here, where the subscriptions are set up to asynchronously receive updates from the Redis database.

Clone this wiki locally