# assem-gh/el-shop architecture

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

- Interactive diagram: https://gitdiagram.com/assem-gh/el-shop
- Repository: https://github.com/assem-gh/el-shop

## Overview

##### Project type and purpose
- Frontend: a React+TypeScript single-page app built with Vite, using Redux slices, Axios API calls, and a component hierarchy.
- Backend: a Spring Boot (Java/Maven) REST API with Controllers, Services, Repositories, integration with AWS S3 and Keycloak for auth, packaged and containerized via Docker.

##### File structure
- Top-level directories:
- frontend/ – React app (vite.config, tsconfig, package.json, src/components, src/pages, src/store, etc.)
- backend/ – Spring Boot service (pom.xml, src/main/java/com/elshop/backend/{category,product,common,config,exception}, resources, tests)
- . github/workflows/ – CI pipelines (analyse, deploy)
- Patterns:
- Backend follows MVC: Controller → Service → Repository (Spring Data JPA).
- frontend follows feature-based module organization (components, pages, store slices).
- Infrastructure/deployment:
- backend/Dockerfile, Maven wrapper
- GitHub Actions YAMLs for CI/CD
- sonar-project.properties for code quality

##### README
- README is minimal, so all insights come from directory names and file naming conventions.

##### Essential architectural elements
- Every major folder or module as a discrete component.
- How frontend state management (Redux slices) maps to backend entities (Product, Category).
- Authentication/authorization flow via Keycloak.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "CI/CD Pipeline"
        GHRepo["GitHub Repo"]:::infra
        AnalyseBackend["Backend Analysis Workflow"]:::infra
        AnalyseFrontend["Frontend Analysis Workflow"]:::infra
        Deploy["Deployment Workflow"]:::infra
        GHRepo --> AnalyseBackend
        GHRepo --> AnalyseFrontend
        AnalyseBackend -->|"push image"| DockerReg["Docker Registry"]:::infra
        AnalyseFrontend --> DockerReg
        DockerReg -->|"deploy"| ProdEnv["Production Env"]:::infra
    end

    subgraph "UI Tier (React + Vite)"
        UI_SPA["Frontend SPA"]:::frontend
        CategorySlice["categorySlice.ts"]:::frontend
        ProductSlice["productSlice.ts"]:::frontend
        AxiosClient["axios.ts"]:::frontend
        ProductService["productService.ts"]:::frontend
        ProductListPage["ProductListPage.tsx"]:::frontend
        AddProductPage["AddProductPage.tsx"]:::frontend
        CategoryListPage["CategoryListPage.tsx"]:::frontend
        UsePagination["usePagination.tsx"]:::frontend
        KeycloakJS["keycloack.ts"]:::frontend

        UI_SPA -->|uses| CategorySlice
        UI_SPA -->|uses| ProductSlice
        CategorySlice -->|dispatches| AxiosClient
        ProductSlice -->|dispatches| AxiosClient
        AxiosClient -->|calls| ProductService
        UI_SPA --> ProductListPage
        UI_SPA --> AddProductPage
        UI_SPA --> CategoryListPage
        UI_SPA --> UsePagination
        UI_SPA --> KeycloakJS
    end

    subgraph "API Tier (Spring Boot)"
        BackendApp["BackendApplication.java"]:::backend
        Controllers["Controllers"]:::backend
        Services["Services"]:::backend
        Repos["Repositories"]:::backend
        ExceptionHandler["AppControllerAdvisor.java"]:::backend
        SecurityConfig["SecurityConfig.java"]:::backend
        RoleConverter["KeycloackRoleConverter.java"]:::backend
        AWSConfig["AWSConfig.java"]:::backend
        S3Service["S3Service.java"]:::backend

        BackendApp --> Controllers
        Controllers --> Services
        Services --> Repos
        Controllers --> ExceptionHandler
        Controllers --> SecurityConfig
        SecurityConfig --> RoleConverter
        Services --> S3Service
        S3Service --> AWSConfig
    end

    subgraph "Backend Modules"
        CatController["CategoryController.java"]:::backend
        CatService["CategoryService.java"]:::backend
        CatRepo["CategoryRepository.java"]:::backend
        CatModel["Category.java & CategoryRequest.java"]:::backend

        ProdController["ProductController.java"]:::backend
        ProdService["ProductService.java"]:::backend
        ProdRepo["ProductRepository.java"]:::backend
        ProdModel["Product.java & DTOs"]:::backend

        Controllers --> CatController
        Controllers --> ProdController
        Services --> CatService
        Services --> ProdService
        Repos --> CatRepo
        Repos --> ProdRepo
        CatService --> CatRepo
        ProdService --> ProdRepo
        CatService --> CatModel
        ProdService --> ProdModel
    end

    Database["Relational Database"]:::infra
    S3Bucket["AWS S3 Bucket"]:::external
    Keycloak["Keycloak Auth Server"]:::external

    UI_SPA -->|REST/HTTPS| BackendApp
    BackendApp -->|JPA/SQL| Database
    BackendApp -->|AWS SDK| S3Bucket
    BackendApp -->|OAuth2/OpenID| Keycloak
    UI_SPA -->|Auth| Keycloak

    subgraph "Dockerization"
        Dockerfile["Dockerfile"]:::infra
        MavenWrapper["mvnw & .mvn"]:::infra
        Dockerfile --> MavenWrapper
    end

    Dockerfile --> AnalyseBackend

    %% Click Events
    click UI_SPA "https://github.com/assem-gh/el-shop/tree/main/frontend/"
    click CategorySlice "https://github.com/assem-gh/el-shop/blob/main/frontend/src/store/slices/categorySlice.ts"
    click ProductSlice "https://github.com/assem-gh/el-shop/blob/main/frontend/src/store/slices/productSlice.ts"
    click AxiosClient "https://github.com/assem-gh/el-shop/blob/main/frontend/src/store/api/axios.ts"
    click ProductService "https://github.com/assem-gh/el-shop/blob/main/frontend/src/store/api/productService.ts"
    click ProductListPage "https://github.com/assem-gh/el-shop/blob/main/frontend/src/pages/dashboard/Product/ProductListPage.tsx"
    click AddProductPage "https://github.com/assem-gh/el-shop/blob/main/frontend/src/pages/dashboard/Product/AddProductPage.tsx"
    click CategoryListPage "https://github.com/assem-gh/el-shop/blob/main/frontend/src/pages/dashboard/Category/CategoryListPage.tsx"
    click UsePagination "https://github.com/assem-gh/el-shop/blob/main/frontend/src/hooks/usePagination.tsx"
    click KeycloakJS "https://github.com/assem-gh/el-shop/blob/main/frontend/src/utils/keycloack.ts"
    click BackendApp "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/BackendApplication.java"
    click CatController "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/category/CategoryController.java"
    click CatService "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/category/CategoryService.java"
    click CatRepo "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/category/CategoryRepository.java"
    click CatModel "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/category/model/Category.java"
    click ProdController "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/product/ProductController.java"
    click ProdService "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/product/ProductService.java"
    click ProdRepo "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/product/ProductRepository.java"
    click ProdModel "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/product/model/Product.java"
    click S3Service "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/common/S3Service.java"
    click AWSConfig "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/config/AWSConfig.java"
    click SecurityConfig "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/config/SecurityConfig.java"
    click RoleConverter "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/config/KeycloackRoleConverter.java"
    click ExceptionHandler "https://github.com/assem-gh/el-shop/blob/main/backend/src/main/java/com/elshop/backend/exception/AppControllerAdvisor.java"
    click Dockerfile "https://github.com/assem-gh/el-shop/tree/main/backend/Dockerfile"
    click MavenWrapper "https://github.com/assem-gh/el-shop/tree/main/backend/mvnw"
    click AnalyseBackend "https://github.com/assem-gh/el-shop/blob/main/.github/workflows/backend-analyse.yml"
    click AnalyseFrontend "https://github.com/assem-gh/el-shop/blob/main/.github/workflows/frontend-analyse.yml"
    click Deploy "https://github.com/assem-gh/el-shop/blob/main/.github/workflows/deploy.yml"

    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef backend fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef infra fill:#EEEEEE,stroke:#333,stroke-width:1px
```
