Skip to content

Project Structure

ValerianWeiss edited this page Aug 8, 2018 · 7 revisions

In General the Application consists out of 7 components:

  • A Authentication server (Spring Boot Microservice)
  • A Resource server (Spring Boot Microservice)
  • A Websocket server (Spring Boot Microservice)
  • A service registry (Spring Boot Microservice)
  • A API gateway (Spring Boot Microservice)
  • A MySql database
  • A Tomcat web server which contains the Vue front end

Diagram of project structure

The project also has a libs folder. In this folder are two more projects. The communication project, which provides the classes for the REST endpoints to deserialize the calls. And the security project which includes the security configuration and a custom token filter. The security library also says which rest endpoint should be protected. These projects don’t have any dependency to other Projects. The two projects are separated to reduce code redundancy and make it easy to use them. The security project for example. You just have to include it in another project and you’ve set up the entire security for the project and you still can configure it.

Authentication server

The Authentication server is managing the authentication and authorization of the users. That means if a user wants to login or register, the user is talking to the Authentication server. If a user is requesting a resource (e.g. GET-Request) on the Resource server which is protected and you have to be logged in to get a response, the Resource server will send a request to the Authentication server, and asks him if the user is logged in. To validate if a user is logged in, JWTs are used. So as a users you will always send a JWT with your requests, which can be validated.

Resources server

The Resource server is a gateway to the Database and offers a REST-API which the User can access via the Vue front end and the API Gateway. The data which will be returned will be visualized in the front end.

Websocket server

The Websocket server is the access point for the websocket clients from the Vue front end. So this Microservice contains a Websocket Broker which publishes messages to certain topics. It also offers an REST-API to add data points for to some topics, which are getting published immediately. All data points which are getting received will be stored in the Database.

Tomcat web server

The webserver offers the Vue application which is a Single Page Application (SPA). The front end is interacting with the backend via REST and websockets. The Vue application is also using Vuex and Vue Router. To protect certain routes in the SPA there is a routine in the Vue Router object which is talking to the Authentication server.

Service Registry

A simple Eureka registry server where all the Spring Boot microservices are registered. Up to now there is no additional logic in it. It is just the main function with the annotation to enable the Eureka server.

package com.vuebackend;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class EurekaServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServiceApplication.class, args);
    }
}

API Gateway

This module is simply forwarding REST requests to the microservices. For that the server is using Feign and Eureka to get the right microservice and forwards the request to it.

Database

The Database is a MySql database. The entiere data model is getting built by the Resources server. So there is no logic in the database yet.

Clone this wiki locally