Advanced Spring and Microservices Architecture

This course dives into advanced Spring projects, focusing on microservices architecture, Docker deployment, and OAuth2 authentication. It covers building scalable, secure applications using Spring Boot, Gradle, and various other Spring components.

Objective

  • Work with advanced Spring projects.
  • Implement user authentication with OAuth2.
  • Deploy an application using the microservice architecture.

Curriculum

Introduction to Microservices

  • What is Monolith Architecture?
  • Benefits of the Monolith Architecture
  • Problems with the Monolith Architecture
  • What is Microservice Architecture?
  • Benefits of the Microservice Architecture
  • Challenges of the Microservice Architecture
  • Components of a Microservice Architecture

Microservices Components

  • Service Discovery
  • API Gateway
  • Service Orchestration
  • Externalized Configuration

Docker Deployment

  • What is Docker?
  • Brief History of Docker
  • Benefits of Using Docker
  • Docker Use Cases

Basic Docker Concepts

  • What is a Dockerfile?
  • What are Docker Images?
  • What are Docker Containers?
  • Dockerfile Commands

Container Lifecycle

  • Container Lifecycle
  • Basic Docker CLI Commands

Docker Storage

  • What is Docker Storage?
  • Three Docker Storage Mount Types

Docker Networks

  • What are Docker Networks?
  • Importance of Docker Networks
  • User-defined bridge networks
  • Host network

Docker Hub

  • Publishing images to Docker Hub
  • Pulling images from Docker Hub

Docker Compose

  • What is container orchestration?
  • What is Docker Compose?
  • Installing Docker Compose plugin
  • Creating a Docker Compose File
  • Docker Compose CLI
  • Docker Compose YML File

Gradle (1)

  • What is Gradle?
  • Gradle vs. Maven
  • Gradle Installation
  • Build Script File
  • Build Management
  • Dependency Management

Spring Boot

  • Spring Boot Gradle Plugin
  • Spring Dependency Management Plugin

JPA / Hibernate

  • What is Object Relational Mapping?
  • What is JPA?
  • Brief History of JPA
  • Benefits of using JPA
  • What is Hibernate?
  • Differences between JPA and Hibernate

JPA / Hibernate Entity

  • What is an Entity? ( @Entity and @Id )
  • Primary Key Generation ( @GeneratedValue )
  • Column Definition ( @Column )
  • Table Definition ( @Table )
  • Entity States ( Transient Persistent Detached Removed )
  • EntityManager ( @PersistenceContext )
  • EntityManagerFactory ( @PersistenceUnit )
  • Entity Lifecycle

JPA / Hibernate Relationships

  • @OneToOne
  • FetchType
  • CascadeType
  • Unidirectional Association
  • Bidirectional Association
  • Preventing Recursive Calls with Bidirectional Association
  • @ManyToOne
  • @OneToMany
  • Many-To-Many Extra Columns Relationship Mapping
  • N+1 Query Problem

Spring Data JPA

  • What is Spring Data JPA?
  • JpaRepository
  • @EnableJpaRepositories
  • CRUD with Spring Data JPA
  • Sorting & Pagination with Pageable

Spring Data JPA (Spring Data)

  • What is Spring Data?
  • Modules of Spring Data
  • Features of Spring Data
  • CrudRepository
  • PagingAndSortingRepository

Spring Data JPA (Custom Queries)

  • What is JPQL?
  • What is a Native Query?
  • JPQL vs. Native Queries
  • @Query (JPQL, NativeQuery)
  • Derived Query Methods

Spring Boot Testing

  • Introduction to Testing
  • Why Write Tests?
  • Unit Tests
  • Integration Tests
  • Functional Tests
  • Introduction to JUnit 5
  • Introduction to Mockito
  • Creating Mocks
  • JUnit Mockito Extension
  • Injecting Mocks with Mockito
  • Returning values from Mockito Mocks
  • Introduction to Spring MVC Tests
  • Introduction to Spring MVC RestController
  • Using JsonPath in MockMVC Tests
  • Using JsonPath with Lists

Mini Project 1 Gradle

  • Spring Data JPA

Spring Profiles

  • What are Spring Profiles?
  • What Do Profiles Control?
  • Why do we need Spring Profiles?
  • When to use Spring Profiles?
  • Profile-specific Properties
  • Creating New Profiles
  • Default Profile
  • Active Profiles
  • Changing Spring Profiles via Environment Variables

OAuth2 Overview

  • What is OAuth2 Authentication?
  • OAuth2 for Third Party Access
  • The Password Anti-pattern
  • The solution provided by OAuth2

OAuth2 with OpenID Connect

  • What is OIDC?
  • Common OIDC Endpoints

OAuth2 with Abstract Protocol Flow

  • Grant Types
  • Authorization Code
  • PKCE-enhanced Authorization Code
  • Client Credentials
  • Device Code
  • Refresh Token
  • Legacy Grant Types
  • What does Legacy mean?
  • Implicit Flow
  • Password Grant
  • When to use each Grant Type

