Overall Architecture

The application makes use of four key services to function:

  1. Svelte – A special frontend framework that allows responsive code to be written, and then compiled to standard javascript.
  2. Vercel – A hosting service that allows us to easily deploy the Svelte frontend.
  3. AWS – Provides a gateway that links to serverless Lambda functions to perform logic operations and CRUD access to the database.
  4. MongoDB – A NoSQL cloud hosted database to store the data.

Overall Architecture

1.1 Svelte

Svelte is a unique component framework that allows for reactive and rapid development in a similar way to more well-known frameworks such as React or Vue. The difference with Svelte is that it compiles everything to standard JavaScript rather than requiring a framework to be downloaded by the client.

The Svelte generated frontend which is hosted on a Vercel virtual environment makes calls to the backend via the AWS REST API gateway using the Fetch API. Every time the client does an action that requires data transfer to the backend, a HTTP request is sent to a specified gateway endpoint for processing and the result is relayed to the client.

1.2 Vercel

Vercel offers a virtual hosting environment that integrates well with Svelte. Within our GitHub repository we have an action script that automatically initiates a build and deployment to Vercel every time a push is made.

Vercel automatically builds and deploys the code to either a preview environment, or when pushing to the main branch, a production environment. This allows the easy identification of any build errors, as well as providing a fast to inspect the state of the application and perform any required tests in a hosted environment.

1.3 Amazon Web Services (AWS)

AWS is a cloud operator that offers a huge range of services that allow rapid development without the need for procurement of the required hardware.

The AWS Gateway that we use for our application is set up with a number of endpoint that accept a designated HTTP request type such as GET or POST. Each endpoint and request type is configured to pass the request on to a designated Lambda function for processing.

Lambda functions are a lean virtual environments that contain just enough dependencies to process the passed request. The Lambda environment spins up when it receives a request, processes the request, and then terminates when the request is complete, saving resources and cost.

The Lambda functions direct CRUD operations over the internet to MongoDB Atlas. MongoDB processes the request and returns the result of the database action back to the Lambda function.

Once the database data is returned to the Lambda function, the data is further manipulated and processed as required by the Lambda. Once complete, the required results are returned back through the gateway, and on to the clients browser.

1.4 MongoDB Atlas

MongoDB Atlas is a cloud-hosted NoSQL database that is used to store all the client data. The free-tier that we are using for the assignment exists on a shared virtual server running on AWS infrastructure.

When the request is received from the Lambda function, the user is first validated, and then the request is processed by the virtual server. As MongoDB is a NoSQL database, there is no SQL query language interpreter running on the server. To access the data, a series or structured JSON requests must be passed to the server which is then actioned against the data.