# janakiramch/ecommerce_webapp_java_springboot architecture

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

- Interactive diagram: https://gitdiagram.com/janakiramch/ecommerce_webapp_java_springboot
- Repository: https://github.com/janakiramch/ecommerce_webapp_java_springboot

## Overview

##### Project Type and Purpose
- This is a full-stack Ecommerce application built with a SpringBoot backend and an Angular frontend (as mentioned in the README).
- It uses MySQL for data persistence, JWT for authentication, and Amazon S3 for image storage. Routes are further secured using role-based authentication.

##### Key Components
a. Frontend:
– Although the file tree doesn’t explicitly show Angular files, include a “Frontend (Angular)” component, which is responsible for user interaction and consuming the RESTful APIs from the backend.

b. Backend (SpringBoot):
– The SpringBoot application is clearly structured, with packages for controllers, DTOs, entities, repositories, services, and security.
– Note that the ‘service’ layer (with both interfaces and implementations) encapsulates the business logic.
– The data persistence layer is represented by the repositories and the entities reflecting domain models such as User, Product, Order, etc.

c. Database:

d. External Services:
– Amazon S3 is used for storing image data.
– JWT Authentication mechanism and role-based security need to be clearly indicated.

e. Security:
– Include components for JWT authentication (JwtAuthFilter, JwtUtils), custom user details service, and the security configuration (SecurityConfig).
– Demonstrate that every API route is secured, and indicate dependency between the AuthController and the security modules.

##### Relationships and Interactions
– From the Angular frontend to the SpringBoot controllers (indicate REST API communications).
– From controllers to the service layer where business logic is processed.
– From service layer to repository and then to the MySQL database.
– Also, show how file/image upload requests are handled by the AwsS3Service.
– Indicate the authentication flow: the frontend sends credentials to the AuthController which then interacts with JwtUtils/CustomUserDetailsService, leading to secured interactions.

##### Architectural Patterns and Design Principles
- The system follows an MVC pattern where controllers manage HTTP requests, the service layer encapsulates business logic, and the repository layer handles persistence.
- The use of DTOs and mappers (EntityDtoMapper) shows a commitment to separating internal representations from external API contracts.
- Role-based and JWT-based security is clearly integrated, and the GlobalExceptionHandler ensures a centralized approach to error handling.

##### Additional Detail
– Include the existence of the Exception Handling mechanism (GlobalExceptionHandler) which is critical for capturing and managing errors system-wide.
– Mention that security is tightly integrated (AuthController, SecurityConfig, JwtAuthFilter) and ensure its interactions with the frontend authentication flow are clearly drawn.
– Display how DTOs (data transfer objects) and mappers help in converting entity objects to client-responsive formats.

- The separation between the Angular frontend and SpringBoot backend.
- The layered architecture in the SpringBoot application (controllers, services, repositories, security, external interfaces).
- The interactions with external components like MySQL and Amazon S3.
- The implementation of routing security via JWT authentication and role-based access control.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F["Frontend (Angular)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BA["Backend Application"]:::backend
        subgraph "Controllers Layer"
            C["Controllers"]:::controller
        end
        subgraph "Services Layer"
            SI["Service Interfaces"]:::service
            SImpl["Service Implementations"]:::service
            Aws["AwsS3Service"]:::service
        end
        subgraph "Repositories Layer"
            R["Repositories"]:::repository
        end
        subgraph "Security Layer"
            SM["Security Modules"]:::security
        end
        subgraph "DTOs & Entities Layer"
            DTO["DTOs"]:::dto
            E["Entities"]:::dto
            EDM["EntityDtoMapper"]:::mapper
        end
        subgraph "Exception Handling Layer"
            GEH["GlobalExceptionHandler"]:::exception
        end
    end

    %% External Systems
    DB["MySQL Database"]:::external
    S3["Amazon S3"]:::external

    %% Connections from Frontend to Backend
    F -->|"HTTPRequests"| C
    BA --> C

    %% Controllers and Security Flow
    C -->|"Authentication"| SM
    C -->|"ErrorHandling"| GEH

    %% Controllers to Service Layer
    C -->|"BusinessLogic"| SImpl

    %% Service Interfaces to Implementations
    SI -->|"implements"| SImpl

    %% Service Layer to Repositories and External Storage
    SImpl -->|"DBOperations"| R
    R -->|"Persistence"| DB
    SImpl -->|"ImageUpload"| Aws
    Aws -->|"StoresImage"| S3

    %% Service Layer to DTO & Entity Mapping
    SImpl -->|"EntityMapping"| EDM
    EDM -->|"MapsToDTO"| DTO
    EDM -->|"MapsToEntity"| E

    %% Class Definitions (Styles)
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef backend fill:#F7E6AD,stroke:#333,stroke-width:2px;
    classDef controller fill:#C7F7AD,stroke:#333,stroke-width:2px;
    classDef service fill:#F7A1A1,stroke:#333,stroke-width:2px;
    classDef repository fill:#A1F7B0,stroke:#333,stroke-width:2px;
    classDef external fill:#F7D6AD,stroke:#333,stroke-width:2px;
    classDef security fill:#F7ADAD,stroke:#333,stroke-width:2px;
    classDef dto fill:#ADF7E6,stroke:#333,stroke-width:2px;
    classDef exception fill:#F7ADDA,stroke:#333,stroke-width:2px;
    classDef mapper fill:#D6ADFF,stroke:#333,stroke-width:2px;

    %% Click Events for Components
    click BA "https://github.com/janakiramch/ecommerce_webapp_java_springboot/blob/master/src/main/java/com/dev/Ecommerce/EcommerceApplication.java"
    click C "https://github.com/janakiramch/ecommerce_webapp_java_springboot/tree/master/src/main/java/com/dev/Ecommerce/controller"
    click DTO "https://github.com/janakiramch/ecommerce_webapp_java_springboot/tree/master/src/main/java/com/dev/Ecommerce/dto"
    click E "https://github.com/janakiramch/ecommerce_webapp_java_springboot/tree/master/src/main/java/com/dev/Ecommerce/entity"
    click R "https://github.com/janakiramch/ecommerce_webapp_java_springboot/tree/master/src/main/java/com/dev/Ecommerce/repository"
    click SI "https://github.com/janakiramch/ecommerce_webapp_java_springboot/tree/master/src/main/java/com/dev/Ecommerce/service/interf"
    click SImpl "https://github.com/janakiramch/ecommerce_webapp_java_springboot/tree/master/src/main/java/com/dev/Ecommerce/service/impl"
    click Aws "https://github.com/janakiramch/ecommerce_webapp_java_springboot/blob/master/src/main/java/com/dev/Ecommerce/service/AwsS3Service.java"
    click SM "https://github.com/janakiramch/ecommerce_webapp_java_springboot/tree/master/src/main/java/com/dev/Ecommerce/security"
    click GEH "https://github.com/janakiramch/ecommerce_webapp_java_springboot/tree/master/src/main/java/com/dev/Ecommerce/exception"
    click EDM "https://github.com/janakiramch/ecommerce_webapp_java_springboot/blob/master/src/main/java/com/dev/Ecommerce/mapper/EntityDtoMapper.java"
```
