# gsoutfit/gsoutfit-web architecture

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

- Interactive diagram: https://gitdiagram.com/gsoutfit/gsoutfit-web
- Repository: https://github.com/gsoutfit/gsoutfit-web

## Overview

#### 1. System Purpose and Runtime
Gentleman Savage is a full-stack Bangladesh-focused luxury menswear e-commerce application: storefront browsing, cart and checkout, account access, order management, and an executive admin suite. It runs on Next.js 15 App Router with React 19, TypeScript, Tailwind, and Vercel-oriented deployment. Primary bootstrap and application shell are `src/app/layout.tsx`, `src/app/page.tsx`, and `next.config.ts`.

#### 2. Storefront Route Layer
Customer entry points are App Router pages for shop discovery, product detail, categories, cart, checkout, and accounts: `src/app/shop/page.tsx`, `src/app/product/[id]/page.tsx`, `src/app/checkout/page.tsx`. Shared navigation and commerce interaction surfaces are rooted in `src/components/Navbar.tsx`, `src/components/CartDrawer.tsx`, and `src/components/ProductCard.tsx`. SEO endpoints are implemented as route metadata handlers in `src/app/robots.ts` and `src/app/sitemap.ts`.

#### 3. Client Commerce State and UX Providers
Application-wide client state is supplied through the provider composition at `src/components/Providers.tsx`. Separate contexts own authenticated identity, cart contents, wishlist/compare lists, language, theme, recently viewed products, and toast messages; core examples are `src/context/AuthContext.tsx`, `src/context/CartContext.tsx`, and `src/context/LanguageContext.tsx`. UI actions flow from pages/components into these contexts, then call API routes or browser-persisted state as applicable.

#### 4. Commerce Domain APIs and Persistence Boundary
Route handlers form the server boundary for product catalog, categories, coupons, reviews, orders, and analytics. Primary endpoints include `src/app/api/products/route.ts`, `src/app/api/orders/route.ts`, and `src/app/api/coupons/validate/route.ts`; item-level mutations use dynamic handlers such as `src/app/api/products/[id]/route.ts` and `src/app/api/orders/[id]/route.ts`. Domain-specific repositories isolate data access in `src/lib/products-db.ts`, `src/lib/orders-db.ts`, and `src/lib/coupons-db.ts`, backed by shared database modules `src/lib/db.ts` / `src/lib/pg.ts`; `data/db.json` is present as repository-managed data.

#### 5. Authentication and Security Control Plane
Customer auth exposes registration, login, logout, and current-user endpoints under `src/app/api/auth/login/route.ts`, `src/app/api/auth/register/route.ts`, and `src/app/api/auth/me/route.ts`. Authentication primitives and server-side session verification are separated into `src/lib/auth.ts` and `src/lib/server-auth.ts`. `src/middleware.ts` is the cross-cutting request gate, expected to enforce route/session policy and security behavior before protected admin or application routes execute. Session security depends on `SESSION_SECRET`.

#### 6. Admin Operations
The `/admin` route tree supplies administrative login/registration/verification plus operations dashboards for inventory, orders, customers, marketing, security, and settings: `src/app/admin/layout.tsx`, `src/app/admin/products/page.tsx`, and `src/app/admin/orders/page.tsx`. Its server control endpoints cover administrator lifecycle and customer/security management in `src/app/api/admin/register/route.ts`, `src/app/api/admin/verify-registration/route.ts`, and `src/app/api/admin/security/route.ts`. Operational configuration, including theme settings and email diagnostics/logging, is served through `src/app/api/settings/route.ts` and `src/app/api/mail/test/route.ts`.

#### 7. External Integrations and Deployment
Payment behavior targets COD plus bKash and Nagad transfer/transaction-ID verification, but no dedicated provider integration paths are visible; checkout/order APIs are the integration boundary. Mailing is abstracted through `src/lib/mail.ts` and exposed via mail APIs. Localization uses the application translation catalog `src/lib/translations.ts`. Deployment is configured for Vercel through `vercel.json`; environment setup is documented by `.env.example`.

