This the the server of the mail (or message) app. It was developed in Groovy (for XML support) with Spring Boot.
It has a local 'version', using files on the local file system, and a firebase version, using file from firebase storage. These 'versions' are called profiles. We will discuss later on why we used different storage.
The project is structured with many packages:
Holding classes related to the configuration of the projects. It is where we instantiate the objects that will be dependency injected by Spring Boot
A Controller is a class responsible of handling web
requests. Each function annotated with a Mapping
annotation will be executed for
the given endpoint (and method) specified the annotation
Exception allowing to stop execution of a request and return a specific error response code.
All data classes
A Repository is a class allowing to retrieve/save elements of a certain type
A Service is a class allowing to perform some operation, handle/convert data
A storage is an element allowing to store, retrieve data from a storage, in this case firebase. The Firebase API is not easy to use, that is why we decided to abstract the use of this API with this kind of class
In order to make this server accessible to the front end, we used Heroku, a service that can hosts REST APIs and give a public URL. The problem is that Heroku doesn't allow the API to use a local storage, that is why we used Firebase Storage, a cloud storage solution.
But the transfer of files with Regis's app would be made through the local file system (apps would run in the same computer for the presentation).
That is why we created two profiles, local
and firebase
.
Each class specific for a given storage is annotated with
@Profile('profile')
This API has a documentation generated by a Swagger. It is accessible via this url Note that the first ping to an Heroku link might be slow because Heroku ('s free forfeit) kills the application after 30mn of inactivity
If you run the application locally, the url is http://localhost:8080/ and the swagger is http://localhost:8080/swagger-ui.html
Each messages sent by the client to the server are validated by the schemas provided by Regis, and if they are valid, they'll be stored
Mails are also validated when they are read (on the localMailRepository)