How prantascode/ecommerce-website works
1. This repository is a Spring Boot backend for an e-commerce system, not a full frontend app. The architectural center is a REST API that exposes business capabilities for authentication, catalog management, cart, orders, payments, reviews, wishlists, and admin/customer operations.
2. The codebase follows a clear layered structure: Controller handles HTTP endpoints, Service contains business rules, Repository provides persistence access, and Entity defines the database model. This is the main boundary an architecture diagram should show, with requests flowing downward and DTOs used at the API edge.
3. Authentication and authorization are a major subsystem. AuthController, AuthService, CustomUserDetailsService, JwtFilter, Jwtutil, and SecurityConfig work together to handle registration, login, JWT issuance/validation, refresh tokens, and role-based access control for ADMIN and CUSTOMER.
4. Domain data is modeled with JPA entities for User, Customer, Product, Brand, Category, Cart, CartItem, Order, OrderItem, Payment, Review, Wishlist, Discount, and RefreshToken. These entities are persisted through Spring Data repositories and represent the core business state in MySQL.
5. Product and catalog management are isolated into their own flow: ProductController and ProductService manage products, while BrandController/BrandService and CategoryController/CategoryService support classification and filtering. DiscountController/DiscountService adds pricing logic that likely affects product and order calculations.
6. Cart and checkout form another business pipeline. CartController and CartService manage cart state and cart items, then OrderController and OrderService convert cart contents into orders and order items. This is the key transactional handoff from shopping to purchase.
7. Payment integration is a separate boundary around external processing. PaymentController, PaymentService, and SSLCommerzConfig indicate integration with the SSLCommerz gateway for payment initiation and verification, with Payment persisted as an internal record of the transaction outcome.
8. Reviews and wishlists are auxiliary customer-facing features. ReviewController/ReviewService manage product feedback, and WishlistController/WishlistService handle saved items. These are independent from the core checkout path but still tied to authenticated users and products.
9. The API surface is strongly typed with request/response DTOs under Dto/Request and Dto/Response. This keeps controllers decoupled from persistence entities and makes the external contract explicit for login, registration, product updates, order placement, payment responses, and similar operations.
10. Error handling is centralized. Custom exceptions such as ResourceNotFoundException, DuplicateResourceException, InvalidRequestException, and UnauthorizedAccessException are translated by GlobalExceptionHandler into a structured ErrorResponseDto, which is an important cross-cutting boundary for API reliability.
11. The application includes operational support components: OpenApiConfig for Swagger/OpenAPI documentation, DataInitializer for bootstrapping data, and CartCleanupScheduler for periodic cart maintenance. These are supporting subsystems rather than primary business flows, but they affect runtime behavior.
12. Persistence and runtime environment are straightforward: the project uses Maven, Spring Boot, Spring Security, Spring Data JPA/Hibernate, and MySQL, with configuration driven from application.properties. There is a single backend deployable (EcommerceApplication) and a basic test entry point under src/test.
Main entry points: EcommerceApplication.java App · Dto DTOs · Repository Repositories · AuthController.java Auth API
Components 20
API Layer
HTTP controllers and DTOs at the application boundary
- Auth API · Login, registration, token refresh, and auth endpoints
src/main/java/com/pranta/ecommerce/Controller/AuthController.java - Catalog API · Product, brand, category, and discount endpoints
src/main/java/com/pranta/ecommerce/Controller/ProductController.java - Cart API · Cart and cart item endpoints
src/main/java/com/pranta/ecommerce/Controller/CartController.java - Order API · Order placement and order update endpoints
src/main/java/com/pranta/ecommerce/Controller/OrderController.java - Payment API · Payment initiation and verification endpoints
src/main/java/com/pranta/ecommerce/Controller/PaymentController.java - Social API · Review and wishlist endpoints
src/main/java/com/pranta/ecommerce/Controller/ReviewController.java - User API · Customer and user administration endpoints
src/main/java/com/pranta/ecommerce/Controller/UserController.java - DTOs · Request and response models for the REST API
src/main/java/com/pranta/ecommerce/Dto
Domain Layer
Business services and core workflows
- Auth Service · Authentication, JWT, and refresh token flows
src/main/java/com/pranta/ecommerce/Service/AuthService.java - Catalog Service · Products, brands, categories, and discount rules
src/main/java/com/pranta/ecommerce/Service/ProductService.java - Checkout Flow · Cart handling, order creation, and order items
src/main/java/com/pranta/ecommerce/Service/CartService.java - Payment Service · Gateway integration and payment record handling
src/main/java/com/pranta/ecommerce/Service/PaymentService.java - Customer Features · Reviews, wishlists, and customer-facing account actions
src/main/java/com/pranta/ecommerce/Service/ReviewService.java
Data Layer
Entities and repositories for persistence
- Entities · User, product, order, payment, review, wishlist, and token state
src/main/java/com/pranta/ecommerce/Entity - Repositories · Persistence access for core domain aggregates
src/main/java/com/pranta/ecommerce/Repository
Cross-cutting
Security, configuration, errors, and runtime support
- App · Application bootstrap and runtime entry
src/main/java/com/pranta/ecommerce/EcommerceApplication.java - Security · JWT filter, user details, and access rules
src/main/java/com/pranta/ecommerce/Security/JwtFilter.java - Config · Security, OpenAPI, and payment gateway configuration
src/main/java/com/pranta/ecommerce/Config/SecurityConfig.java - Errors · Custom exceptions and global API error mapping
src/main/java/com/pranta/ecommerce/Exceptions/GlobalExceptionHandler.java - Scheduler · Periodic cart cleanup task
src/main/java/com/pranta/ecommerce/Scheduler/CartCleanupScheduler.java
Connections 33
- App → Auth API: serves · Bootstraps REST authentication endpoints
- App → Catalog API: serves · Bootstraps catalog endpoints
- App → Cart API: serves · Bootstraps cart endpoints
- App → Order API: serves · Bootstraps order endpoints
- App → Payment API: serves · Bootstraps payment endpoints
- App → Social API: serves · Bootstraps review and wishlist endpoints
- App → User API: serves · Bootstraps user and customer endpoints
- Auth API → Auth Service: calls · Delegates authentication and token operations
- Catalog API → Catalog Service: calls · Delegates catalog and pricing rules
- Cart API → Checkout Flow: calls · Delegates cart state changes
- Order API → Checkout Flow: calls · Delegates order creation and updates
- Payment API → Payment Service: calls · Delegates gateway operations
- Social API → Customer Features: calls · Delegates review and wishlist actions
- User API → Customer Features: calls · Delegates customer and profile operations
- Auth Service → Security: uses · JWT validation and user lookup
- Auth Service → Repositories: persists · Reads and writes users and refresh tokens
- Catalog Service → Repositories: persists · Uses product, brand, category, and discount repositories
- Checkout Flow → Repositories: persists · Uses cart, order, and order item repositories
- Payment Service → Config: uses · Uses payment gateway configuration
- Payment Service → Repositories: persists · Stores payment outcomes
- Customer Features → Repositories: persists · Uses review and wishlist repositories
- Security → Config: configured by · Security chain and JWT settings
- Repositories → Entities: maps · Spring Data repositories operate on JPA entities
- DTOs → Auth API: contracts · Request and response models at the API boundary
- DTOs → Catalog API: contracts · Typed catalog requests and responses
- DTOs → Cart API: contracts · Typed cart requests and responses
- DTOs → Order API: contracts · Typed order requests and responses
- DTOs → Payment API: contracts · Typed payment responses
- DTOs → Social API: contracts · Typed review and wishlist payloads
- Errors → Auth API: handles · Translates controller and service failures
- Errors → Catalog API: handles · Translates controller and service failures
- Errors → Cart API: handles · Translates controller and service failures
- Scheduler → Checkout Flow: triggers · Runs periodic cart cleanup through cart logic