How gattiharishkumar/springboot-reactjs-ecommerce works
Project Type and Purpose
• This is a full‑stack e‑commerce application:
• Java Spring Boot backend exposing RESTful APIs
• React.js frontend (Vite) consuming those APIs for product browsing, cart management, and checkout
Main Components
a. Frontend (React.js/Vite)
• src/components/* (Home, Product, Cart, CheckoutPopup, Add/UpdateProduct, Navbar)
• src/Context/Context.jsx for global state (cart, user session)
• axios.jsx for API calls
• Vite dev server / bundler (vite.config.js)
b. Backend (Spring Boot)
• Controller layer (ProductController) exposing endpoints
• Service layer (ProductService) holding business logic
• Repository layer (ProductRepo) interacting with the database using Spring Data JPA
• Model (Product) mapping to a relational table
• application.properties / data1.sql for DB config & seed data
• Maven wrapper (mvnw, pom.xml) for build & dependency management
c. Database
• Relational DB (MySQL/PostgreSQL) holding tables for products, users, orders
d. External/Internal Services
• Browser clients
• Possible Authentication service (if extended)
• CI/CD pipeline (implied by Maven, tests)
Relationships & Data Flows
1. User’s Browser → React App (served by Vite or static hosting)
2. React components dispatch actions through Context → invoke Axios calls
3. Axios (HTTP) → Spring Boot REST endpoints (/api/products, /api/cart, etc.)
4. Controller → Service → Repository → Database
5. Repository returns entities → Service applies business rules → Controller returns JSON
6. React updates UI based on API responses
Architectural Patterns & Principles
• MVC / Layered Architecture in backend (Controller‑Service‑Repository)
• RESTful API design (CRUD endpoints for Product)
• Client‑side state management (React Context as a simplified Flux)
• Dependency Injection (Spring Boot)
• Modular UI components (React)
• Build automation (Maven & Vite)
• Unit testing (JUnit in src/test)