# hainam1408/interlux-fe architecture

> Architecture diagram of the GitHub repository hainam1408/interlux-fe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hainam1408/interlux-fe
- Repository: https://github.com/hainam1408/interlux-fe

## Overview

##### Project type and purpose
- This is a front-end single-page e-commerce application built with React, TypeScript, and Vite.
- It provides product listing, product detail, cart management, authentication, chat-bot support, and 3D model viewing (GLB files under public/models).
- It consumes RESTful APIs (auth, cart, category, chatbot, product) exposed by a back-end or microservices.

##### File structure
- Top-level:
· public/ – static assets and 3D models
· src/
– src/main.tsx, App.tsx – application entry point
– src/pages/… – page-level components (landing, layout, login, products, product-detail)
– src/components/… – reusable UI components (buttons, inputs, chat-bot, loading screens, etc.)
– src/apis/… – API wrappers for each REST endpoint
– src/redux/… – Redux slices and store setup
– src/routes/router-container.tsx – client routing layer
– src/hooks, src/utils – custom hooks and HTTP utility
– src/themes, src/constants, src/configs – theming, constants, and route layouts
- Configuration files: vite.config.ts, tsconfig*.json, eslint.config.js, package.json

##### Key technical stack from README
- React 18 + TypeScript + Vite for fast HMR builds
- ESLint (with recommended and type-checked rules)
- SWC/Babel plugin for React Fast Refresh

##### Main components
a. Client SPA (browser)
- Vite-built JS bundle (App.tsx + pages + components)
- Static assets (images, videos, GLB 3D models served from CDN or static hosting)
b. API Gateway / Backend services
- Auth Service (login/register endpoints)
- Product Service (list, detail)
- Category Service
- Cart Service
- Chatbot Service (possibly backed by an AI engine)
c. Data stores
- Relational or NoSQL DB for users, products, categories, carts, orders
d. External services
- CDN (for static assets & 3D models)
- Third-party Chatbot / AI API
e. Redux store (client-side state)
f. Client Router (routes → pages)

