Uncategorized

Client/Server Exception and Success Mapping for Adventuretube Microservice

In a well-designed microservice system, exception and success classification must be consistent, traceable, and informative. Below is a complete reference list organized by type and mapped to HTTP status codes. Each exception or success type reflects its purpose: successful operations (2xx), client errors (4xx), or server errors (5xx). ✅ 1. Success Response Types → HTTP […]

Client/Server Exception and Success Mapping for Adventuretube Microservice Read More »

Uncategorized

Exception Architecture in Adventuretube Microservices

The Adventuretube backend is designed with a clear separation of exception types, handling responsibilities, and architectural patterns to support robust, scalable microservices. There are two primary layers of exception management in the system: 1. Checked Exceptions (Handled with try-catch) These are exceptions that represent recoverable or gracefully degradable failures, such as I/O problems, API call

Exception Architecture in Adventuretube Microservices Read More »

Uncategorized

How Spring Security Authentication Flow Has Been Implemented in AdventureTube auth-service Module

  1. 🎯 Purpose This document explains how Spring Security’s authentication flow is custom-configured and used inside the auth-service module of the AdventureTube microservices system, especially for authenticating users via Google ID tokens. 2. 🔐 Authentication Scenario The only point where authentication is explicitly triggered is during POST /auth/issueToken. This endpoint receives a valid Google

How Spring Security Authentication Flow Has Been Implemented in AdventureTube auth-service Module Read More »

Uncategorized

Understanding Spring Test Types in Microservice Projects

Understanding Spring Test Types in Microservice Projects In a real-world Spring Boot microservice architecture, choosing the right kind of test can drastically affect test speed, confidence, and maintainability. This guide breaks down key test types used in Spring applications, their purposes, and best practices. ✅ 1. Unit Test (Pure Java) Purpose: Test a single class/method

Understanding Spring Test Types in Microservice Projects Read More »

Uncategorized

Custom Spring Security Test in Spring Boot

When writing tests for Spring Security, it’s important to align your test scope with the actual application flow. Here’s how to test your CustomUserDetailService correctly in a Spring Boot microservices setup that communicates with another service via RestTemplate and is wired into the AuthenticationManager. ✅ Why Testing AuthenticationManager Is Better Than Calling loadUserByUsername() Calling authenticationManager.authenticate(…):

Custom Spring Security Test in Spring Boot Read More »

Uncategorized

How Spring Config Server and .env Collaborate in Multi-Env Microservices

In the AdventureTube backend microservices architecture, configuration management is handled through a collaboration between Spring Cloud Config Server and environment (.env) files. This setup ensures consistency, flexibility, and secure handling of configuration data across different stages of deployment. 🧩 Background of env.XXX File Design The original idea behind creating env.XXX files was for Docker-based environments,

How Spring Config Server and .env Collaborate in Multi-Env Microservices Read More »

Uncategorized

MapStruct Debug in Microservice

1. Configuration in Microservice For MapStruct to function properly within a Spring Boot microservices architecture, both the parent and sub-module pom.xml files must be correctly configured: Parent pom.xml <dependencyManagement> <dependencies> <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct</artifactId> <version>1.5.5.Final</version> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.10.1</version> <configuration> <annotationProcessorPaths> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>1.5.5.Final</version> </path> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.30</version> </path>

MapStruct Debug in Microservice Read More »

Uncategorized

Adventuretube REST API Architecture Principle

1. Correct Design of Controller and Service Principle: Thin Controller, Fat Service Controllers should only handle HTTP concerns: routing, request/response formatting, and returning status codes. Services should encapsulate business logic, including all validations and error throwing. Why This Matters 1. Separation of Concerns Layer Responsibility Controller Handle HTTP interface Service Contain domain logic and validation

Adventuretube REST API Architecture Principle Read More »

Uncategorized

Spring Security Configuration: From Default to Advanced Setup

This document has been created to answer the question of what is the best way to understand Spring Security and customise configuration on demand.  So we will start with the default configuration first and move to the customisation. 1. Default Spring Security Setup (Basic) Description A minimal setup relying on Spring Boot’s auto-configuration. Ideal for

Spring Security Configuration: From Default to Advanced Setup Read More »

Uncategorized

Custom vs Default Credential Authentication in Spring Security

Let’s compares the default credential authentication process used by Spring Security and the custom credential authentication logic defined in the CustomAuthenticationProvider of the auth-service module. ⚙️ Default Credential Flow (Current Behavior) By default, AdventureTube’s auth-service uses Spring Security’s built-in DaoAuthenticationProvider through this configuration: authenticationManagerBuilder .userDetailsService(userDetailsService) .passwordEncoder(passwordEncoder()); 🔁 Flow Spring injects DaoAuthenticationProvider It uses your CustomUserDetailService

Custom vs Default Credential Authentication in Spring Security Read More »

Uncategorized