Hello this is shiva ✌🏻
This project started from a deliberately bad, real-world style e-commerce admin flow and is now refactored to follow SOLID principles.
npm install
npm run devsrc/App.jsxoriginally handled UI rendering, pricing, discounts, payment logic, notification side effects, local storage, refund state changes, and CSV reporting.
- Adding payment types required editing
if/elseblocks in the main component. - Adding notification channels required changing core flow code.
- No formal contract-like behavior for payment/notification handlers, increasing risk of inconsistent replacement behavior.
- UI depended on a giant mixed API from one component instead of small, focused interfaces.
- High-level order flow depended directly on concrete details (
fetch,alert,localStorage, inline payment branches).
Code is split by responsibility:
- Domain rules:
src/domain/catalog.jssrc/domain/discountPolicy.jssrc/domain/orderFactory.js
- Application orchestration:
src/adapters/orderAppService.js
- Infrastructure/persistence:
src/repositories/orderRepository.js
- Integrations:
src/services/paymentProcessors.jssrc/services/paymentService.jssrc/services/notifiers.jssrc/services/notificationService.jssrc/services/reportService.js
- UI-only components:
src/ui/OrderForm.jsxsrc/ui/OrdersTable.jsxsrc/App.jsx(wiring/orchestration only)
- New payment method: implement a new processor class and register it in
PaymentServicemap. - New notification channel: implement a notifier class and add it to
NotificationServicelist. - Core order flow (
OrderAppService) stays unchanged.
- Payment processors all expose
pay(payload). - Notifiers all expose
notify(payload). - Services operate on behavior contracts, so implementations can be swapped consistently.
- UI consumes focused props from dedicated components (
OrderForm,OrdersTable) instead of a monolithic interface. - App logic is exposed through narrow app-service methods:
placeOrderrefundOrderexportOrdersReportloadOrders
- High-level flow in
OrderAppServicedepends on abstractions/collaborators injected at creation time. - Concrete infrastructure concerns are moved to repository/services and composed in
createOrderAppService().
- Easier to test business logic without React rendering.
- Lower risk changes when adding payment or notification capabilities.
- Better maintainability via clear module boundaries.
- Cleaner UI components focused on user interaction.