How abhishekvermaa10/spring-basics-with-spring-boot works
Project Type and Purpose
• This is a multi-module, tutorial-style repository teaching Spring Framework fundamentals and Spring Boot best practices.
• The final module, Petistaan, is a console-based CRUD application built on Spring Boot that demonstrates:
– Inversion of Control & Dependency Injection
– Spring AOP (LogAspect)
– Externalized Configuration (YAML, properties, banners)
– Layered architecture: DTOs, Services, Repositories
– Exception handling & testing
File Structure (Focus on Petistaan)
• Top-level modules: Demo0…Demo17, Petistaan
• Each demo is a self-contained Maven subproject; Petistaan is the most feature-rich.
• Petistaan/src/main/java/com/abhishekvermaa10:
– aspect/LogAspect.java
– dto/*.java
– enums/*.java
– exception/*.java
– repository/* + impl/*
– service/* + impl/*
– util/InputUtil.java
– Demo.java (entry point / CommandLineRunner)
• Petistaan/src/main/resources:
– application.yml, banner.txt, messages.properties
• Tests for service & repository layers
Key Architectural Patterns & Technologies
• Spring Boot Application (auto-configuration, component scanning)
• Layered architecture (Controller/CLI → Service → Repository → Data store)
• Dependency Injection (constructor-based)
• Aspect-Oriented Programming (LogAspect intercepting service & repo calls)
• Externalized configuration & profiles (YAML, properties)
• DTO pattern for data transfer
• Exception hierarchy for domain errors
• Unit testing with JUnit for service & repository
Main Components and Relationships
a. Entry Point
– Demo.java implements CommandLineRunner: bootstraps Spring, invokes InputUtil to read user commands.
b. Input Layer
– InputUtil: handles console I/O, passes commands to Services.
c. Service Layer
– OwnerService, PetService (interfaces), OwnerServiceImpl, PetServiceImpl (implementations)
– Business logic: create/read/update/delete Owners & Pets, apply validation, throw exceptions.
d. Repository Layer
– OwnerRepository, PetRepository (interfaces), Impl classes with in-memory collections.
e. Domain / DTOs / Enums
– DTOs (OwnerDTO, PetDTO, DomesticPetDTO, WildPetDTO) encapsulate data.
– Enums (Gender, PetType) define allowed values.
f. Cross-Cutting Concerns
– LogAspect: monitors entry/exit of service & repo methods, logs via Spring AOP.
g. Configuration
– application.yml: defines profiles, message codes.
– messages.properties: externalized messages.
– banner.txt: custom startup banner.
h. Spring Context
– Bean Container holds all @Component, @Service, @Repository, @Aspect beans.
Relationships and Data Flow
– Console User → Demo.java → InputUtil → Service → Repository → Data Store
• LogAspect weaving:
• Configuration being read at startup: