# raiyan12999/estore architecture

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

- Interactive diagram: https://gitdiagram.com/raiyan12999/estore
- Repository: https://github.com/raiyan12999/estore

## Overview

##### Project type and purpose
- This is a monolithic Spring Boot “eStore” RESTful backend for managing an online store’s products, categories, suppliers, and detailed relationships. It exposes HTTP endpoints, uses JPA/Hibernate for persistence in MySQL, and applies an AOP-based logging aspect.

##### File structure
- Top-level: Maven project with `pom.xml`.
- `src/main/java/com/webApp/eStore`:
- controller/* – REST controllers (HomeController, LoginController, ProductController, CategoryController, ProductDetailsController)
- service/* – business logic (ProductService, CategoryService, ProductDetailsService)
- repository/* – Spring Data JPA repos (ProductRepo, CategoryRepo, ProductDetailsRepo)
- model/* – JPA entities (Product, Category, Supplier, ProductDetails)
- aspect/LogginAspect.java – AOP logging
- EStoreApplication.java – Spring Boot entry point
- `src/main/resources`: `application.properties`, `data.sql` (schema/data seeding)
- Standard test suite under `src/test/java`.

##### Key insights from README
- Layered architecture: Controllers → Services → Repositories → MySQL
- Uses entity relationships (One-to-Many, Many-to-Many, One-to-One)
- AOP for logging service calls
- Cross-origin enabled, Jackson for JSON, SLF4J for logs

a. Main components:
1) External Clients (Browser, Postman, Mobile App)
3) Spring Boot Application
– Presentation Layer: REST Controllers
– Business Layer: Services
– Persistence Layer: Repositories
– Cross-cutting Concern: Logging Aspect
4) MySQL Database
5) Static Resources (if serving any via Spring MVC) or External Auth Service for `/login`

b. Relationships & interactions:
- Clients send HTTP(S) requests to controllers (e.g., GET /api/products)
- Controllers delegate to corresponding Service methods
- Service methods apply business rules, call Repository interfaces
- Repositories translate method calls to SQL via Hibernate, interact with MySQL
- Data flows back up: MySQL → Repo → Service → Controller → JSON response to client
- AOP Aspect intercepts Service calls for logging both requests and responses

c. Architectural patterns & design principles:
- Layered (Controller-Service-Repository)
- MVC-ish for REST (no UI templates, JSON only)
- Dependency Injection via Spring’s @Autowired/@Service/@Repository
- Aspect-Oriented Programming for logging cross-cutting concerns
- JPA/Hibernate for ORM, with lazy/eager fetching and cascade rules

d. Key technologies/frameworks:
- Spring Boot (Web, Data JPA, AOP)
- Maven build (`pom.xml`)
- MySQL (runtime) + Hibernate
- Jackson (JSON serialization)
- SLF4J (logging)

##### Detail without over-compartmentalizing
- Every layer (presentation, business, persistence)
- Cross-cutting concerns (AOP logging)
- External dependencies (MySQL) and major frameworks (Spring Boot, Hibernate, Jackson)
- Don’t split into microservices unless that’s a future goal—focus on the existing monolith

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    subgraph "External Clients"
        Browser["Browser"]:::external
        Postman["Postman"]:::external
        Mobile["Mobile App"]:::external
    end

    %% Optional Gateway
    APIGateway["API Gateway / Load Balancer"]:::gateway

    %% Spring Boot Application
    subgraph "Spring Boot Application"
        EStoreApp["EStoreApplication"]:::app

        subgraph "Presentation Layer (Controllers)"
            HomeCtrl["HomeController"]:::controller
            LoginCtrl["LoginController"]:::controller
            ProductCtrl["ProductController"]:::controller
            CategoryCtrl["CategoryController"]:::controller
            DetailsCtrl["ProductDetailsController"]:::controller
        end

        subgraph "Business Layer (Services)"
            ProductSvc["ProductService"]:::service
            CategorySvc["CategoryService"]:::service
            DetailsSvc["ProductDetailsService"]:::service
        end

        subgraph "Data Access Layer (Repositories)"
            ProductRepo["ProductRepo"]:::repo
            CategoryRepo["CategoryRepo"]:::repo
            DetailsRepo["ProductDetailsRepo"]:::repo
        end

        subgraph "Persistence Models (Entities)"
            Product["Product"]:::entity
            Category["Category"]:::entity
            Supplier["Supplier"]:::entity
            ProdDetailsEntity["ProductDetails"]:::entity
        end

        subgraph "Cross-Cutting Concern"
            LoggingAspect["LogginAspect"]:::aspect
        end
    end

    %% Database
    MySQL["MySQL Database"]:::db

    %% Data Seeding and Config
    subgraph "Resources"
        applicationProps["application.properties"]:::resource
        dataSQL["data.sql"]:::resource
    end

    %% Interactions
    Browser -->|HTTP/JSON| APIGateway
    Postman -->|HTTP/JSON| APIGateway
    Mobile -->|HTTP/JSON| APIGateway
    APIGateway -->|HTTP/JSON| HomeCtrl
    APIGateway -->|HTTP/JSON| LoginCtrl
    APIGateway -->|HTTP/JSON| ProductCtrl
    APIGateway -->|HTTP/JSON| CategoryCtrl
    APIGateway -->|HTTP/JSON| DetailsCtrl

    HomeCtrl -->|calls| ProductSvc
    LoginCtrl -->|calls| CategorySvc
    ProductCtrl -->|calls| ProductSvc
    CategoryCtrl -->|calls| CategorySvc
    DetailsCtrl -->|calls| DetailsSvc

    ProductSvc -->|uses| ProductRepo
    CategorySvc -->|uses| CategoryRepo
    DetailsSvc -->|uses| DetailsRepo

    ProductRepo -->|ORM| MySQL
    CategoryRepo -->|ORM| MySQL
    DetailsRepo -->|ORM| MySQL

    ProductRepo -->|maps| Product
    CategoryRepo -->|maps| Category
    DetailsRepo -->|maps| ProdDetailsEntity

    Supplier -->|relates| Product
    ProdDetailsEntity -->|one-to-one| Product

    LoggingAspect -.->|intercepts| ProductSvc
    LoggingAspect -.->|intercepts| CategorySvc
    LoggingAspect -.->|intercepts| DetailsSvc

    applicationProps -->|configures| EStoreApp
    dataSQL -->|seeds| MySQL

    %% Click Events
    click EStoreApp "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/EStoreApplication.java"
    click LoggingAspect "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/aspect/LogginAspect.java"
    click HomeCtrl "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/controller/HomeController.java"
    click LoginCtrl "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/controller/LoginController.java"
    click ProductCtrl "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/controller/ProductController.java"
    click CategoryCtrl "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/controller/CategoryController.java"
    click DetailsCtrl "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/controller/ProductDetailsController.java"
    click ProductSvc "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/service/ProductService.java"
    click CategorySvc "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/service/CategoryService.java"
    click DetailsSvc "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/service/ProductDetailsService.java"
    click ProductRepo "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/repository/ProductRepo.java"
    click CategoryRepo "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/repository/CategoryRepo.java"
    click DetailsRepo "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/repository/ProductDetailsRepo.java"
    click Product "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/model/Product.java"
    click Category "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/model/Category.java"
    click Supplier "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/model/Supplier.java"
    click ProdDetailsEntity "https://github.com/raiyan12999/estore/blob/main/src/main/java/com/webApp/eStore/model/ProductDetails.java"
    click applicationProps "https://github.com/raiyan12999/estore/blob/main/src/main/resources/application.properties"
    click dataSQL "https://github.com/raiyan12999/estore/blob/main/src/main/resources/data.sql"

    %% Styles
    classDef external fill:#f9f,stroke:#333
    classDef gateway fill:#d3d3d3,stroke:#333
    classDef app fill:#ddeeff,stroke:#333
    classDef controller fill:#bbdefb,stroke:#333
    classDef service fill:#c8e6c9,stroke:#333
    classDef repo fill:#ffe0b2,stroke:#333
    classDef entity fill:#e1bee7,stroke:#333
    classDef aspect fill:#eeeeee,stroke-dasharray: 5 5,stroke:#666
    classDef db fill:#ffcc80,stroke:#333
    classDef resource fill:#e0e0e0,stroke:#333
```