##### Relationships & interactions
- The browser loads index.html → main.tsx → hydrates App.
- Client Router directs to pages.
- Pages/components call src/apis/*.api.ts → fetch() → API Gateway.
- API Gateway forwards to microservices.
- Microservices read/write to shared DB.
- Payment service callbacks update Order status.
- Chatbot UI ↔ Chatbot Service ↔ AI API.
- Static assets (models/videos/images) served from CDN/public.

##### Architectural patterns & principles
- SPA with clear separation of concerns: presentation (components/pages) vs. data-access (api wrappers) vs. state (Redux).
- Feature folders: grouping by page and component domain.
- Unidirectional data flow: React → Redux → API → Redux.
- Thematic styling: global theme + CSS/SCSS modules.
- Client-side routing (React Router).

## Diagram (Mermaid)

```mermaid
graph TB
  %% Client Side
  subgraph "Client (Browser)"
    direction TB
    MainTSX["main.tsx\n(src/main.tsx)"]:::client
    AppTSX["App.tsx\n(src/App.tsx)"]:::client
    Router["Router\n(src/routes/router-container.tsx)"]:::client
    ReduxStore["Redux Store\n(src/redux/store/index.ts)"]:::client
    subgraph "API Client Layer"
      direction TB
      AuthAPI["Auth API\n(src/apis/auth.api.ts)"]:::client
      CartAPI["Cart API\n(src/apis/cart.api.ts)"]:::client
      CategoryAPI["Category API\n(src/apis/category.api.ts)"]:::client
      ChatbotAPI["Chatbot API\n(src/apis/chatbot.api.ts)"]:::client
      ProductAPI["Product API\n(src/apis/product.api.ts)"]:::client
    end
    subgraph "Pages & Components"
      direction TB
      LandingPage["Landing Page\n(src/pages/landding/index.tsx)"]:::client
      LayoutPage["Layout\n(src/pages/layout/index.tsx)"]:::client
      LoginPage["Login/Register\n(src/pages/login/index.tsx)"]:::client
      ProductsPage["Products List\n(src/pages/products/index.tsx)"]:::client
      ProductDetail["Product Detail\n(src/pages/product-detail/index.tsx)"]:::client
      ChatbotWrapper["Chatbot Wrapper\n(src/components/chat-bot-wrapper/index.tsx)"]:::client
      ChatbotCore["Chatbot Core\n(src/components/chat-bot/index.tsx)"]:::client
      ButtonComp["Button\n(src/components/button-custom/index.tsx)"]:::client
      InputComp["Input\n(src/components/input-custom/index.tsx)"]:::client
      LoadingComp["Loading Screen\n(src/components/loading-screen/index.tsx)"]:::client
      PaginationComp["Pagination\n(src/components/pagination-custom/index.tsx)"]:::client
    end
  end

  %% Static Assets
  StaticAssets["Static Assets\n(public/models, CDN)"]:::client

  %% API Gateway
  APIGateway["API Gateway\n(REST)"]:::backend

  %% Backend Services
  subgraph "Backend Services"
    direction TB
    AuthService["Auth Service"]:::backend
    ProductService["Product Service"]:::backend
    CategoryService["Category Service"]:::backend
    CartService["Cart Service"]:::backend
    ChatbotService["Chatbot Service"]:::backend
  end

  %% Database
  Database["Database\n(Relational/NoSQL)"]:::database

  %% External Services
  subgraph "External Services"
    direction TB
    PaymentGateway["Payment Gateway"]:::external
    ChatbotAI["Chatbot AI API"]:::external
  end

  %% Connections
  MainTSX --> AppTSX
  AppTSX --> Router
  Router --> LandingPage
  Router --> LayoutPage
  Router --> LoginPage
  Router --> ProductsPage
  Router --> ProductDetail
  LandingPage --> AuthAPI
  LoginPage --> AuthAPI
  ProductsPage --> ProductAPI
  ProductDetail --> ProductAPI
  LandingPage --> CategoryAPI
  ProductsPage --> CategoryAPI
  CartService -.-> CartAPI
  ProductDetail --> CartAPI
  CartAPI --> APIGateway
  AuthAPI --> APIGateway
  ProductAPI --> APIGateway
  CategoryAPI --> APIGateway
  ChatbotAPI --> APIGateway
  APIGateway --> AuthService
  APIGateway --> ProductService
  APIGateway --> CategoryService
  APIGateway --> CartService
  APIGateway --> ChatbotService
  AuthService --> Database
  ProductService --> Database
  CategoryService --> Database
  CartService --> Database
  ChatbotService --> Database
  ChatbotWrapper --> ChatbotAPI
  ChatbotCore --> ChatbotAPI
  ChatbotService --> ChatbotAI
  AppTSX --> ReduxStore
  ReduxStore --> AuthAPI
  ReduxStore --> CartAPI
  ReduxStore --> ProductAPI
  ReduxStore --> CategoryAPI
  ReduxStore --> ChatbotAPI
  ProductDetail --> StaticAssets
  ProductsPage --> StaticAssets

  %% Click Events
  click MainTSX "https://github.com/hainam1408/interlux-fe/blob/main/src/main.tsx"
  click AppTSX "https://github.com/hainam1408/interlux-fe/blob/main/src/App.tsx"
  click Router "https://github.com/hainam1408/interlux-fe/blob/main/src/routes/router-container.tsx"
  click ReduxStore "https://github.com/hainam1408/interlux-fe/blob/main/src/redux/store/index.ts"
  click AuthAPI "https://github.com/hainam1408/interlux-fe/blob/main/src/apis/auth.api.ts"
  click CartAPI "https://github.com/hainam1408/interlux-fe/blob/main/src/apis/cart.api.ts"
  click CategoryAPI "https://github.com/hainam1408/interlux-fe/blob/main/src/apis/category.api.ts"
  click ChatbotAPI "https://github.com/hainam1408/interlux-fe/blob/main/src/apis/chatbot.api.ts"
  click ProductAPI "https://github.com/hainam1408/interlux-fe/blob/main/src/apis/product.api.ts"
  click LandingPage "https://github.com/hainam1408/interlux-fe/blob/main/src/pages/landding/index.tsx"
  click LayoutPage "https://github.com/hainam1408/interlux-fe/blob/main/src/pages/layout/index.tsx"
  click LoginPage "https://github.com/hainam1408/interlux-fe/blob/main/src/pages/login/index.tsx"
  click ProductsPage "https://github.com/hainam1408/interlux-fe/blob/main/src/pages/products/index.tsx"
  click ProductDetail "https://github.com/hainam1408/interlux-fe/blob/main/src/pages/product-detail/index.tsx"
  click ChatbotWrapper "https://github.com/hainam1408/interlux-fe/blob/main/src/components/chat-bot-wrapper/index.tsx"
  click ChatbotCore "https://github.com/hainam1408/interlux-fe/blob/main/src/components/chat-bot/index.tsx"
  click ButtonComp "https://github.com/hainam1408/interlux-fe/blob/main/src/components/button-custom/index.tsx"
  click InputComp "https://github.com/hainam1408/interlux-fe/blob/main/src/components/input-custom/index.tsx"
  click LoadingComp "https://github.com/hainam1408/interlux-fe/blob/main/src/components/loading-screen/index.tsx"
  click PaginationComp "https://github.com/hainam1408/interlux-fe/blob/main/src/components/pagination-custom/index.tsx"

  %% Styles
  classDef client fill:#D0E8FF,stroke:#0B69A3,color:#0B69A3;
  classDef backend fill:#DFF5D4,stroke:#3A8F22,color:#3A8F22;
  classDef database fill:#E0E0E0,stroke:#888888,color:#333333;
  classDef external fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00;
```