Keycloak Overview

  • What is an Authentication Server?
  • What is Keycloak?
  • Benefits of using Keycloak
  • (Optional) Deploying Keycloak with Docker Compose

Keycloak Configuration

  • What are Realms?
  • What are Clients?
  • What are Users?
  • What are Realm Roles?
  • What are Client Roles?
  • Assigning Roles to users
  • Exporting Keycloak Configurations

Single Sign-On (SSO)

  • What is SSO?
  • Third party login with Keycloak

Keycloak REST API

  • OpenID Configuration Endpoint
  • Authorize Endpoint
  • Token Endpoint
  • User Information Endpoint
  • Token Introspection Endpoint

Spring Boot OAuth2 Resource Server Configuration

  • What is a Resource Server?
  • Enable OAuth2 in Spring Boot
  • Configure Spring Boot
  • (Optional) HTTPS Configuration with Keycloak and NGINX

Gradle 2 ( Multi-Project Build )

  • What is a multi-module project/multi-project build?
  • Benefits of using multi-project builds
  • Multi-Project Build Structure
  • Adding subprojects
  • Best Practices & Common Mistakes

OpenFeign

  • What is OpenFeign?
  • Calling REST Services in Spring Boot
  • RestTemplate vs. FeignClient vs. WebClient
  • Creating a FeignClient Instance
  • Sending HTTP requests
  • Reading the response

Spring Cloud Config Server Overview

  • What is Spring Cloud?
  • Why use Spring Cloud?
  • What are Spring Cloud components?

Spring Cloud Externalized Configuration

  • What is a Spring Cloud Config?
  • What is Externalized Configuration?
  • Benefits of using Externalized Configuration
  • Spring Cloud Config Server
  • Spring Cloud Config Client

Spring Cloud Environment Repository

  • What is an Environment Repository?
  • Git Backend
  • File System Backend
  • Encryption and Decryption

API Gateway Overview

  • What is an API Gateway?
  • How do API Gateways Work?
  • Request Routing
  • API Composition
  • Protocol Translation
  • Benefits of Using an API Gateway
  • Challenges of Using an API Gateway

Spring Cloud Gateway

  • Introduction to Spring Cloud Gateway
  • Routing Handler
  • Using Java
  • Using properties configuration
  • Auto Mapping of Gateway Route
  • Manually Configure Gateway Route
  • API Gateway Predicate
  • Web Filters
  • What is a Load Balancer?
  • Spring Cloud API Gateway as a Load Balancer
  • Spring Cloud API Gateway Global and Custom Filter

Service Discovery Overview

  • What is Service Discovery?
  • Popular Service Discovery Tools
  • Benefits of Using Service Registry

Spring Cloud Service Registration and Discovery

  • Creating an Eureka Service Registry in Spring Boot
  • Register a Spring Boot App with Eureka
  • Load balancing with OpenFeign

Circuit Breaker

  • Failures in Microservices
  • How Does Circuit Breaker Operate?
  • Popular circuit breakers for Spring Boot
  • Resilience4j
  • Hystrix
  • How Does Resilience4j Work?
  • Configure and enable Resilience4j
  • @CircuitBreaker

Distributed Tracing

  • The importance of distributed tracing
  • Introduction to Sleuth and Zipkin
  • Deploy Zipkin with Docker Compose
  • Configure Spring Boot with Zipkin
  • View Traces of Sleuth in Zipkin

Message Brokers (Microservice Communication)

  • What is a Message Broker?
  • Synchronous vs. Asynchronous Communication
  • Advantages of Asynchronous Communication

Message Brokers (Some Messaging Patterns)

  • Request/Response
  • Fire and Forget
  • Pub/Sub Pattern
  • Message Queue

Choosing a Message Broker

  • RabbitMQ
  • Kafka
  • Apache ActiveMQ

RabbitMQ Overview

  • What is RabbitMQ?
  • What is AMQP?
  • Four Exchange Types of AMQP

RabbitMQ Setup

  • Deploy RabbitMQ with Docker Compose
  • Spring Boot configuration with RabbitMQ
  • Creating a publisher in RabbitMQ
  • Subscribing to RabbitMQ

Kafka Overview

  • Introduction to Apache Kafka
  • Apache Kafka vs. Confluent Kafka
  • Four Core Components of a Kafka System
  • Kafka Topics
  • Kafka Partitions

Kafka System Setup

  • Setup Zookeeper and Kafka Broker with Docker Compose
  • Build Spring Boot Kafka Producer
  • Build Spring Boot Kafka Consumer

WebSocket

  • What is a WebSocket?
  • What is the STOMP messaging protocol?
  • WebSocket Connection vs. HTTP Connection

Project Setup with WebSocket

  • Create a WebSocket in Spring Boot with RabbitMQ/Kafka as a message broker
  • Create a STOMP client with SockJS with Javascript, ReactJS or Angular