Web Application - morenagit/wikiTest GitHub Wiki
Web Application
General description
The web application side has been developed through the Mean stack architecture. MEAN is an open-source stack of Javascript-based technologies for building web applications. These technologies support the MVC (Model View Controller) architectural pattern. MEAN is an acronym for the four main technologies (from client-side, to server-side, to database) of the stack. These are:
- M = MongoDB is a document-oriented database that implements a NoSQL structure. MongoDB is also available as MongoDB Atlas, a fully managed cloud database.
- E = Express.js is a framework that supports and is used to host Node.js projects. It provides various features such as defining routes based on HTTP methods, and creating a REST API server.
- A = Angular.js is a client-side framework for building web apps based on the model–view–controller (MVC) architecture.
- N = Node.js is a runtime environment which runs server-side web applications.
The typical flow of request and responses in a MEAN stack web application takes place as follows:
- The client makes a request, which is processed by AngularJS.
- The request is forwarded to the NodeJS server.
- ExpressJS makes the request to the database.
- MongoDB processes the request, and returns the data to ExpressJS.
- ExpressJS sends a response to NodeJS.
- AngularJS receives the response from the server-side, and displays the result to the user.
Cient side
AngularJS
AngularJS is a browser-independent, open-source JavaScript framework. It is based on the MVC (Model View Controller) architectural pattern. MVC allows to split the application’s logical units into three interconnected elements, in order to separate the different responsibilities.
- Model: it’s responsible for managing application data. All the data is fetched from the server through the model. Whenever a user is interacting with the view, the data being displayed will be coming from the model.
- View: displays data to the end user. It represents the interface that the users interacts with. The presentation is triggered by the controller, and changes according to the model.
- Controller: it’s the code that determines how the model and the view interact. The business logic resides in the controller, as it performs the actions that control the behaviour of the application.
Server side
NodeJS
Node.js is a lightweight server-side platform to build fast and scalable web applications. This technology presents some fundamental advantages that make it perfect for IoT environments. First of all, it is able to handle concurrent requests very quickly by applying the asynchronous event-driven I/O model. This means that the server never waits for an API to return data, but it moves on to the next request after calling the API. This is perfect for distributed real-time applications and IoT scenarios characterized by a heavy flow of data, which must be processed in real time. Moreover, a NodeJS server executes code fast improving performance, and can handle a large number of client requests. It can also expose APIs to allow the interaction with physical sensors.
ExpressJS
ExpressJs is a lightweight server framework that provides additional features to extend server-side coding. It is mainly used for managing routing, handling HTTP requests and simplifying the definition of REST APIs. Express allows us to define a middleware to respond to RESTful requests.
Database
MongoDB
MongoDB is a NoSQL open-source, cross-platform database. It features Document Oriented Storage, which means that data is stored in the form of JSON-like documents. Mongoose is an ODM (Object Data Modeling) library for MongoDB. It allows us to easily define objects by means of a schema that is mapped to a MongoDB document. A mongoose schema defines the structure of the document, while a model creates an instance of a document from a schema.
The main advantages of using MongoDB are:
- Flexible Models: MongoDB has a schema-less structure, meaning that the structure of the documents can vary. This speeds up application development.
- Geospatial support: MongoDB supports query operations on geospatial data. The database schemas support the storage of location data as GeoJSON objects. This allows us to perform a set of geospatial queries on these objects.
- Scalability
- High Performance
- Built for the cloud