# dimuthu7/micro-frontend-with-react-vite architecture

> Architecture diagram of the GitHub repository dimuthu7/micro-frontend-with-react-vite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dimuthu7/micro-frontend-with-react-vite
- Repository: https://github.com/dimuthu7/micro-frontend-with-react-vite

## Overview

#### Purpose and Entry Points
This is a two-application React product-catalog micro-frontend demo. The host owns catalog navigation and cart state; the remote supplies a product-detail card at runtime through Vite Module Federation. Browser entry points are `host/src/main.tsx` and `remote/src/main.tsx`; host orchestration begins in `host/src/App.tsx`.

#### Host Shell and State Ownership
`host/src/App.tsx` is the control boundary for selected-product and cart-count state. It switches between local catalog and detail views, passes product data into the remote-facing detail container, and receives add-to-cart callbacks. `host/src/data/products.ts` is the host-owned catalog source, while `host/src/types/index.ts` defines its product contracts.

#### Catalog Presentation Stage
The initial host view composes application chrome with a local product grid:
- `host/src/components/ProductListView.tsx`
- `host/src/components/ProductList.tsx`
- `host/src/components/Header.tsx`

Product selection flows upward from the list to `App.tsx`; cart updates flow from host state back into the header. `host/src/components/Footer.tsx` is shared host chrome.

#### Remote Detail Integration Boundary
`host/src/components/ProductDetailsView.tsx` is the federation consumption boundary. It lazy-loads the remote `ProductCard`, renders it under React Suspense, and isolates remote failures through `host/src/components/ErrorBoundary.tsx`. Back-navigation is local host behavior via `host/src/components/BackButton.tsx`.

The remote exports the detail UI from `remote/src/components/ProductCard.tsx`; its public prop shape is represented in `remote/src/types/index.ts`. Host-to-remote communication is props; remote-to-host communication is callback invocation, notably for cart additions.

#### Federation and Runtime Loading
Both Vite builds configure federation in:
- `host/vite.config.ts`
- `remote/vite.config.ts`

The host resolves the remote’s `remoteEntry.js` at runtime and imports the exposed `./ProductCard` module only when a product detail is requested. React and React DOM are configured as shared singleton dependencies, allowing the remote component to render in the host React tree rather than carrying an isolated framework runtime.

#### Deployment and Network Topology
Each app has an independent build-and-serve image:
- `host/Dockerfile`
- `remote/Dockerfile`
- `docker-compose.yml`

Docker Compose runs host and remote services, with the host dependent on the remote. Production artifacts are served by Nginx using `host/nginx.conf` and `remote/nginx.conf`; the remote server is responsible for cross-origin access needed by the host’s browser-side federation request. Development uses separate Vite servers, conventionally host on 5173 and remote on 5174.

#### Material Technology Boundaries
The UI runtime is React 18 with TypeScript, Vite, Tailwind CSS, and component-local CSS for the remote card (`remote/src/components/ProductCard.css`). Nginx is the static production edge, Docker Compose is the local/container orchestration layer, and the only cross-application external dependency is the remote’s HTTP-served federation manifest and chunks.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host application"]
  node_host_entry["Host browser entry<br/>React entry<br/>[main.tsx]"]
  node_host_app["Host app controller<br/>React state boundary<br/>[App.tsx]"]
  node_catalog_data[("Catalog products<br/>catalog data<br/>[products.ts]")]
  node_host_contracts["Product contracts<br/>TypeScript types<br/>[index.ts]"]
  node_catalog_view["Catalog view<br/>React view"]
  node_product_list["Product list<br/>React component<br/>[ProductList.tsx]"]
  node_host_chrome["Header and footer<br/>host chrome<br/>[Header.tsx]"]
  node_detail_view{{"Detail integration view<br/>federation consumer"}}
  node_error_boundary["Remote error boundary<br/>React boundary<br/>[ErrorBoundary.tsx]"]
  node_back_button["Back navigation<br/>React component<br/>[BackButton.tsx]"]
end

subgraph group_remote["Remote application"]
  node_remote_entry["Remote browser entry<br/>React entry<br/>[main.tsx]"]
  node_product_card["Product card<br/>federated React module<br/>[ProductCard.tsx]"]
  node_remote_contracts["Remote card props<br/>TypeScript types<br/>[index.ts]"]
end

subgraph group_deployment["Build and delivery"]
  node_host_image["Host image and Nginx<br/>containerized static host"]
  node_remote_image["Remote image and Nginx<br/>containerized static remote"]
  node_compose{{"Docker Compose<br/>service orchestration<br/>[docker-compose.yml]"}}
end

node_federation_runtime{{"Federation runtime<br/>Vite Module Federation<br/>[vite.config.ts]"}}

