Best practice: Spring Boot + Angular project structure and architecture [closed]

  angular, architecture, maven, spring, spring-boot

I am building an application which consists of a spring boot backend and an angular frontend.
Would you rather keep the projects separated (own folders and own webservers) or would you prefer including the angular app inside the spring boot app?

Requirements:

  • maven project
  • spring security (login + registration) -> form? basic? jwt?
  • Angular frontend
  • Spring Boot Backend

I thought of following possibilities:

Angular inside spring project running on same server

The Angular project folder is inside the spring boot project. When building the spring boot application the angular project is built and included inside the static folder.

Advantages:

  • only one deployable
  • easy use of spring security (form login + sessions)
  • single code base

Disadvantages:

  • ui is highly dependent on backend
  • load balancing could be more difficult (I am not sure about this)

Spring Boot + Angular in one project and same server

The angular app and spring boot app are in separate folders (maybe a root project including these 2 maven modules). When building the spring project the angular project is built and included in it’s target folder (something like: https://github.com/FraktonDevelopers/spring-boot-angular-maven-build)

Advantages:

  • only one deployable
  • easy use of spring security (form login + sessions)
  • single code base
  • multi module maven project

Disadvantages:

  • ui is highly dependent on backend
  • load balancing could be more difficult (I am not sure about this)

Spring Boot + Angular in one project and different servers

The Angular project folder is in in the same project as the spring boot project (maybe one root folder and inside it there is the ui and the backend project as separate folders). The backend and the ui are running on separate servers (angular is not included in the jar/war of spring boot)

Advantages:

  • single code base
  • decoupled ui from backend
    Disadvantages:
  • security is much more difficult (you need to do check if users are logged in manually in the frontend and receive the session/jwt manually)

Spring Boot + Angular in different projects and different servers

The two projects are completely separated (two git repos) and have no code in common. They are deployed on different servers.

Advantages:

  • decoupled ui from backend
    Disadvantages:
  • security is much more difficult (you need to do check if users are logged in manually in the frontend and receive the session/jwt manually)
  • you have to open two projects when developing

Which project structure is "best practice"? Are there other alternatives? dit I miss any advantages/disadvantages?

Are there any example projects / open source projects you could recommend? I would prefere architectures/structures which are production ready and preferably they include spring security.

Source: Angular Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.