# vecfonds/saigonsky-reactjs-springboot architecture

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

- Interactive diagram: https://gitdiagram.com/vecfonds/saigonsky-reactjs-springboot
- Repository: https://github.com/vecfonds/saigonsky-reactjs-springboot

## Overview

##### Main Components
- Front-end: This is the client side, built with React. It contains multiple subdirectories for scenes (such as Login, Signup, Home, ProductDetail, etc.), components (such as a slider, toast notifications, etc.), services (for API calls like auth, product, category), and a global Redux store to manage the application state.
- Back-end: A Spring Boot application structured in a modular way:
– Controllers: Handle the REST API endpoints (e.g., AuthController, ProductController, CategoryController) and serve as the communication gateway between the front-end and back-end.
– Services: Implement business logic (e.g., UserService, ProductService, BillService) with corresponding implementation classes.
– Repositories: Data access layers for persistence using Spring Data JPA (e.g., UserRepository, ProductRepository).
– Entities and DTOs: Represent the data models which are mapped to database tables and exchanged between layers.
– Security: Contains JWT security configuration and filters.
– Exception Handling: A set of custom exceptions and a global exception handler to provide consistent error responses.

##### Interactions and Relationships
- The Front-end communicates with the Back-end via REST APIs. The front-end services make HTTP calls (e.g., auth.service.js, product.service.js) to the endpoints exposed by back-end controllers.
- Within the Back-end:
– Controllers interact with Services to execute business logic.
– Services use Repositories to persist or retrieve data from the database.
– Security components (JWT filters and SecurityConfig) intercept incoming requests to authenticate and authorize access.
– Exception handlers capture errors across the system and return standardized error responses.
- The database acts as a persistent store for entities like Users, Products, Orders (Bills), Categories, etc.

##### Architectural Patterns and Design Principles
- The Back-end uses the typical layered architecture (Controller → Service → Repository) which supports separation of concerns and high maintainability.
- The Front-end follows a component-based architecture leveraging React, with state management handled via Redux (store features).
- Pay attention to cross-cutting concerns shown by security configuration and exception handling.
- The separation of DTO objects for transferring data indicates a clear intent to isolate domain models from payload structures for API communications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Front-end (React)"
        FE1["UI Components/Scenes"]:::FE
        FE2["API Services (HTTP Calls)"]:::FE
        FE3["Redux Store"]:::FE
    end

    subgraph "Back-end (Spring Boot)"
        BE5["Security"]:::BE
        BE1["Controllers"]:::BE
        BE2["Business Services"]:::BE
        BE3["Repositories"]:::BE
        BE4["Entities/DTOs"]:::BE
        BE6["Exception Handling"]:::BE
    end

    DB["Database"]:::DB

    %% Front-end interactions
    FE1 -->|"triggers"| FE2
    FE1 -->|"updates"| FE3

    %% Front-end to Back-end flow
    FE2 -->|"authenticates"| BE5
    BE5 -->|"forwards to"| BE1
    BE1 -->|"delegates"| BE2
    BE2 -->|"queries"| BE3
    BE3 -->|"persists/retrieves"| DB

    %% Exception handling
    BE1 -->|"errors"| BE6
    BE2 -->|"errors"| BE6

    %% Click Events for Front-end Components
    click FE1 "https://github.com/vecfonds/saigonsky-reactjs-springboot/tree/main/front-end/src/scenes/"
    click FE2 "https://github.com/vecfonds/saigonsky-reactjs-springboot/tree/main/front-end/src/services/"
    click FE3 "https://github.com/vecfonds/saigonsky-reactjs-springboot/tree/main/front-end/src/store/"

    %% Click Events for Back-end Components
    click BE1 "https://github.com/vecfonds/saigonsky-reactjs-springboot/tree/main/back-end/src/main/java/com/vecfonds/backend/controller/"
    click BE2 "https://github.com/vecfonds/saigonsky-reactjs-springboot/tree/main/back-end/src/main/java/com/vecfonds/backend/service/"
    click BE3 "https://github.com/vecfonds/saigonsky-reactjs-springboot/tree/main/back-end/src/main/java/com/vecfonds/backend/repository/"
    click BE4 "https://github.com/vecfonds/saigonsky-reactjs-springboot/tree/main/back-end/src/main/java/com/vecfonds/backend/entity/"
    click BE5 "https://github.com/vecfonds/saigonsky-reactjs-springboot/tree/main/back-end/src/main/java/com/vecfonds/backend/security/"
    click BE6 "https://github.com/vecfonds/saigonsky-reactjs-springboot/tree/main/back-end/src/main/java/com/vecfonds/backend/exception/"

    %% Click Event for Database Initialization Script
    click DB "https://github.com/vecfonds/saigonsky-reactjs-springboot/blob/main/back-end/src/main/resources/database.sql"

    %% Styles
    classDef FE fill:#a7d7c5,stroke:#333,stroke-width:2px;
    classDef BE fill:#c4defc,stroke:#333,stroke-width:2px;
    classDef DB fill:#ffcccb,stroke:#333,stroke-width:2px;
```