Main entry points: [`src/app/shop/page.tsx`](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/shop/page.tsx) (Shop, product & checkout), [`src/components/Providers.tsx`](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/components/Providers.tsx) (Provider composition), [`src/app/layout.tsx`](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/layout.tsx) (App shell & home), [`src/lib/products-db.ts`](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/products-db.ts) (Commerce repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_app_shell["App shell &amp; home<br/>Next.js App Router<br/>[layout.tsx]"]
  node_storefront_pages["Shop, product &amp; checkout<br/>customer pages<br/>[page.tsx]"]
  node_commerce_ui["Commerce UI<br/>shared components<br/>[Navbar.tsx]"]
  node_seo_routes["SEO metadata<br/>route handlers<br/>[robots.ts]"]
end

subgraph group_client["Client State"]
  node_providers["Provider composition<br/>React providers<br/>[Providers.tsx]"]
  node_auth_state["Auth state<br/>client context<br/>[AuthContext.tsx]"]
  node_cart_state["Cart state<br/>client context<br/>[CartContext.tsx]"]
  node_language_state["Language state<br/>client context"]
end

subgraph group_server["Commerce Server"]
  node_catalog_api["Catalog APIs<br/>route handlers<br/>[route.ts]"]
  node_orders_api["Orders &amp; checkout API<br/>route handlers<br/>[route.ts]"]
  node_auth_api["Customer auth API<br/>route handlers<br/>[route.ts]"]
  node_commerce_repositories["Commerce repositories<br/>data access<br/>[products-db.ts]"]
  node_database[("Database access<br/>shared persistence<br/>[db.ts]")]
  node_managed_data[("Managed data<br/>repository data<br/>[db.json]")]
  node_auth_security["Auth &amp; sessions<br/>security primitives<br/>[auth.ts]"]
  node_request_gate{{"Request gate<br/>middleware<br/>[middleware.ts]"}}
end

subgraph group_admin["Admin Operations"]
  node_admin_suite["Admin suite<br/>admin route tree<br/>[layout.tsx]"]
  node_admin_api["Admin control APIs<br/>route handlers<br/>[route.ts]"]
end

subgraph group_platform["Platform"]
  node_mailing["Mail service<br/>mail abstraction<br/>[mail.ts]"]
  node_translations["Translation catalog<br/>localization<br/>[translations.ts]"]
  node_deployment{{"Vercel deployment<br/>deployment config<br/>[vercel.json]"}}
end

node_app_shell -->|"renders"| node_storefront_pages
node_app_shell -->|"composes"| node_providers
node_storefront_pages -->|"uses"| node_commerce_ui
node_commerce_ui -->|"updates"| node_cart_state
node_storefront_pages -->|"uses"| node_auth_state
node_providers -->|"provides"| node_auth_state
node_providers -->|"provides"| node_cart_state
node_providers -->|"provides"| node_language_state
node_language_state -->|"selects"| node_translations
node_storefront_pages -->|"reads catalog"| node_catalog_api
node_cart_state -->|"submits checkout"| node_orders_api
node_auth_state -->|"signs in"| node_auth_api
node_catalog_api -->|"queries"| node_commerce_repositories
node_orders_api -->|"persists orders"| node_commerce_repositories
node_commerce_repositories -->|"uses"| node_database
node_database -.->|"backs"| node_managed_data
node_auth_api -->|"verifies sessions"| node_auth_security
node_request_gate -->|"enforces policy with"| node_auth_security
node_request_gate -->|"protects"| node_admin_suite
node_admin_suite -->|"operates through"| node_admin_api
node_admin_api -->|"manages commerce data"| node_commerce_repositories
node_admin_api -->|"uses"| node_mailing
node_app_shell -.->|"publishes"| node_seo_routes
node_deployment -->|"deploys"| node_app_shell

click node_app_shell "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/layout.tsx"
click node_storefront_pages "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/shop/page.tsx"
click node_commerce_ui "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/components/Navbar.tsx"
click node_seo_routes "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/robots.ts"
click node_providers "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/components/Providers.tsx"
click node_auth_state "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/context/AuthContext.tsx"
click node_cart_state "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/context/CartContext.tsx"
click node_language_state "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/context/LanguageContext.tsx"
click node_catalog_api "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/api/products/route.ts"
click node_orders_api "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/api/orders/route.ts"
click node_auth_api "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/api/auth/login/route.ts"
click node_commerce_repositories "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/products-db.ts"
click node_database "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/db.ts"
click node_managed_data "https://github.com/gsoutfit/gsoutfit-web/blob/main/data/db.json"
click node_auth_security "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/auth.ts"
click node_request_gate "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/middleware.ts"
click node_admin_suite "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/admin/layout.tsx"
click node_admin_api "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/api/admin/register/route.ts"
click node_mailing "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/mail.ts"
click node_translations "https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/translations.ts"
click node_deployment "https://github.com/gsoutfit/gsoutfit-web/blob/main/vercel.json"

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_app_shell,node_storefront_pages,node_commerce_ui,node_seo_routes toneBlue
class node_providers,node_auth_state,node_cart_state,node_language_state toneAmber
class node_catalog_api,node_orders_api,node_auth_api,node_commerce_repositories,node_database,node_managed_data,node_auth_security,node_request_gate toneMint
class node_admin_suite,node_admin_api toneRose
class node_mailing,node_translations,node_deployment toneIndigo
```

## Components

### Storefront

- [App shell & home](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/layout.tsx): Next.js App Router · `src/app/layout.tsx`
- [Shop, product & checkout](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/shop/page.tsx): customer pages · `src/app/shop/page.tsx`
- [Commerce UI](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/components/Navbar.tsx): shared components · `src/components/Navbar.tsx`
- [SEO metadata](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/robots.ts): route handlers · `src/app/robots.ts`

### Client State

- [Provider composition](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/components/Providers.tsx): React providers · `src/components/Providers.tsx`
- [Auth state](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/context/AuthContext.tsx): client context · `src/context/AuthContext.tsx`
- [Cart state](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/context/CartContext.tsx): client context · `src/context/CartContext.tsx`
- [Language state](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/context/LanguageContext.tsx): client context · `src/context/LanguageContext.tsx`

### Commerce Server

- [Catalog APIs](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/api/products/route.ts): route handlers · Products, categories, coupons, and reviews. · `src/app/api/products/route.ts`
- [Orders & checkout API](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/api/orders/route.ts): route handlers · Checkout is the payment verification boundary. · `src/app/api/orders/route.ts`
- [Customer auth API](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/api/auth/login/route.ts): route handlers · `src/app/api/auth/login/route.ts`
- [Commerce repositories](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/products-db.ts): data access · `src/lib/products-db.ts`
- [Database access](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/db.ts): shared persistence · `src/lib/db.ts`
- [Managed data](https://github.com/gsoutfit/gsoutfit-web/blob/main/data/db.json): repository data · `data/db.json`
- [Auth & sessions](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/auth.ts): security primitives · Session verification depends on SESSION_SECRET. · `src/lib/auth.ts`
- [Request gate](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/middleware.ts): middleware · Applies route and session policy before protected routes. · `src/middleware.ts`

### Admin Operations

- [Admin suite](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/admin/layout.tsx): admin route tree · Operations for inventory, orders, customers, marketing, security, and settings. · `src/app/admin/layout.tsx`
- [Admin control APIs](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/app/api/admin/register/route.ts): route handlers · `src/app/api/admin/register/route.ts`

### Platform

- [Mail service](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/mail.ts): mail abstraction · `src/lib/mail.ts`
- [Translation catalog](https://github.com/gsoutfit/gsoutfit-web/blob/main/src/lib/translations.ts): localization · `src/lib/translations.ts`
- [Vercel deployment](https://github.com/gsoutfit/gsoutfit-web/blob/main/vercel.json): deployment config · `vercel.json`

## Connections

- App shell & home → Shop, product & checkout: renders
- App shell & home → Provider composition: composes
- Shop, product & checkout → Commerce UI: uses
- Commerce UI → Cart state: updates
- Shop, product & checkout → Auth state: uses
- Provider composition → Auth state: provides
- Provider composition → Cart state: provides
- Provider composition → Language state: provides
- Language state → Translation catalog: selects
- Shop, product & checkout → Catalog APIs: reads catalog
- Cart state → Orders & checkout API: submits checkout
- Auth state → Customer auth API: signs in
- Catalog APIs → Commerce repositories: queries
- Orders & checkout API → Commerce repositories: persists orders
- Commerce repositories → Database access: uses
- Database access → Managed data: backs
- Customer auth API → Auth & sessions: verifies sessions
- Request gate → Auth & sessions: enforces policy with
- Request gate → Admin suite: protects
- Admin suite → Admin control APIs: operates through
- Admin control APIs → Commerce repositories: manages commerce data
- Admin control APIs → Mail service: uses
- App shell & home → SEO metadata: publishes
- Vercel deployment → App shell & home: deploys
