How vecfonds/saigonsky-reactjs-springboot works
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.