# vishwadeep17/pet-mart architecture

> Architecture diagram of the GitHub repository vishwadeep17/pet-mart, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vishwadeep17/pet-mart
- Repository: https://github.com/vishwadeep17/pet-mart

## Overview

##### Project Type & Purpose
- This is a full-stack web application built with Spring Boot.
- Its purpose is to allow guest, registered, and admin users to browse, select, and purchase pets. Admin users can also perform CRUD operations on pet records.
- The README highlights features for user sessions (login/signup), pet browsing, wishlist management, and order confirmation with token generation.

##### Analyzing the File Structure
- The project uses a standard Maven layout with a clear division of responsibilities:
– src/main/java contains the Java source files.
– Multiple subpackage layers, e.g., “config”, “controller”, “dao”, “entity”, “model”, “service”, hint at an MVC (Model-View-Controller) and layered architecture.
- The “config” package holds configuration and security setup (WebConfiguration.java and WebSecurityConfig.java), indicating custom web and security settings.
- The “controller” package contains AdminController and MainController that manage incoming HTTP requests.
- The “dao” package includes data access objects for handling interactions with the persistence layer.
- The “entity” package defines domain objects like Product, Customer, Order, etc.
- The “service” package implements business logic (e.g., CartService, CustomerService).
- Resources are used for application configuration (application.properties), static assets (CSS), and Thymeleaf templates (HTML views).
- The presence of test files ensures that a testing layer is also part of the CI/CD process.

a. Main Components:
- Web Client / Browser – renders Thymeleaf-generated HTML pages.
- Spring Boot Web Application – this hosts the application and contains:
- Controllers (AdminController, MainController)
- Services (CartService, CustomerService, ProductService, etc.)
- Data Access Objects (AccountDAO, OrderDAO, ProductDAO)
- Domain Entities (Account, Customer, Product, Order, etc.)
- Security & Configuration components (WebConfiguration, WebSecurityConfig)
- Database – although not detailed in the file tree, the use of Hibernate implies integration with a relational database system to persist entities.
- External Dependencies – components like Maven for build management and Spring Boot for dependency injection and app management.

b. Relationships & Interactions:
- A user’s browser sends HTTP requests to the Spring Boot controllers.
- Controllers interact with the service layer to process business logic.
- Service layer communicates with DAOs to retrieve or persist data in the database.
- View templates (Thymeleaf) render responses based on model data.
- Security configuration manages authentication and authorization, routing requests appropriately (guest paths vs. admin paths).

c. Architectural Patterns:
- MVC Pattern: Controllers, Services, and Views (Thymeleaf).
- Layered Architecture: presentation layer (controllers/views), business logic (services), and data access (DAOs).
- Security Pattern: Spring Security configuration to differentiate between user types.

d. Technologies:
- Frameworks & Libraries: Spring Boot, Hibernate, Thymeleaf, Spring Security.
- Build Tool: Maven.
- Config Management: application.properties.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        WCB["Web Client (Thymeleaf Views)"]:::frontend
        CSS["CSS (Static Assets)"]:::static
        APP_CONF["App Config (application.properties)"]:::config
    end

    %% Backend Layer
    subgraph "Backend Layer - Spring Boot Application"
        ENTRY["OnlinePetStoreApplication.java"]:::entry
        click ENTRY "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/OnlinePetStoreApplication.java"

        subgraph "Controllers"
            AdminC["AdminController"]:::controller
            click AdminC "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/controller/AdminController.java"
            MainC["MainController"]:::controller
            click MainC "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/controller/MainController.java"
        end

        subgraph "Services"
            CartS["CartService"]:::service
            click CartS "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/service/CartService.java"
            CustS["CustomerService"]:::service
            click CustS "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/service/CustomerService.java"
            ProdS["ProductService"]:::service
            click ProdS "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/service/ProductService.java"
            UserDetailsS["UserDetailsServiceImpl"]:::service
            click UserDetailsS "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/service/UserDetailsServiceImpl.java"
            ListResultS["ListResultService"]:::service
            click ListResultS "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/service/ListResultService.java"
        end

        subgraph "Data Access (DAO)"
            AccDAO["AccountDAO"]:::dao
            click AccDAO "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/dao/AccountDAO.java"
            OrdDAO["OrderDAO"]:::dao
            click OrdDAO "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/dao/OrderDAO.java"
            ProdDAO["ProductDAO"]:::dao
            click ProdDAO "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/dao/ProductDAO.java"
        end

        subgraph "Domain Entities"
            Entities["Entities: Account, Customer, Order, OrderDetail, Product, ProductForm"]:::entity
            click Entities "https://github.com/vishwadeep17/pet-mart/tree/master/src/main/java/com/example/demo/entity/"
        end

        subgraph "Configuration & Security"
            WebConf["WebConfiguration"]:::configSec
            click WebConf "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/config/WebConfiguration.java"
            WebSec["WebSecurityConfig"]:::configSec
            click WebSec "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/java/com/example/demo/config/WebSecurityConfig.java"
        end
    end

    Database[(Database)]:::database

    %% Interactions
    WCB -->|"SendsHTTPReq"| AdminC
    WCB -->|"SendsHTTPReq"| MainC

    WebSec -->|"Secures"| AdminC
    WebSec -->|"Secures"| MainC

    AdminC -->|"CallsBL"| CartS
    AdminC -->|"CallsBL"| CustS
    MainC -->|"CallsBL"| ProdS
    MainC -->|"CallsBL"| UserDetailsS
    MainC -->|"CallsBL"| ListResultS

    CartS -->|"UsesDAO"| AccDAO
    CustS -->|"UsesDAO"| OrdDAO
    ProdS -->|"UsesDAO"| ProdDAO
    UserDetailsS -->|"UsesDAO"| AccDAO
    ListResultS -->|"UsesDAO"| ProdDAO

    AccDAO -->|"AccessDB"| Database
    OrdDAO -->|"AccessDB"| Database
    ProdDAO -->|"AccessDB"| Database

    %% Click Events for Frontend Layer
    click WCB "https://github.com/vishwadeep17/pet-mart/tree/master/src/main/resources/templates"
    click CSS "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/resources/static/style.css"
    click APP_CONF "https://github.com/vishwadeep17/pet-mart/blob/master/src/main/resources/application.properties"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef static fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
    classDef config fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
    classDef entry fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
    classDef controller fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef service fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef dao fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef entity fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef configSec fill:#f5c6cb,stroke:#721c24,stroke-width:2px;
    classDef database fill:#c3e6cb,stroke:#155724,stroke-width:2px;
```
