# averma577/shopping_cart architecture

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

- Interactive diagram: https://gitdiagram.com/averma577/shopping_cart
- Repository: https://github.com/averma577/shopping_cart

## Overview

##### Project type and purpose
- This is a full-stack e-commerce web application (“ShopiCart”) built with Spring Boot on the backend and server-rendered HTML/CSS/JS (Thymeleaf templates) on the frontend.
- It provides product browsing, cart management, user registration/login, order placement, and an admin panel for CRUD operations on products and categories.

##### File structure
- Top-level artifacts
– Dockerfile, pom.xml (Maven build), mvnw scripts.
– src/main/java/com/ecom: package hierarchy.
– src/main/resources: static assets (CSS, JS, images) and Thymeleaf templates.
- Layered package structure
– configure: Spring Security setup, authentication handlers, custom user details.
– controller: MVC controllers (HomeController, UserController, AdminController).
– entity: JPA entities (UserDtls, Product, Category).
– repository: Spring Data JPA interfaces.
– service + serviceImpl: business logic interfaces and implementations.
– util: constants and common utilities.
- Resources
– application.properties for datasource and security.
– static files served under /static.
– templates under /templates (user/admin views).
- Deployment
– Dockerfile suggests containerization.
– Maven wrapper indicates reproducible builds.

