# merikbest/ecommerce-spring-reactjs architecture

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

- Interactive diagram: https://gitdiagram.com/merikbest/ecommerce-spring-reactjs
- Repository: https://github.com/merikbest/ecommerce-spring-reactjs

## Overview

##### Main Components
- Frontend Client: Represent the React application (the “frontend” directory) which includes:
- UI components (pages, layouts, reusable widgets like NavBar, Footer, and various pages for products, cart, account management, etc.)
- State management (Redux Toolkit sections for auth, cart, orders, perfumes, etc.)
- Routing and API calls (using REST and GraphQL queries).
- Backend Server: Show the Spring Boot application (contents inside “src/main/java/com/gmail/merikbest2015/ecommerce”) which handles:
- Controllers: Handle REST endpoints (AuthenticationController, OrderController, PerfumeController, etc.)
- Services: Business logic (AuthenticationServiceImpl, OrderServiceImpl, PerfumeServiceImpl, etc.)
- Data Access: Repositories, JPA entities (domain models such as User, Order, Perfume, Review) and DTO mappers.
- Security: JWT, OAuth2 configuration and filters.
- GraphQL API: GraphQLProvider and related schemas defined under resources.
- Database: PostgreSQL (as specified in README and configuration files) for persistent storage, including DB migration files.
- External Integrations & Services:
- AWS S3: For storing static resources (images, etc.).
- OAuth2 Providers: Google, Facebook, Github integration for user authentication.
- reCAPTCHA: For additional authentication validation during registration.
- Email Service: Configured via Gmail for order, registration, and password-reset emails.
- Swagger API: Documentation endpoint (localhost:8080/swagger-ui.html or on Heroku).
- Build & Configuration Tools:
- Maven (server) for managing the backend build.
- NPM/Yarn/Webpack for building the front-end.

##### Relationships and Data Flow
- Frontend-to-Backend Communication:
- REST API calls and GraphQL queries from React components reach the backend controllers.
- Backend Internal Flow:
- Controllers → Service Layer → Repository/Data Access Layer → PostgreSQL.
- External Service Interactions:
- Email Service (spring email configuration) to the Gmail SMTP server.
- ReCAPTCHA integration as part of the user registration endpoint.

##### Architectural Patterns & Design Principles
- Separation of Concerns:
- Clearly distinguish the UI layer (frontend) from the API/server layer.
- Backend is separated into controllers (API layer), services (business logic), repositories (data access), and security aspects.
- API Design:
- Mention support for both REST and GraphQL which implies modular API endpoints.
- Security and Authentication:
- Use of JWT and OAuth2 along with secure endpoints.
- Microservices vs. Monolithic:

##### Final Touches
- That each major module (e.g., Authentication, Order Management, Product Management) is represented along with its flow.
- How the user journeys (registration, login, order processing) traverse through these layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F1["React Frontend (UI, Redux & Routing)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BC["Spring Boot Controllers"]:::backend
        BS["Service Layer"]:::backend
        DM["Domain Models"]:::backend
        RP["Repositories"]:::backend
        EX["Exception Handling"]:::backend
        MP["Mappers"]:::backend
        Sec["Security & Auth (JWT/OAuth2)"]:::backend
        GQL["GraphQL API"]:::backend
    end

    %% External Integrations
    subgraph "External Integrations"
        AWSS3["AWS S3"]:::external
        OAuth["OAuth2 Providers"]:::external
        Email["Email Service"]:::external
        Recaptcha["reCAPTCHA"]:::external
        Swagger["Swagger API Documentation"]:::external
    end

    %% Database
    subgraph "Database"
        DB["PostgreSQL Database"]:::database
    end

    %% Build & Config Tools
    subgraph "Build & Config Tools"
        Maven["Maven (pom.xml)"]:::build
        NPM["NPM/Yarn (package.json)"]:::build
    end

    %% Connections between layers
    F1 -->|"REST/GraphQLCalls"| BC
    BC -->|"Calls"| BS
    BS -->|"BusinessOps"| DM
    BS -->|"DataAccess"| RP
    DM -->|"Queries"| DB
    BC -->|"ErrorHandledBy"| EX
    EX -->|"Mapping"| MP
    BC -->|"SecuredBy"| Sec
    GQL -->|"Executes"| BS
    BC -->|"Validates"| Recaptcha

    %% External service interactions
    BS -->|"Uploads/Downloads"| AWSS3
    Sec -->|"AuthFlows"| OAuth
    BS -->|"SendsEmails"| Email
    BC -->|"DocsAvail"| Swagger

    %% Build and Config associations
    F1 --- NPM
    BS --- Maven

    %% Click Events for Frontend
    click F1 "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/frontend/src"

    %% Click Events for Backend Components
    click BC "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/java/com/gmail/merikbest2015/ecommerce/controller"
    click BS "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/java/com/gmail/merikbest2015/ecommerce/service/Impl"
    click DM "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/java/com/gmail/merikbest2015/ecommerce/domain"
    click RP "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/java/com/gmail/merikbest2015/ecommerce/repository"
    click EX "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/java/com/gmail/merikbest2015/ecommerce/exception"
    click MP "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/java/com/gmail/merikbest2015/ecommerce/mapper"
    click Sec "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/java/com/gmail/merikbest2015/ecommerce/security"
    click Sec "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/java/com/gmail/merikbest2015/ecommerce/dto/auth"
    click Sec "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/java/com/gmail/merikbest2015/ecommerce/security/oauth2"
    click GQL "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/src/main/java/com/gmail/merikbest2015/ecommerce/service/graphql/GraphQLProvider.java"
    click GQL "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/src/main/resources/graphql/schemas.graphql"

    %% Click Events for External Integrations
    click Email "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/src/main/java/com/gmail/merikbest2015/ecommerce/configuration/EmailConfiguration.java"
    click Email "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/src/main/java/com/gmail/merikbest2015/ecommerce/service/email/MailSender.java"
    click Email "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/resources/mail-templates"
    click Swagger "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/src/main/java/com/gmail/merikbest2015/ecommerce/configuration/SwaggerConfiguration.java"
    click Swagger "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/src/main/resources/static/swagger-api/swagger.yaml"
    click Recaptcha "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/src/main/java/com/gmail/merikbest2015/ecommerce/dto/CaptchaResponse.java"

    %% Click Events for Database
    click DB "https://github.com/merikbest/ecommerce-spring-reactjs/tree/master/src/main/resources/db/migration"
    click DB "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/src/main/resources/application.properties"

    %% Click Events for Build & Config Tools
    click Maven "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/pom.xml"
    click NPM "https://github.com/merikbest/ecommerce-spring-reactjs/blob/master/frontend/package.json"

    %% Styles
    classDef frontend fill:#FDEBD0,stroke:#D35400,stroke-width:2px;
    classDef backend fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#239B56,stroke-width:2px;
    classDef database fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef build fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
