Skip to content

Architecture

GBHU753 edited this page May 19, 2024 · 1 revision

Architecture

General Overview

Architecture

The architecture of the system is based on the following components:

  • Frontend: The frontend is a web application that is built using NextJS. It is responsible for rendering the user interface and handling user interactions. The frontend communicates with the backend via a RESTful API.

  • Backend: The backend is a Node.js application that is built using Express. It is responsible for handling requests from the frontend, interacting with the database, and performing business logic. The backend communicates with the database using an ORM (Object-Relational Mapping) manager called Prisma. The backend database is a PostgreSQL database that had been configured to run in a Docker container. OpenAPI is used to define the API specification and Swagger UI is used to document the API. These tools are used to ensure that the API is well-documented and easy to use. The database is a PostgreSQL database that stores the data for the application. The database schema is defined using Prisma's schema language. The database is hosted in a Docker container and is managed using Prisma.

In-Depth Overview

Frontend

The frontend is a web application that is built using NextJS (If you are still confused about the difference between React and NextJS see Frontend Language Comparison). NextJS is a React framework that allows you to build server-side rendered web applications. The frontend is responsible for rendering the user interface and handling user interactions. The frontend communicates with the backend via a RESTful API. The frontend is built using TypeScript, which is a statically typed superset of JavaScript. This allows for better type checking and code completion.

The communication between the frontend and the backend is an OpenAPI client that is automatically generated from the OpenAPI specification. This client provides a type-safe way to interact with the backend API. The frontend uses this client to make requests to the backend and handle responses. The frontend does not need to implement any API logic, as this is handled by the OpenAPI client. This ensures that the frontend and backend are decoupled and can be developed independently. The OpenAPI client used RESTful to communicate with the backend over HTTPS.

What is RESTful? RESTful is an architectural style that defines a set of constraints for creating web services. RESTful services are stateless, meaning that each request from a client contains all the information needed to process the request. RESTful services use standard HTTP methods (GET, POST, PUT, DELETE) to perform operations on resources. RESTful services are designed to be scalable, reliable, and easy to maintain.

Backend

The backend is a Node.js application that is built using Express. Express is a web framework for Node.js that provides a set of tools for building web applications. The backend is responsible for handling requests from the frontend.

What is the difference between Node.js and Express? Node.js is the underlying runtime that lets you run JavaScript on the server. Express is a framework built on top of Node.js that simplifies the process of building web applications and APIs. You could use Node.js alone to create a server, but it would require more code and setup for handling routes, managing requests, etc as it is low-level. With Express, you can quickly set up a server with less code, thanks to its built-in functionalities and middleware support. Both Node.js and Express are used together to build APIs and are written in JavaScript.

A package called express-openapi is used to define the API specification in OpenAPI format. This package automatically generates the API documentation using Swagger UI. This ensures that the API is well-documented and easy to use. This package also provides validation for the API requests and responses, ensuring that the API follows the defined specification.

The backend communicates with the database pod (If you are confused about what containerisation is and what a pod is see Docker) using an ORM (Object-Relational Mapping) manager called Prisma. Prisma is a modern database toolkit that simplifies database access in express applications. It provides a type-safe way to interact with the database and automatically generates the database schema based on the Prisma schema language. It provides high-level functions for querying the database and handling transactions. Prisma also provides a migration tool that allows you to manage the database schema changes.

The database is a PostgreSQL database that stores the data for the application. The database is hosted in a Docker container (If you are confused about what containerisation is see Docker) and is managed using Prisma.

Clone this wiki locally