# abdallahawad3/shopping-world architecture

> Architecture diagram of the GitHub repository abdallahawad3/shopping-world, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abdallahawad3/shopping-world
- Repository: https://github.com/abdallahawad3/shopping-world

## Overview

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: [`src/router/router.tsx`](https://github.com/abdallahawad3/shopping-world/blob/main/src/router/router.tsx) (Router), [`src/layouts/RootLayout.tsx`](https://github.com/abdallahawad3/shopping-world/blob/main/src/layouts/RootLayout.tsx) (Root layout), [`src/components/Cart/CartComponent.tsx`](https://github.com/abdallahawad3/shopping-world/blob/main/src/components/Cart/CartComponent.tsx) (Domain components), [`src/app/feature/Cart/cartSlice.ts`](https://github.com/abdallahawad3/shopping-world/blob/main/src/app/feature/Cart/cartSlice.ts) (Domain slices)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["App shell"]
  node_n1(("Main boot<br/>entrypoint<br/>[main.tsx]"))
  node_n2["App root<br/>app shell<br/>[App.tsx]"]
  node_n3["Router<br/>navigation<br/>[router.tsx]"]
  node_n4["Root layout<br/>[RootLayout.tsx]"]
  node_n5["User layout<br/>[UserLayout.tsx]"]
  node_n6["Admin layout<br/>[AdminLayout.tsx]"]
  node_n7["Route guard<br/>access control"]
end

subgraph group_g2["User experience"]
  node_n8["Home page<br/>route page<br/>[index.tsx]"]
  node_n9["Catalog pages<br/>route pages<br/>[Products.tsx]"]
  node_n10["Cart flow<br/>route pages<br/>[Cart.tsx]"]
  node_n11["User account<br/>route pages<br/>[index.tsx]"]
  node_n12["Category page<br/>route page<br/>[Category.tsx]"]
  node_n13["Brand page<br/>route page<br/>[Brands.tsx]"]
  node_n14["Auth pages<br/>route pages<br/>[Login.tsx]"]
end

subgraph group_g3["Admin console"]
  node_n15["Admin pages<br/>route pages<br/>[AddProduct.tsx]"]
  node_n16["Admin widgets<br/>dashboard ui<br/>[AdminSidebar.tsx]"]
end

subgraph group_g4["State and services"]
  node_n17[("Redux store<br/>state container<br/>[store.ts]")]
  node_n18[("Domain slices<br/>feature state<br/>[cartSlice.ts]")]
  node_n19["API client<br/>http client<br/>[axios.config.ts]"]
  node_n20["Cookie session<br/>session service<br/>[CookieService.ts]"]
end

subgraph group_g5["Shared UI"]
  node_n21["Shared UI kit<br/>ui primitives<br/>[Navbar.tsx]"]
  node_n22["Domain components<br/>feature components<br/>[CartComponent.tsx]"]
end

node_n1 -->|"boots"| node_n2
node_n2 -->|"mounts router"| node_n3
node_n3 -->|"public shell"| node_n4
node_n3 -->|"user shell"| node_n5
node_n3 -->|"admin shell"| node_n6
node_n3 -->|"guards routes"| node_n7
node_n7 -->|"login/register"| node_n14
node_n4 -->|"renders"| node_n8
node_n4 -->|"renders"| node_n9
node_n4 -->|"renders"| node_n12
node_n4 -->|"renders"| node_n13
node_n5 -->|"renders"| node_n10
node_n5 -->|"renders"| node_n11
node_n6 -->|"renders"| node_n15
node_n15 -->|"uses"| node_n16
node_n8 -->|"composes"| node_n22
node_n9 -->|"composes"| node_n22
node_n10 -->|"composes"| node_n22
node_n11 -->|"composes"| node_n22
node_n15 -->|"reads/writes"| node_n18
node_n22 -->|"builds on"| node_n21
node_n17 -->|"contains"| node_n18
node_n18 -->|"fetches via"| node_n19
node_n18 -->|"persists auth"| node_n20
node_n19 -->|"auth context"| node_n20
node_n21 -->|"supports"| node_n8
node_n21 -->|"supports"| node_n9

click node_n1 "https://github.com/abdallahawad3/shopping-world/blob/main/src/main.tsx"
click node_n2 "https://github.com/abdallahawad3/shopping-world/blob/main/src/App.tsx"
click node_n3 "https://github.com/abdallahawad3/shopping-world/blob/main/src/router/router.tsx"
click node_n4 "https://github.com/abdallahawad3/shopping-world/blob/main/src/layouts/RootLayout.tsx"
click node_n5 "https://github.com/abdallahawad3/shopping-world/blob/main/src/layouts/UserLayout.tsx"
click node_n6 "https://github.com/abdallahawad3/shopping-world/blob/main/src/layouts/AdminLayout.tsx"
click node_n7 "https://github.com/abdallahawad3/shopping-world/blob/main/src/components/Auth/ProtectedRoutes.tsx"
click node_n8 "https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Home/index.tsx"
click node_n9 "https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Products/Products.tsx"
click node_n10 "https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Cart/Cart.tsx"
click node_n11 "https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/User/index.tsx"
click node_n12 "https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Catrgories/Category.tsx"
click node_n13 "https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Brands/Brands.tsx"
click node_n14 "https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Auth/Login.tsx"
click node_n15 "https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Admin/AddProduct.tsx"
click node_n16 "https://github.com/abdallahawad3/shopping-world/blob/main/src/components/Admin/AdminSidebar.tsx"
click node_n17 "https://github.com/abdallahawad3/shopping-world/blob/main/src/app/store.ts"
click node_n18 "https://github.com/abdallahawad3/shopping-world/blob/main/src/app/feature/Cart/cartSlice.ts"
click node_n19 "https://github.com/abdallahawad3/shopping-world/blob/main/src/config/axios.config.ts"
click node_n20 "https://github.com/abdallahawad3/shopping-world/blob/main/src/services/CookieService.ts"
click node_n21 "https://github.com/abdallahawad3/shopping-world/blob/main/src/components/utils/Navbar.tsx"
click node_n22 "https://github.com/abdallahawad3/shopping-world/blob/main/src/components/Cart/CartComponent.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n1,node_n2,node_n3,node_n4,node_n5,node_n6,node_n7 toneBlue
class node_n8,node_n9,node_n10,node_n11,node_n12,node_n13,node_n14 toneAmber
class node_n15,node_n16 toneMint
class node_n17,node_n18,node_n19,node_n20 toneRose
class node_n21,node_n22 toneIndigo
```

## Components

### App shell

Bootstrap, routing, and page layouts.

- [Main boot](https://github.com/abdallahawad3/shopping-world/blob/main/src/main.tsx): entrypoint · Application bootstrap and global provider wiring. · `src/main.tsx`
- [App root](https://github.com/abdallahawad3/shopping-world/blob/main/src/App.tsx): app shell · Top-level app composition and global setup. · `src/App.tsx`
- [Router](https://github.com/abdallahawad3/shopping-world/blob/main/src/router/router.tsx): navigation · Defines public, user, and admin route boundaries. · `src/router/router.tsx`
- [Root layout](https://github.com/abdallahawad3/shopping-world/blob/main/src/layouts/RootLayout.tsx): layout · Shared shell for public-facing pages. · `src/layouts/RootLayout.tsx`
- [User layout](https://github.com/abdallahawad3/shopping-world/blob/main/src/layouts/UserLayout.tsx): layout · Shell for authenticated customer pages. · `src/layouts/UserLayout.tsx`
- [Admin layout](https://github.com/abdallahawad3/shopping-world/blob/main/src/layouts/AdminLayout.tsx): layout · Shell for admin dashboard pages. · `src/layouts/AdminLayout.tsx`
- [Route guard](https://github.com/abdallahawad3/shopping-world/blob/main/src/components/Auth/ProtectedRoutes.tsx): access control · Protects authenticated and admin-only routes. · `src/components/Auth/ProtectedRoutes.tsx`

### User experience

Public shopping and account flows.

- [Home page](https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Home/index.tsx): route page · Landing page composed from product and promo sections. · `src/Pages/Home/index.tsx`
- [Catalog pages](https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Products/Products.tsx): route pages · Product listing and product detail routes. · `src/Pages/Products/Products.tsx`
- [Cart flow](https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Cart/Cart.tsx): route pages · Shopping cart and cart sidebar experience. · `src/Pages/Cart/Cart.tsx`
- [User account](https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/User/index.tsx): route pages · Wishlist, address, profile, and user-area routes. · `src/Pages/User/index.tsx`
- [Category page](https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Catrgories/Category.tsx): route page · Category browsing route. · `src/Pages/Catrgories/Category.tsx`
- [Brand page](https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Brands/Brands.tsx): route page · Brand browsing route. · `src/Pages/Brands/Brands.tsx`
- [Auth pages](https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Auth/Login.tsx): route pages · Login and registration screens. · `src/Pages/Auth/Login.tsx`

### Admin console

Back-office management screens and widgets.

- [Admin pages](https://github.com/abdallahawad3/shopping-world/blob/main/src/Pages/Admin/AddProduct.tsx): route pages · Dashboard CRUD and order management pages. · `src/Pages/Admin/AddProduct.tsx`
- [Admin widgets](https://github.com/abdallahawad3/shopping-world/blob/main/src/components/Admin/AdminSidebar.tsx): dashboard ui · Sidebar, tables, cards, and admin detail components. · `src/components/Admin/AdminSidebar.tsx`

### State and services

Redux slices, API access, and session handling.

- [Redux store](https://github.com/abdallahawad3/shopping-world/blob/main/src/app/store.ts): state container · Central store configuration for app state. · `src/app/store.ts`
- [Domain slices](https://github.com/abdallahawad3/shopping-world/blob/main/src/app/feature/Cart/cartSlice.ts): feature state · Auth, cart, wishlist, catalog, coupon, address, and global slices. · `src/app/feature/Cart/cartSlice.ts`
- [API client](https://github.com/abdallahawad3/shopping-world/blob/main/src/config/axios.config.ts): http client · Centralized axios configuration and dashboard API calls. · `src/config/axios.config.ts`
- [Cookie session](https://github.com/abdallahawad3/shopping-world/blob/main/src/services/CookieService.ts): session service · Cookie-based persistence and rehydration support. · `src/services/CookieService.ts`

### Shared UI

Reusable components and presentation primitives.

- [Shared UI kit](https://github.com/abdallahawad3/shopping-world/blob/main/src/components/utils/Navbar.tsx): ui primitives · Navbar, footer, dialogs, pagination, cards, and inputs. · `src/components/utils/Navbar.tsx`
- [Domain components](https://github.com/abdallahawad3/shopping-world/blob/main/src/components/Cart/CartComponent.tsx): feature components · Cart, product, home, wishlist, user, category, and brand components. · `src/components/Cart/CartComponent.tsx`

## Connections

- 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.