node_host_entry -->|"mounts"| node_host_app
node_host_app -->|"reads"| node_catalog_data
node_host_app -.->|"uses"| node_host_contracts
node_host_app -->|"renders catalog"| node_catalog_view
node_catalog_view -->|"composes"| node_product_list
node_product_list -->|"selects product"| node_host_app
node_host_app -->|"supplies cart count"| node_host_chrome
node_host_app -->|"renders detail"| node_detail_view
node_detail_view -->|"composes"| node_back_button
node_detail_view -->|"isolates failures"| node_error_boundary
node_error_boundary -->|"renders lazily"| node_product_card
node_product_card -->|"add-to-cart callback"| node_host_app
node_product_card -.->|"uses props"| node_remote_contracts
node_detail_view -->|"requests remote module"| node_federation_runtime
node_federation_runtime -->|"loads ./ProductCard"| node_product_card
node_remote_entry -.->|"standalone mount"| node_product_card
node_compose -->|"runs host"| node_host_image
node_compose -->|"runs remote first"| node_remote_image
node_remote_image -->|"serves remoteEntry.js and chunks"| node_federation_runtime

click node_host_entry "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/main.tsx"
click node_host_app "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/App.tsx"
click node_catalog_data "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/data/products.ts"
click node_host_contracts "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/types/index.ts"
click node_catalog_view "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/ProductListView.tsx"
click node_product_list "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/ProductList.tsx"
click node_host_chrome "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/Header.tsx"
click node_detail_view "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/ProductDetailsView.tsx"
click node_error_boundary "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/ErrorBoundary.tsx"
click node_back_button "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/BackButton.tsx"
click node_remote_entry "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/remote/src/main.tsx"
click node_product_card "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/remote/src/components/ProductCard.tsx"
click node_remote_contracts "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/remote/src/types/index.ts"
click node_federation_runtime "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/vite.config.ts"
click node_host_image "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/Dockerfile"
click node_remote_image "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/remote/Dockerfile"
click node_compose "https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/docker-compose.yml"

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_host_entry,node_host_app,node_catalog_data,node_host_contracts,node_catalog_view,node_product_list,node_host_chrome,node_detail_view,node_error_boundary,node_back_button toneBlue
class node_remote_entry,node_product_card,node_remote_contracts toneAmber
class node_host_image,node_remote_image,node_compose toneMint
class node_federation_runtime toneNeutral
```

## Components

### Host application

Owns catalog navigation and cart state.

- [Host browser entry](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/main.tsx): React entry · `host/src/main.tsx`
- [Host app controller](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/App.tsx): React state boundary · Controls selected product and cart count. · `host/src/App.tsx`
- [Catalog products](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/data/products.ts): catalog data · `host/src/data/products.ts`
- [Product contracts](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/types/index.ts): TypeScript types · `host/src/types/index.ts`
- [Catalog view](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/ProductListView.tsx): React view · `host/src/components/ProductListView.tsx`
- [Product list](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/ProductList.tsx): React component · Emits product selection. · `host/src/components/ProductList.tsx`
- [Header and footer](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/Header.tsx): host chrome · Header displays the host cart count. · `host/src/components/Header.tsx`
- [Detail integration view](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/ProductDetailsView.tsx): federation consumer · Lazy-loads and renders the remote card. · `host/src/components/ProductDetailsView.tsx`
- [Remote error boundary](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/ErrorBoundary.tsx): React boundary · `host/src/components/ErrorBoundary.tsx`
- [Back navigation](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/src/components/BackButton.tsx): React component · `host/src/components/BackButton.tsx`

### Remote application

Supplies the federated product detail card.

- [Remote browser entry](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/remote/src/main.tsx): React entry · `remote/src/main.tsx`
- [Product card](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/remote/src/components/ProductCard.tsx): federated React module · Receives product props and invokes add-to-cart callback. · `remote/src/components/ProductCard.tsx`
- [Remote card props](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/remote/src/types/index.ts): TypeScript types · `remote/src/types/index.ts`

### Build and delivery

Independent static builds served through Nginx.

- [Host image and Nginx](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/Dockerfile): containerized static host · `host/Dockerfile`
- [Remote image and Nginx](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/remote/Dockerfile): containerized static remote · Serves federation assets with cross-origin access. · `remote/Dockerfile`
- [Docker Compose](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/docker-compose.yml): service orchestration · Starts host with a dependency on remote. · `docker-compose.yml`

### Other components

- [Federation runtime](https://github.com/dimuthu7/micro-frontend-with-react-vite/blob/main/host/vite.config.ts): Vite Module Federation · Loads remoteEntry.js and shared React singletons. · `host/vite.config.ts`

## Connections

- Host browser entry → Host app controller: mounts
- Host app controller → Catalog products: reads
- Host app controller → Product contracts: uses
- Host app controller → Catalog view: renders catalog
- Catalog view → Product list: composes
- Product list → Host app controller: selects product
- Host app controller → Header and footer: supplies cart count
- Host app controller → Detail integration view: renders detail
- Detail integration view → Back navigation: composes
- Detail integration view → Remote error boundary: isolates failures
- Remote error boundary → Product card: renders lazily
- Product card → Host app controller: add-to-cart callback
- Product card → Remote card props: uses props
- Detail integration view → Federation runtime: requests remote module
- Federation runtime → Product card: loads ./ProductCard
- Remote browser entry → Product card: standalone mount
- Docker Compose → Host image and Nginx: runs host
- Docker Compose → Remote image and Nginx: runs remote first
- Remote image and Nginx → Federation runtime: serves remoteEntry.js and chunks
