How sirajuddin135/e-commerce-application works
Purpose and Runtime
This is a Java 17+/Spring Boot 3 REST backend for e-commerce administration and customer shopping flows. It persists marketplace data in MySQL through Spring Data JPA, secures APIs with JWT/Auth0, and exposes Swagger UI documentation. Maven is the build/runtime launcher.
• ECommerceApplication/src/main/java/com/app/ECommerceApplication.java
• ECommerceApplication/pom.xml
• ECommerceApplication/src/main/resources/application.properties
Application Entry and HTTP Boundary
Spring Boot starts component scanning from the application class. REST controllers are the public API boundary, covering authentication, users/addresses, catalog, carts, and orders. Controllers should delegate business behavior rather than expose entities directly.
• ECommerceApplication/src/main/java/com/app/controllers/AuthController.java
• ECommerceApplication/src/main/java/com/app/controllers/ProductController.java
• ECommerceApplication/src/main/java/com/app/controllers/OrderController.java
Security and Identity Flow
Login/authentication is handled through the auth controller and JWT components. SecurityConfig establishes Spring Security policy; JWTFilter processes request tokens; JWTUtil supports token handling. Auth0 is the stated external identity/JWT provider. User details are integrated through a Spring Security service.
• ECommerceApplication/src/main/java/com/app/config/SecurityConfig.java
• ECommerceApplication/src/main/java/com/app/security/JWTFilter.java
• ECommerceApplication/src/main/java/com/app/services/UserDetailsServiceImpl.java
Domain and Persistence Model
JPA entities model users/roles, catalog, customer addresses, cart state, and order/payment records. Repository interfaces are the persistence boundary to MySQL. The principal commerce relationship chain is category → product → cart/cart item → order/order item, associated with users and addresses.
• ECommerceApplication/src/main/java/com/app/entites/User.java
• ECommerceApplication/src/main/java/com/app/entites/Product.java
• ECommerceApplication/src/main/java/com/app/entites/Order.java
• ECommerceApplication/src/main/java/com/app/repositories/OrderRepo.java
Service Layer and Commerce Flows
Service interfaces and implementations contain application operations between controllers and repositories. Catalog operations manage categories/products and pricing/discount behavior; cart operations add, remove, and change product quantities; order operations convert customer/cart selections into order, order-item, and payment-oriented records. Address and user services manage account-associated customer data.
• ECommerceApplication/src/main/java/com/app/services/ProductServiceImpl.java
• ECommerceApplication/src/main/java/com/app/services/CartServiceImpl.java
• ECommerceApplication/src/main/java/com/app/services/OrderServiceImpl.java
API Data Contracts and Error Boundary
DTO payloads separate HTTP request/response contracts from JPA entities, including paginated/list response wrappers and JWT login responses. A global exception handler centralizes conversion of domain/resource failures into API errors.
• ECommerceApplication/src/main/java/com/app/payloads/ProductDTO.java
• ECommerceApplication/src/main/java/com/app/payloads/OrderResponse.java
• ECommerceApplication/src/main/java/com/app/exceptions/MyGlobalExceptionHandler.java
Supporting Integrations
Swagger configuration publishes interactive API documentation at the configured local Swagger UI endpoint. File service abstractions suggest product/content file handling, with content configuration providing its boundary. MySQL connection and application settings are externally configured through properties.
• ECommerceApplication/src/main/java/com/app/config/SwaggerConfig.java
• ECommerceApplication/src/main/java/com/app/services/FileServiceImpl.java
• ECommerceApplication/src/main/java/com/app/config/ContentConfig.java
Main entry points: AuthController.java REST controllers · OrderRepo.java Repository layer · ECommerceApplication.java Spring Boot application · JWTFilter.java JWT filter
Components 18
Runtime & API
- Maven · Builds and launches the Spring Boot service.
ECommerceApplication/pom.xml - Spring Boot application · Starts component scanning and the REST runtime.
ECommerceApplication/src/main/java/com/app/ECommerceApplication.java - REST controllers · Authentication, catalog, and order endpoints.
ECommerceApplication/src/main/java/com/app/controllers/AuthController.java - DTO contracts · Separates HTTP payloads from persistence entities.
ECommerceApplication/src/main/java/com/app/payloads/ProductDTO.java - Global error handler · Maps application failures to API errors.
ECommerceApplication/src/main/java/com/app/exceptions/MyGlobalExceptionHandler.java - Swagger UI
ECommerceApplication/src/main/java/com/app/config/SwaggerConfig.java
Security
- Security policy
ECommerceApplication/src/main/java/com/app/config/SecurityConfig.java - JWT filter · Processes tokens on secured requests.
ECommerceApplication/src/main/java/com/app/security/JWTFilter.java - User details service
ECommerceApplication/src/main/java/com/app/services/UserDetailsServiceImpl.java - Auth0 · External JWT and identity provider.
Commerce application
- Catalog service · Manages categories, products, pricing, and discounts.
ECommerceApplication/src/main/java/com/app/services/ProductServiceImpl.java - Cart service · Maintains cart items and quantities.
ECommerceApplication/src/main/java/com/app/services/CartServiceImpl.java - Order service · Converts cart selections into order, item, and payment records.
ECommerceApplication/src/main/java/com/app/services/OrderServiceImpl.java
Data & integrations
- Commerce entities · Users, addresses, catalog, carts, orders, and payments.
ECommerceApplication/src/main/java/com/app/entites/Order.java - Repository layer · Persistence boundary for commerce aggregates.
ECommerceApplication/src/main/java/com/app/repositories/OrderRepo.java - MySQL
- File service · Handles product or content file operations.
ECommerceApplication/src/main/java/com/app/services/FileServiceImpl.java - Application properties · Supplies database and application settings.
ECommerceApplication/src/main/resources/application.properties
Connections 20
- Maven → Spring Boot application: launches
- Spring Boot application → REST controllers: registers
- Spring Boot application → Security policy: applies
- Spring Boot application → Application properties: loads
- REST controllers → DTO contracts: uses
- REST controllers → Catalog service: catalog requests
- REST controllers → Cart service: cart requests
- REST controllers → Order service: order requests
- REST controllers → Global error handler: failures handled by
- Security policy → JWT filter: installs
- JWT filter → User details service: loads user
- JWT filter → Auth0: validates JWTs from
- Catalog service → Repository layer: persists through
- Cart service → Repository layer: persists through
- Order service → Repository layer: persists through
- Catalog service → File service: manages content via
- Repository layer → Commerce entities: maps
- Repository layer → MySQL: reads and writes
- Application properties → MySQL: configures connection
- Swagger UI → REST controllers: documents