How sarosh13/spring-boot-react-crud-application works
Main Components
• Frontend: The React application located in the "react" directory. It includes UI components like AddItem, EditItem, DeleteItem, ViewItem, Navbar, etc.
• Backend: The Spring Boot application in the "backend" directory. This includes the core CRUD functionality as reflected in packages for controllers, services, DAOs, and data models.
• API Layer: The Spring Boot REST controllers (e.g., CrudController.java) provide endpoints that are consumed by the React frontend.
Interactions and Relationships
• The React frontend communicates with the backend via HTTP REST API calls.
• The backend’s controller layer (CrudController) receives requests and then calls the service layer (CrudService, CrudServiceImpl) to execute business logic.
• The service layer interacts with the DAO layer (CrudDaoImpl) to perform CRUD operations on the Product model.
• If applicable, the DAO communicates with an external or embedded database.
Architectural Patterns and Design Principles
• MVC/Multi-layered Structure: The Spring Boot application follows an organized layered architecture with distinct roles (controller, service, DAO, and model).
• Separation of Concerns: React handles the view and user interaction; Spring Boot handles business logic and data persistence.
• Clear Contract via REST API: The frontend and backend interaction is clearly defined by REST endpoints.
Components and Elements
a. Frontend Component:
• Inside, list essential UI components (AddItem, EditItem, ListItems, DeleteItem, ViewItem, Navbar).
• Client-side routing and state management if relevant.
b. Backend Component:
• Subdivide the backend into layers:
• Controller Layer: Represent the CrudController.
• Service Layer: Represent CrudService and its implementation.
• DAO Layer: Represent CrudDaoImpl.
• Model Layer: Represent the Product model.
• Configuration: Reference application.properties as the configuration hub.
c. Database Component:
• A “Database” element (or “Data Store”) that the DAO interacts with.