How abdallahawad3/shopping-world works
1. Overall shape
- This repository is a single-page e-commerce frontend built with React + TypeScript and bundled by Vite.
- The architecture is organized around routed pages, reusable UI components, and a centralized Redux state layer that drives cart, auth, catalog, wishlist, and admin workflows.
2. Top-level application composition
- src/main.tsx boots the app, while src/App.tsx likely wires the router and global providers.
- src/router/router.tsx is the main navigation boundary, separating public pages, authenticated user pages, and admin pages.
- src/layouts/RootLayout.tsx, UserLayout.tsx, and AdminLayout.tsx indicate three distinct page shells with shared navigation and page chrome.
3. User-facing product and shopping flows
- The user area covers product discovery and shopping operations: home, products listing, single product detail, brands, categories, cart, wishlist, and address management.
- Pages under src/Pages/Home, Products, Brands, Cart, User, and Catrgories are thin route-level containers that assemble reusable components from src/components.
4. Admin management subsystem
- The admin section is a separate functional boundary under src/Pages/Admin and src/components/Admin.
- It supports catalog and promotion management: products, brands, categories, subcategories, coupons, and order views.
- Components like AdminSidebar, DashboardTable, OrderCard, and CouponCard suggest a dashboard-style interface with list/detail management patterns.
5. State management and domain slices
- Core application state lives in Redux Toolkit slices under src/app/feature.
- Distinct slices exist for Auth, Cart, Wishlist, Brands, Category, Subcategory, Products, Coupon, Address, and Global state.
- This indicates the application treats each business domain as an independent state boundary rather than using a monolithic store.
6. Persistence and session continuity
- The README confirms use of redux-persist, so selected state survives reloads and browser restarts.
- Authentication/session handling is also cookie-based via src/services/CookieService.ts and universal-cookie, implying token or session data is stored outside Redux and rehydrated for route protection.
7. API and backend integration
- src/config/axios.config.ts centralizes HTTP client configuration, which is the main boundary for backend communication.
- src/app/services/dashboardProductApi.ts suggests at least one service layer for admin/dashboard data fetching.
- The data flow is: page/component triggers action or query, slice/service calls the axios layer, response updates Redux, UI re-renders from store state.
8. Route protection and access control
- src/components/Auth/ProtectedRoutes.tsx is the key guardrail for separating unauthenticated users, normal users, and admin-only views.
- This is reinforced by the split layouts and the presence of dedicated auth pages (Login, Register).
- Access control is therefore handled at the routing boundary rather than inside individual feature components.
9. Shared reusable UI library
- src/components/utils contains app-wide primitives such as Navbar, Footer, ModalDialog, Pagination, SelectMenu, RatingStars, and ProductCard.
- Feature-specific components build on these shared primitives, which keeps page-level code focused on composition rather than repeated UI logic.
10. Feature-specific UI composition
- Each major domain has its own component set: cart (CartComponent, CartItem, CartDrawer), products (ProductSlider, ProductSidebar, reviews), user (ProfilePage, UserSidebar, AddressCard), wishlist, and home sections (Slider, Discount, BrandsSection, CardProductsSection).
- This component structure mirrors the Redux slices and page routes, making the architecture easy to map domain-by-domain.
11. Media and static content
- src/assets/images and src/assets/videos hold the visual assets used across marketing and product pages.
- src/data/index.ts and src/interfaces/index.ts suggest the project also centralizes static seed-like data and shared TypeScript contracts.
12. Validation and form handling
- The presence of src/validation/index.ts and the README’s use of React Hook Form indicates forms are a significant part of the architecture.
- Admin CRUD pages and auth/address forms likely rely on validation schemas and shared inputs such as AddImageInput.
13. Styling and presentation layer
- Styling is primarily Tailwind CSS, with a small amount of local CSS in src/components/Products/styles.css.
- This makes the UI layer utility-driven, with component composition doing most of the visual structuring.
- Swiper-based carousels and toast notifications are part of the interactive presentation layer.
14. Key architectural boundaries for a diagram
- A useful diagram would show four main boundaries: routing/layouts, feature state slices, shared components, and API/session services.
- Data flows outward from Redux and services into pages/components, while auth/session state flows back into route guards and layout selection.
- Admin and user experiences are not separate apps, but clearly separated slices of the same frontend with different layouts and protected routes.
Main entry points: router.tsx Router · RootLayout.tsx Root layout · CartComponent.tsx Domain components · cartSlice.ts Domain slices
Components 22
App shell
Bootstrap, routing, and page layouts.
- Main boot · Application bootstrap and global provider wiring.
src/main.tsx - App root · Top-level app composition and global setup.
src/App.tsx - Router · Defines public, user, and admin route boundaries.
src/router/router.tsx - Root layout · Shared shell for public-facing pages.
src/layouts/RootLayout.tsx - User layout · Shell for authenticated customer pages.
src/layouts/UserLayout.tsx - Admin layout · Shell for admin dashboard pages.
src/layouts/AdminLayout.tsx - Route guard · Protects authenticated and admin-only routes.
src/components/Auth/ProtectedRoutes.tsx
User experience
Public shopping and account flows.
- Home page · Landing page composed from product and promo sections.
src/Pages/Home/index.tsx - Catalog pages · Product listing and product detail routes.
src/Pages/Products/Products.tsx - Cart flow · Shopping cart and cart sidebar experience.
src/Pages/Cart/Cart.tsx - User account · Wishlist, address, profile, and user-area routes.
src/Pages/User/index.tsx - Category page · Category browsing route.
src/Pages/Catrgories/Category.tsx - Brand page · Brand browsing route.
src/Pages/Brands/Brands.tsx - Auth pages · Login and registration screens.
src/Pages/Auth/Login.tsx
Admin console
Back-office management screens and widgets.
- Admin pages · Dashboard CRUD and order management pages.
src/Pages/Admin/AddProduct.tsx - Admin widgets · Sidebar, tables, cards, and admin detail components.
src/components/Admin/AdminSidebar.tsx
State and services
Redux slices, API access, and session handling.
- Redux store · Central store configuration for app state.
src/app/store.ts - Domain slices · Auth, cart, wishlist, catalog, coupon, address, and global slices.
src/app/feature/Cart/cartSlice.ts - API client · Centralized axios configuration and dashboard API calls.
src/config/axios.config.ts - Cookie session · Cookie-based persistence and rehydration support.
src/services/CookieService.ts
Shared UI
Reusable components and presentation primitives.
- Shared UI kit · Navbar, footer, dialogs, pagination, cards, and inputs.
src/components/utils/Navbar.tsx - Domain components · Cart, product, home, wishlist, user, category, and brand components.
src/components/Cart/CartComponent.tsx
Connections 27
- Main boot → App root: boots · Entry initializes the app root.
- App root → Router: mounts router · App composition delegates navigation to the router.
- Router → Root layout: public shell · Public routes render within the root layout.
- Router → User layout: user shell · Authenticated customer routes render within the user layout.
- Router → Admin layout: admin shell · Admin routes render within the admin layout.
- Router → Route guard: guards routes · Route protection separates public, user, and admin access.
- Route guard → Auth pages: login/register · Unauthenticated users are routed to auth pages.
- Root layout → Home page: renders · Root layout hosts public landing content.
- Root layout → Catalog pages: renders · Root layout hosts catalog browsing pages.
- Root layout → Category page: renders · Category browsing is part of the public shell.
- Root layout → Brand page: renders · Brand browsing is part of the public shell.
- User layout → Cart flow: renders · User layout hosts cart-related routes.
- User layout → User account: renders · User layout hosts account management routes.
- Admin layout → Admin pages: renders · Admin layout hosts back-office pages.
- Admin pages → Admin widgets: uses · Admin pages compose dashboard widgets and cards.
- Home page → Domain components: composes · Home page is built from shared feature components.
- Catalog pages → Domain components: composes · Catalog routes reuse product and filter components.
- Cart flow → Domain components: composes · Cart views use cart-specific UI components.
- User account → Domain components: composes · User pages use account and wishlist components.
- Admin pages → Domain slices: reads/writes · Admin CRUD flows update domain state.
- Domain components → Shared UI kit: builds on · Feature components are assembled from shared primitives.
- Redux store → Domain slices: contains · Redux store combines the domain slices.
- Domain slices → API client: fetches via · Slices and async flows use the central HTTP client.
- Domain slices → Cookie session: persists auth · Session continuity is supported through cookie storage.
- API client → Cookie session: auth context · Cookie state supports request/session handling.
- Shared UI kit → Home page: supports · Shared UI primitives are used across pages.
- Shared UI kit → Catalog pages: supports · Shared UI primitives are used across catalog views.