# abhishekvermaa10/spring-basics-with-spring-boot architecture

> Architecture diagram of the GitHub repository abhishekvermaa10/spring-basics-with-spring-boot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhishekvermaa10/spring-basics-with-spring-boot
- Repository: https://github.com/abhishekvermaa10/spring-basics-with-spring-boot

## Overview

##### 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:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% High-Level Modules
    subgraph "Parent POM"
        style ParentPOM fill:#f9f,stroke:#333,stroke-width:1px
        ParentPOM["Parent POM"]
        ParentPOM --> Demo0["Demo0"]
        ParentPOM --> Demo1["Demo1"]
        ParentPOM --> Demo2["Demo2"]
        ParentPOM --> Demo3["Demo3"]
        ParentPOM --> Demo4["Demo4"]
        ParentPOM --> Demo5["Demo5"]
        ParentPOM --> Demo6["Demo6"]
        ParentPOM --> Demo7["Demo7"]
        ParentPOM --> Demo8["Demo8"]
        ParentPOM --> Demo9["Demo9"]
        ParentPOM --> Demo10["Demo10"]
        ParentPOM --> Demo11["Demo11"]
        ParentPOM --> Demo12["Demo12"]
        ParentPOM --> Demo13["Demo13"]
        ParentPOM --> Demo14["Demo14"]
        ParentPOM --> Demo15["Demo15"]
        ParentPOM --> Demo16["Demo16"]
        ParentPOM --> Demo17["Demo17"]
        ParentPOM --> PetistaanModule["Petistaan"]
    end

    %% Petistaan Application
    subgraph "Petistaan (Spring Boot Application)"
        direction TB
        subgraph "Spring IoC Container"
            direction TB
            U["Demo.java\n(CommandLineRunner)"]:::code
            U --> V["InputUtil"]:::code
            subgraph "Service Layer"
                direction TB
                OS["OwnerService"]:::code
                PS["PetService"]:::code
                OSi["OwnerServiceImpl"]:::code
                PSi["PetServiceImpl"]:::code
                V --> OS
                V --> PS
                OS --> OSi
                PS --> PSi
            end
            subgraph "Repository Layer"
                direction TB
                OR["OwnerRepository"]:::code
                PR["PetRepository"]:::code
                ORi["OwnerRepositoryImpl"]:::code
                PRi["PetRepositoryImpl"]:::code
                OSi --> OR
                PSi --> PR
                OR --> ORi
                PR --> PRi
            end
            subgraph "In-Memory Data Store"
                direction TB
                DS[(Collections)]:::datastore
                ORi --> DS
                PRi --> DS
            end
        end

        %% Cross-Cutting Concerns and Config
        AOP["LogAspect"]:::aspect
        Config["Configuration\n(application.yml,\nmessages.properties,\nbanner.txt)"]:::config

        AOP -.-> OSi
        AOP -.-> PSi
        AOP -.-> ORi
        AOP -.-> PRi

        Config --> U
    end

    %% External User
    User([Console User]):::external
    User --> U

    %% Click Events
    click U "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/Demo.java"
    click V "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/util/InputUtil.java"
    click OS "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/service/OwnerService.java"
    click PS "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/service/PetService.java"
    click OSi "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/service/impl/OwnerServiceImpl.java"
    click PSi "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/service/impl/PetServiceImpl.java"
    click OR "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/repository/OwnerRepository.java"
    click PR "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/repository/PetRepository.java"
    click ORi "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/repository/impl/OwnerRepositoryImpl.java"
    click PRi "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/repository/impl/PetRepositoryImpl.java"
    click AOP "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/java/com/abhishekvermaa10/aspect/LogAspect.java"
    click Config "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/resources/application.yml"
    click Config "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/resources/messages.properties"
    click Config "https://github.com/abhishekvermaa10/spring-basics-with-spring-boot/blob/master/Petistaan/src/main/resources/banner.txt"

    %% Styles
    classDef code fill:#bbf,stroke:#333,stroke-width:1px
    classDef config fill:#fbf,stroke:#333,stroke-width:1px
    classDef aspect fill:#ffb,stroke:#333,stroke-width:1px
    classDef datastore fill:#bfb,stroke:#333,stroke-width:1px
    classDef external fill:#fff,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
```
