# legialam-gif/ecogreen-ecommerce architecture

> Architecture diagram of the GitHub repository legialam-gif/ecogreen-ecommerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/legialam-gif/ecogreen-ecommerce
- Repository: https://github.com/legialam-gif/ecogreen-ecommerce

## Overview

EcoGreen is a Vietnamese storefront and admin UI for an eco-products shop, backed by a Spring Boot REST API (not included in the supplied tree). The customer journey runs from catalogue browsing and account/cart use through checkout, simulated payment, order tracking and returns; staff manage products, categories, orders, returns, users and sales reporting. The graph focuses on frontend runtime responsibilities and its REST boundary. Some connections are based on explicit README or SOURCE INDEX references; unsampled feature internals are represented at their exact directory paths.

Main entry points: [`frontend/src/App.jsx`](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/App.jsx) (Routes and shell), [`frontend/src/services/orderApi.js`](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/orderApi.js) (Order API), [`frontend/src/pages/Checkout.jsx`](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Checkout.jsx) (Checkout), [`frontend/src/context/AuthContext.jsx`](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/context/AuthContext.jsx) (Session context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_catalog["Product catalogue<br/>[Home.jsx]"]
  node_product["Product details<br/>[ProductDetail.jsx]"]
  node_cartui["Shopping cart<br/>[Cart.jsx]"]
  node_cartstate["Server cart state<br/>[CartContext.jsx]"]
  node_help["Help and policies"]
end

subgraph group_customer["Customer accounts"]
  node_authui["Sign in / register<br/>[Login.jsx]"]
  node_authstate["Session context<br/>[AuthContext.jsx]"]
  node_authstorage["Token storage<br/>[authStorage.js]"]
  node_google["Google sign-in<br/>[googleAuth.js]"]
  node_addresses["Address book<br/>[Addresses.jsx]"]
end

subgraph group_fulfillment["Order fulfillment"]
  node_checkout["Checkout<br/>[Checkout.jsx]"]
  node_orders["Order history<br/>[Orders.jsx]"]
  node_orderdetail["Order details / returns<br/>[OrderDetail.jsx]"]
  node_payment["Simulated payment<br/>[Payment.jsx]"]
  node_payreturn["Payment return<br/>[PaymentReturn.jsx]"]
end

subgraph group_management["Administration"]
  node_admin["Admin workspace<br/>[AdminDashboard.jsx]"]
  node_sales["Sales reporting<br/>[SalesDashboard.jsx]"]
end

subgraph group_shared["Shared frontend"]
  node_app["Routes and shell<br/>[App.jsx]"]
  node_cartapi["Cart API<br/>[cartApi.js]"]
  node_orderapi["Order API<br/>[orderApi.js]"]
  node_paymentapi["Payment API<br/>[paymentApi.js]"]
  node_adminservices["Admin API services"]
  node_http["HTTP client / refresh<br/>[http.js]"]
end

node_browser(("Shopper / staff"))
node_rest["Spring REST API"]
node_database[("PostgreSQL")]

node_browser -->|"navigates"| node_app
node_app -->|"routes to"| node_catalog
node_app -->|"routes to"| node_product
node_app -->|"routes to"| node_cartui
node_app -->|"routes to"| node_authui
node_app -->|"protects route"| node_checkout
node_app -->|"protects route"| node_payment
node_app -->|"protects route"| node_payreturn
node_app -->|"protects route"| node_orders
node_app -->|"protects route"| node_orderdetail
node_app -->|"protects route"| node_addresses
node_app -->|"admin route"| node_admin
node_app -->|"routes to"| node_help
node_catalog -.->|"fetches catalogue"| node_rest
node_product -.->|"fetches product"| node_rest
node_cartui -->|"uses cart"| node_cartstate
node_cartstate -->|"fetches and updates"| node_cartapi
node_authui -->|"signs in"| node_authstate
node_authui -->|"requests ID token"| node_google
node_authstate -->|"stores session"| node_authstorage
node_authstate -.->|"validates session"| node_rest
node_google -->|"passes ID token"| node_authstate
node_addresses -.->|"manages addresses"| node_rest
node_checkout -->|"previews and submits"| node_orderapi
node_checkout -->|"selects address"| node_addresses
node_checkout -->|"resets after checkout"| node_cartstate
node_orderapi -->|"sends order requests"| node_rest
node_payment -->|"loads order"| node_orderapi
node_payment -->|"manages payment"| node_paymentapi
node_payreturn -->|"checks payment"| node_paymentapi
node_paymentapi -->|"sends payment requests"| node_rest
node_orders -.->|"loads history"| node_orderapi
node_orderdetail -->|"loads and cancels"| node_orderapi
node_orderdetail -.->|"requests returns"| node_adminservices
node_admin -->|"manages shop data"| node_adminservices
node_admin -->|"renders dashboard"| node_sales
node_sales -->|"loads reports"| node_adminservices
node_adminservices -.->|"uses client"| node_http
node_cartapi -.->|"uses client"| node_http
node_http -->|"sends authenticated requests"| node_rest
node_rest -.->|"reads and writes"| node_database

click node_app "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/App.jsx"
click node_catalog "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Home.jsx"
click node_product "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/ProductDetail.jsx"
click node_cartui "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Cart.jsx"
click node_cartstate "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/context/CartContext.jsx"
click node_cartapi "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/cartApi.js"
click node_authui "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Login.jsx"
click node_authstate "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/context/AuthContext.jsx"
click node_authstorage "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/authStorage.js"
click node_google "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/googleAuth.js"
click node_addresses "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Addresses.jsx"
click node_checkout "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Checkout.jsx"
click node_orders "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Orders.jsx"
click node_orderdetail "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/OrderDetail.jsx"
click node_payment "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Payment.jsx"
click node_payreturn "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/PaymentReturn.jsx"
click node_orderapi "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/orderApi.js"
click node_paymentapi "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/paymentApi.js"
click node_admin "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/admin/AdminDashboard.jsx"
click node_sales "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/admin/SalesDashboard.jsx"
click node_adminservices "https://github.com/legialam-gif/ecogreen-ecommerce/tree/main/frontend/src/services"
click node_http "https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/http.js"
click node_help "https://github.com/legialam-gif/ecogreen-ecommerce/tree/main/frontend/src/pages"

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_catalog,node_product,node_cartui,node_cartstate,node_help toneBlue
class node_authui,node_authstate,node_authstorage,node_google,node_addresses,node_database toneAmber
class node_checkout,node_orders,node_orderdetail,node_payment,node_payreturn,node_rest toneMint
class node_admin,node_sales toneRose
class node_app,node_cartapi,node_orderapi,node_paymentapi,node_adminservices,node_http,node_browser toneIndigo
```

## Components

### Storefront

- [Product catalogue](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Product details](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/ProductDetail.jsx): `frontend/src/pages/ProductDetail.jsx`
- [Shopping cart](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Cart.jsx): `frontend/src/pages/Cart.jsx`
- [Server cart state](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/context/CartContext.jsx): `frontend/src/context/CartContext.jsx`
- [Help and policies](https://github.com/legialam-gif/ecogreen-ecommerce/tree/main/frontend/src/pages): `frontend/src/pages`

### Customer accounts

- [Sign in / register](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Session context](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Token storage](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/authStorage.js): `frontend/src/services/authStorage.js`
- [Google sign-in](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/googleAuth.js): `frontend/src/services/googleAuth.js`
- [Address book](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Addresses.jsx): `frontend/src/pages/Addresses.jsx`

### Order fulfillment

- [Checkout](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Checkout.jsx): `frontend/src/pages/Checkout.jsx`
- [Order history](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Orders.jsx): `frontend/src/pages/Orders.jsx`
- [Order details / returns](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/OrderDetail.jsx): `frontend/src/pages/OrderDetail.jsx`
- [Simulated payment](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/Payment.jsx): `frontend/src/pages/Payment.jsx`
- [Payment return](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/PaymentReturn.jsx): `frontend/src/pages/PaymentReturn.jsx`

### Administration

- [Admin workspace](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/admin/AdminDashboard.jsx): `frontend/src/pages/admin/AdminDashboard.jsx`
- [Sales reporting](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/pages/admin/SalesDashboard.jsx): `frontend/src/pages/admin/SalesDashboard.jsx`

### Shared frontend

- [Routes and shell](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Cart API](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/cartApi.js): `frontend/src/services/cartApi.js`
- [Order API](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/orderApi.js): `frontend/src/services/orderApi.js`
- [Payment API](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/paymentApi.js): `frontend/src/services/paymentApi.js`
- [Admin API services](https://github.com/legialam-gif/ecogreen-ecommerce/tree/main/frontend/src/services): `frontend/src/services`
- [HTTP client / refresh](https://github.com/legialam-gif/ecogreen-ecommerce/blob/main/frontend/src/services/http.js): `frontend/src/services/http.js`

### Other components

- **Shopper / staff**
- **Spring REST API**
- **PostgreSQL**

## Connections

- Shopper / staff → Routes and shell: navigates (evidence: `frontend/src/App.jsx`)
- Routes and shell → Product catalogue: routes to (evidence: `frontend/src/App.jsx`)
- Routes and shell → Product details: routes to (evidence: `frontend/src/App.jsx`)
- Routes and shell → Shopping cart: routes to (evidence: `frontend/src/App.jsx`)
- Routes and shell → Sign in / register: routes to (evidence: `frontend/src/App.jsx`)
- Routes and shell → Checkout: protects route (evidence: `frontend/src/App.jsx`)
- Routes and shell → Simulated payment: protects route (evidence: `frontend/src/App.jsx`)
- Routes and shell → Payment return: protects route (evidence: `frontend/src/App.jsx`)
- Routes and shell → Order history: protects route (evidence: `frontend/src/App.jsx`)
- Routes and shell → Order details / returns: protects route (evidence: `frontend/src/App.jsx`)
- Routes and shell → Address book: protects route (evidence: `frontend/src/App.jsx`)
- Routes and shell → Admin workspace: admin route (evidence: `frontend/src/App.jsx`)
- Routes and shell → Help and policies: routes to (evidence: `frontend/src/App.jsx`)
- Product catalogue → Spring REST API: fetches catalogue (evidence: `README.md`)
- Product details → Spring REST API: fetches product (evidence: `README.md`)
- Shopping cart → Server cart state: uses cart (evidence: `frontend/src/pages/Cart.jsx`)
- Server cart state → Cart API: fetches and updates (evidence: `frontend/src/context/CartContext.jsx`)
- Sign in / register → Session context: signs in (evidence: `frontend/src/pages/Login.jsx`)
- Sign in / register → Google sign-in: requests ID token (evidence: `frontend/src/pages/Login.jsx`)
- Session context → Token storage: stores session (evidence: `frontend/src/context/AuthContext.jsx`)
- Session context → Spring REST API: validates session (evidence: `README.md`)
- Google sign-in → Session context: passes ID token (evidence: `frontend/src/services/googleAuth.js`)
- Address book → Spring REST API: manages addresses (evidence: `README.md`)
- Checkout → Order API: previews and submits (evidence: `frontend/src/pages/Checkout.jsx`)
- Checkout → Address book: selects address (evidence: `frontend/src/pages/Checkout.jsx`)
- Checkout → Server cart state: resets after checkout (evidence: `frontend/src/context/CartContext.jsx`)
- Order API → Spring REST API: sends order requests (evidence: `frontend/src/services/orderApi.js`)
- Simulated payment → Order API: loads order (evidence: `frontend/src/pages/Payment.jsx`)
- Simulated payment → Payment API: manages payment (evidence: `frontend/src/pages/Payment.jsx`)
- Payment return → Payment API: checks payment (evidence: `frontend/src/pages/PaymentReturn.jsx`)
- Payment API → Spring REST API: sends payment requests (evidence: `frontend/src/services/paymentApi.js`)
- Order history → Order API: loads history
- Order details / returns → Order API: loads and cancels (evidence: `frontend/src/pages/OrderDetail.jsx`)
- Order details / returns → Admin API services: requests returns (evidence: `frontend/src/pages/OrderDetail.jsx`)
- Admin workspace → Admin API services: manages shop data (evidence: `frontend/src/pages/admin/AdminDashboard.jsx`)
- Admin workspace → Sales reporting: renders dashboard (evidence: `frontend/src/pages/admin/AdminDashboard.jsx`)
- Sales reporting → Admin API services: loads reports (evidence: `frontend/src/pages/admin/SalesDashboard.jsx`)
- Admin API services → HTTP client / refresh: uses client (evidence: `frontend/src/services/orderApi.js`)
- Cart API → HTTP client / refresh: uses client
- HTTP client / refresh → Spring REST API: sends authenticated requests (evidence: `frontend/src/services/http.js`)
- Spring REST API → PostgreSQL: reads and writes (evidence: `README.md`)
