How gsoutfit/gsoutfit-web works
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: page.tsx Shop, product & checkout · Providers.tsx Provider composition · layout.tsx App shell & home · products-db.ts Commerce repositories
Components 21
Storefront
- App shell & home
src/app/layout.tsx - Shop, product & checkout
src/app/shop/page.tsx - Commerce UI
src/components/Navbar.tsx - SEO metadata
src/app/robots.ts
Client State
- Provider composition
src/components/Providers.tsx - Auth state
src/context/AuthContext.tsx - Cart state
src/context/CartContext.tsx - Language state
src/context/LanguageContext.tsx
Commerce Server
- Catalog APIs · Products, categories, coupons, and reviews.
src/app/api/products/route.ts - Orders & checkout API · Checkout is the payment verification boundary.
src/app/api/orders/route.ts - Customer auth API
src/app/api/auth/login/route.ts - Commerce repositories
src/lib/products-db.ts - Database access
src/lib/db.ts - Managed data
data/db.json - Auth & sessions · Session verification depends on SESSION_SECRET.
src/lib/auth.ts - Request gate · Applies route and session policy before protected routes.
src/middleware.ts
Admin Operations
- Admin suite · Operations for inventory, orders, customers, marketing, security, and settings.
src/app/admin/layout.tsx - Admin control APIs
src/app/api/admin/register/route.ts
Platform
- Mail service
src/lib/mail.ts - Translation catalog
src/lib/translations.ts - Vercel deployment
vercel.json
Connections 24
- 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