##### README for additional insights
- Tech stack mentions Spring Boot, Hibernate/JDBC, MySQL/H2.
- Features: user auth, product listing, add-to-cart, order placement, admin panel.
- Architecture hints: MVC pattern and layered service/repository.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"   
        direction TB
        Browser["Web Browser"]:::frontend
        StaticAssets["Static Assets\n(CSS/JS/Images)"]:::frontend
        Templates["Thymeleaf Templates"]:::frontend
    end

    %% Security Layer
    SecurityFilter["Spring Security Filter Chain"]:::infra

    %% Web Layer
    subgraph "Web Layer"
        direction TB
        HomeController["HomeController"]:::backend
        UserController["UserController"]:::backend
        AdminController["AdminController"]:::backend
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        CategoryService["CategoryService"]:::backend
        ProductService["ProductService"]:::backend
        UserService["UserService"]:::backend
        CommonService["CommonService"]:::backend
        CategoryServiceImpl["CategoryServiceImpl"]:::backend
        ProductServiceImpl["ProductServiceImpl"]:::backend
        UserServiceImpl["UserServiceImpl"]:::backend
        CommonServiceImpl["CommonServiceImpl"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        CategoryRepo["CategoryRepository"]:::data
        ProductRepo["ProductRepository"]:::data
        UserDetailsRepo["UserDetailsRepository"]:::data
    end

    %% Domain Entities
    subgraph "Domain Model"
        direction TB
        CategoryEntity["Category Entity"]:::data
        ProductEntity["Product Entity"]:::data
        UserDtlsEntity["UserDtls Entity"]:::data
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        Database["MySQL/H2 Database"]:::db
        FileStorage["File Storage"]:::infra
        EmailService["Email/SMS Service"]:::infra
        Docker["Docker Container"]:::infra
    end

    %% Application Entry
    AppEntry["ShoppingCartApplication"]:::backend

    %% Exception Handling
    Exception["ProductNotFoundException"]:::infra

    %% Utilities and Configuration
    AppConst["AppConstant"]:::infra
    CommonUtil["CommonUtil"]:::infra
    SecurityConfig["SecurityConfig"]:::infra
    UserDetailServiceImpl["UserDetailServiceImpl"]:::infra
    AuthSuccessHandler["AuthSuccessHandlerImpl"]:::infra
    AuthFailureHandler["AuthFailureHandler"]:::infra
    CustomUser["CustomUser"]:::infra
    ProductNotFoundExc["ProductNotFoundException"]:::infra
    ApplicationProps["application.properties"]:::infra
    DockerfileNode["Dockerfile"]:::infra

    %% Connections
    Browser -->|requests| StaticAssets
    Browser -->|requests| SecurityFilter
    StaticAssets -->|served by| Browser
    SecurityFilter -->|forwards to| HomeController
    SecurityFilter -->|forwards to| UserController
    SecurityFilter -->|forwards to| AdminController
    HomeController -->|calls| CategoryService
    HomeController -->|calls| ProductService
    HomeController -->|renders| Templates
    UserController -->|calls| UserService
    AdminController -->|calls| CommonService
    AdminController -->|calls| CategoryService
    AdminController -->|calls| ProductService
    CategoryService -->|implemented by| CategoryServiceImpl
    ProductService -->|implemented by| ProductServiceImpl
    UserService -->|implemented by| UserServiceImpl
    CommonService -->|implemented by| CommonServiceImpl
    CategoryServiceImpl -->|uses| CategoryRepo
    ProductServiceImpl -->|uses| ProductRepo
    UserServiceImpl -->|uses| UserDetailsRepo
    CategoryRepo -->|manages| CategoryEntity
    ProductRepo -->|manages| ProductEntity
    UserDetailsRepo -->|manages| UserDtlsEntity
    CategoryRepo -->|connects to| Database
    ProductRepo -->|connects to| Database
    UserDetailsRepo -->|connects to| Database
    AppEntry -->|bootstraps| HomeController
    AppEntry -->|bootstraps| SecurityConfig
    AppEntry -->|bootstraps| AppConst
    AppEntry -->|bootstraps| CommonUtil
    AppEntry -->|bootstraps| UserDetailServiceImpl
    AppEntry -->|bootstraps| AuthSuccessHandler
    AppEntry -->|bootstraps| AuthFailureHandler
    AppEntry -->|bootstraps| CustomUser
    AppEntry -->|runs in| Docker
    Docker -->|links to| Database
    AppEntry -->|reads| ApplicationProps
    AppEntry -->|package built by| DockerfileNode
    ProductServiceImpl -->|throws| Exception
    Exception -->|renders| Templates

    Browser -.->|emails| EmailService
    AppEntry -->|stores images in| FileStorage

    %% Click Events
    click AppEntry "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/ShoppingCartApplication.java"
    click HomeController "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/controller/HomeController.java"
    click UserController "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/controller/UserController.java"
    click AdminController "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/controller/AdminController.java"
    click CategoryService "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/service/CategoryService.java"
    click ProductService "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/service/ProductService.java"
    click UserService "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/service/UserService.java"
    click CommonService "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/service/CommonService.java"
    click CategoryServiceImpl "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/serviceImpl/CategoryServiceImpl.java"
    click ProductServiceImpl "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/serviceImpl/ProductServiceImpl.java"
    click UserServiceImpl "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/serviceImpl/UserServiceImpl.java"
    click CommonServiceImpl "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/serviceImpl/CommonServiceImpl.java"
    click CategoryRepo "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/repository/CategoryRepository.java"
    click ProductRepo "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/repository/ProductRepository.java"
    click UserDetailsRepo "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/repository/UserDetailsRepository.java"
    click SecurityConfig "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/configure/SecurityConfig.java"
    click UserDetailServiceImpl "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/configure/UserDetailServiceImpl.java"
    click AuthSuccessHandler "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/configure/AuthSuccessHandlerImpl.java"
    click AuthFailureHandler "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/configure/AuthFailureHandler.java"
    click CustomUser "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/configure/CustomUser.java"
    click ProductNotFoundExc "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/configure/ProductNotFoundException.java"
    click AppConst "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/util/AppConstant.java"
    click CommonUtil "https://github.com/averma577/shopping_cart/blob/master/src/main/java/com/ecom/util/CommonUtil.java"
    click ApplicationProps "https://github.com/averma577/shopping_cart/blob/master/src/main/resources/application.properties"
    click DockerfileNode "https://github.com/averma577/shopping_cart/tree/master/Dockerfile"
    click StaticAssets "https://github.com/averma577/shopping_cart/tree/master/src/main/resources/static"
    click Templates "https://github.com/averma577/shopping_cart/tree/master/src/main/resources/templates"

    %% Styles
    classDef frontend fill:#E1F5FE,stroke:#0288D1,color:#01579B;
    classDef backend fill:#E8F5E9,stroke:#43A047,color:#1B5E20;
    classDef data fill:#FFF3E0,stroke:#FB8C00,color:#E65100;
    classDef db fill:#EFEBE9,stroke:#6D4C41,color:#3E2723;
    classDef infra fill:#ECEFF1,stroke:#78909C,color:#37474F;
```
