# zahidrajudev/next-gmn architecture

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

- Interactive diagram: https://gitdiagram.com/zahidrajudev/next-gmn
- Repository: https://github.com/zahidrajudev/next-gmn

## Overview

1. This repository is a Next.js application organized around the older `pages/` router, with a large shared UI/component layer and many route-level feature pages. It appears to power a content/media-oriented platform with public marketing pages, commerce/checkout flows, and a multi-role dashboard.

2. The application boundary is mostly frontend: page files under `pages/` assemble screens, while reusable presentation and interaction logic lives under `components/`, `layouts/`, `hooks/`, and `lib/`. A small `pages/api/` area and a top-level `server.js` suggest there is at least one custom Node server endpoint or server wrapper, but the bulk of the repo is client-facing UI.

3. There are three major route surfaces:
   - Public site pages such as home, about, services, news, shop, live/video pages, policy pages, and contact/help pages.
   - Authentication and checkout pages for login/register, email verification, password reset, and payment status/checkout.
   - A large authenticated dashboard area under `pages/dashboard/` with many subdomains for news/article management, media, payments, subscriptions, promotion, users/roles, settings, and versioned dashboard variants (`v2`, `v3`, `v4`, `v5`).

4. Layout composition is role-based. The `layouts/` folder contains separate shells for the main public site and several dashboard personas: affiliate, author, team, user dashboard, and a general dashboard layout. These layouts likely define the persistent chrome—headers, sidebars, footers, and content framing—while individual pages provide the inner content.

5. The shared component system is the core architectural layer. `components/elements/` contains generic UI primitives such as buttons, modals, drawers, tables, pagination, breadcrumbs, accordions, loading states, and router links. Higher-level blocks like headers, footers, sidebars, widgets, and partials build on those primitives to create reusable page sections.

6. State and app-wide coordination are concentrated in custom hooks and context:
   - `components/AppContext.jsx` and `hooks/appService.ts` indicate shared application state and service wiring.
   - `hooks/lan_theme_currency_cart.ts` suggests global preferences such as language, theme, currency, and cart-like state.
   - `hooks/global_media_gallery.tsx` provides a cross-page media selection/gallery mechanism.
   - `hooks/tracking/` contains viewport and size-tracking utilities used by UI behavior and animation logic.

7. API/data access is abstracted through `lib/`. The presence of `lib/api.js`, `lib/admin_api.js`, and `lib/user_api.js` implies the app talks to different backend surfaces or permission tiers. Pages and hooks likely call these helpers rather than hitting network endpoints directly, which keeps page components thin and centralizes authentication/role-specific request logic.

8. Checkout and payments are their own subsystem. Under `components/checkout/` are separate integrations for Stripe, bKash, and Nagad, plus add-card/subscription flows and backups. This is mirrored by dashboard payment pages for gateway management, transactions, affiliate earnings/payouts, and subscription logs, indicating a split between customer-facing checkout and admin/payment operations.

9. The dashboard is not a single monolith; it is organized by functional domains. Major admin areas include news/articles, products, press releases, packages/add-ons, media management, roles/users, email config, language, subscriptions, promotions, and AI-related `gmnai` pages. The `v2`–`v5` dashboards suggest iterative UI generations or product lines that coexist in the same codebase.

10. Media and content workflows are first-class. There are pages for news editing, article creation, media libraries, trash/folder management, press content, live episodes, and brand/product archives. Shared components like uploaders, image boxes, media areas, and archive widgets show that content selection and asset reuse are core flows in the application.

11. Several specialized UI integrations are present but remain bounded in their own components:
   - `components/partial/echart.tsx` for charting/analytics.
   - `components/elements/map_libre.tsx` for map rendering.
   - `components/partial/gtranslate.tsx` for translation.
   - Animation helpers and sliders for richer marketing pages.
   These are treated as reusable capabilities rather than page-level concerns.

12. Static assets are extensive and domain-specific. The `public/` tree contains branded media, flags, logos, and many topic-specific image folders for home/about/news/live/promotion/service/write flows. This indicates the frontend relies heavily on local static media rather than dynamically generated imagery.

13. Styling and build tooling are standard Next.js ecosystem pieces: `tailwind.config.js`, `postcss.config.mjs`, `styles/globals.css`, TypeScript configuration, and the Next.js app/document bootstrap files. The stack mixes `.tsx`, `.jsx`, and `.js`, which suggests an incremental migration rather than a fully uniform TypeScript codebase.

14. For an architecture diagram, the most important boundaries are: public site vs authenticated dashboard; shared UI library vs page composition; local state/context/hooks vs remote API helpers; and checkout/payment providers vs in-app order/subscription management. The app is fundamentally a modular frontend shell over multiple content, commerce, and admin workflows.

Main entry points: [`pages/dashboard/index.tsx`](https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/index.tsx) (Dashboard shell), [`pages/index.tsx`](https://github.com/zahidrajudev/next-gmn/blob/main/pages/index.tsx) (Public pages), [`lib/api.js`](https://github.com/zahidrajudev/next-gmn/blob/main/lib/api.js) (API clients), [`layouts/MainLayout.tsx`](https://github.com/zahidrajudev/next-gmn/blob/main/layouts/MainLayout.tsx) (Layouts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared["Shared app layer"]
  node_server["Server entry<br/>Node server<br/>[server.js]"]
  node_app_boot["App bootstrap<br/>Next app<br/>[_app.tsx]"]
  node_ui_kit["UI kit<br/>components<br/>[button.tsx]"]
  node_shells["Layouts<br/>shells<br/>[MainLayout.tsx]"]
  node_state_hooks["State hooks<br/>[appService.ts]"]
  node_api_clients["API clients<br/>data access<br/>[api.js]"]
end

subgraph group_public["Public site"]
  node_site_pages["Public pages<br/>route surface<br/>[index.tsx]"]
  node_content_routes["Content routes<br/>[[...slug].tsx]"]
  node_commerce_routes["Shop pages<br/>commerce routes<br/>[index.tsx]"]
end

subgraph group_account["Auth and commerce"]
  node_auth_pages["Auth pages<br/>auth routes<br/>[index.tsx]"]
  node_checkout_flow["Checkout flow<br/>commerce flow<br/>[index.tsx]"]
  node_checkout_providers["Payment providers<br/>payments<br/>[index.tsx]"]
end

subgraph group_dashboard["Dashboards"]
  node_dashboard_home["Dashboard shell<br/>admin workspace<br/>[index.tsx]"]
  node_content_admin["Content admin<br/>admin content<br/>[index.tsx]"]
  node_media_admin["Media library<br/>asset management<br/>[index.tsx]"]
  node_payments_admin["Payments admin<br/>finance ops<br/>[index.tsx]"]
  node_marketing_admin["Promotion admin<br/>growth ops<br/>[index.tsx]"]
  node_people_admin["Users and roles<br/>access control<br/>[index.tsx]"]
  node_variant_dashboards["Dashboard variants<br/>alternate dashboards<br/>[index.tsx]"]
end

node_app_boot -->|"renders"| node_site_pages
node_app_boot -->|"renders"| node_auth_pages
node_app_boot -->|"renders"| node_dashboard_home
node_site_pages -->|"uses"| node_shells
node_content_routes -->|"uses"| node_shells
node_commerce_routes -->|"uses"| node_shells
node_auth_pages -->|"uses"| node_state_hooks
node_checkout_flow -->|"uses"| node_checkout_providers
node_checkout_flow -->|"calls"| node_api_clients
node_checkout_providers -->|"calls"| node_api_clients
node_dashboard_home -->|"routes to"| node_content_admin
node_dashboard_home -->|"routes to"| node_media_admin
node_dashboard_home -->|"routes to"| node_payments_admin
node_dashboard_home -->|"routes to"| node_marketing_admin
node_dashboard_home -->|"routes to"| node_people_admin
node_dashboard_home -->|"routes to"| node_variant_dashboards
node_content_admin -->|"uses"| node_ui_kit
node_media_admin -->|"uses"| node_ui_kit
node_payments_admin -->|"calls"| node_api_clients
node_marketing_admin -->|"calls"| node_api_clients
node_people_admin -->|"uses"| node_state_hooks
node_site_pages -->|"uses"| node_ui_kit
node_dashboard_home -->|"uses"| node_shells
node_dashboard_home -->|"uses"| node_state_hooks
node_site_pages -->|"calls"| node_api_clients
node_site_pages -.->|"served by"| node_server

click node_server "https://github.com/zahidrajudev/next-gmn/blob/main/server.js"
click node_app_boot "https://github.com/zahidrajudev/next-gmn/blob/main/pages/_app.tsx"
click node_ui_kit "https://github.com/zahidrajudev/next-gmn/blob/main/components/elements/button.tsx"
click node_shells "https://github.com/zahidrajudev/next-gmn/blob/main/layouts/MainLayout.tsx"
click node_state_hooks "https://github.com/zahidrajudev/next-gmn/blob/main/hooks/appService.ts"
click node_api_clients "https://github.com/zahidrajudev/next-gmn/blob/main/lib/api.js"
click node_site_pages "https://github.com/zahidrajudev/next-gmn/blob/main/pages/index.tsx"
click node_content_routes "https://github.com/zahidrajudev/next-gmn/blob/main/pages/news/[...slug].tsx"
click node_commerce_routes "https://github.com/zahidrajudev/next-gmn/blob/main/pages/shop/index.tsx"
click node_auth_pages "https://github.com/zahidrajudev/next-gmn/blob/main/pages/login/index.tsx"
click node_checkout_flow "https://github.com/zahidrajudev/next-gmn/blob/main/pages/checkout/index.tsx"
click node_checkout_providers "https://github.com/zahidrajudev/next-gmn/blob/main/components/checkout/stripe/index.tsx"
click node_dashboard_home "https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/index.tsx"
click node_content_admin "https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/news/index.tsx"
click node_media_admin "https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/media/index.tsx"
click node_payments_admin "https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/payments/gateway/index.tsx"
click node_marketing_admin "https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/promotion/index.tsx"
click node_people_admin "https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/user/index.tsx"
click node_variant_dashboards "https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/v2/index.tsx"

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_server,node_app_boot,node_ui_kit,node_shells,node_state_hooks,node_api_clients toneBlue
class node_site_pages,node_content_routes,node_commerce_routes toneAmber
class node_auth_pages,node_checkout_flow,node_checkout_providers toneMint
class node_dashboard_home,node_content_admin,node_media_admin,node_payments_admin,node_marketing_admin,node_people_admin,node_variant_dashboards toneRose
```

## Components

### Shared app layer

Reusable UI, state, and data access used across routes.

- [Server entry](https://github.com/zahidrajudev/next-gmn/blob/main/server.js): Node server · Custom Node wrapper and API endpoint surface. · `server.js`
- [App bootstrap](https://github.com/zahidrajudev/next-gmn/blob/main/pages/_app.tsx): Next app · Global Next.js bootstrapping and document wiring. · `pages/_app.tsx`
- [UI kit](https://github.com/zahidrajudev/next-gmn/blob/main/components/elements/button.tsx): components · Shared elements, inputs, icons, and reusable interaction primitives. · `components/elements/button.tsx`
- [Layouts](https://github.com/zahidrajudev/next-gmn/blob/main/layouts/MainLayout.tsx): shells · Main and role-based page chrome for public and dashboard areas. · `layouts/MainLayout.tsx`
- [State hooks](https://github.com/zahidrajudev/next-gmn/blob/main/hooks/appService.ts): hooks · Global app context, preferences, gallery state, and viewport tracking. · `hooks/appService.ts`
- [API clients](https://github.com/zahidrajudev/next-gmn/blob/main/lib/api.js): data access · Shared API helpers for public, admin, and user-tier requests. · `lib/api.js`

### Public site

Marketing, media, and public content surfaces.

- [Public pages](https://github.com/zahidrajudev/next-gmn/blob/main/pages/index.tsx): route surface · Home, about, services, media, policies, and content pages. · `pages/index.tsx`
- [Content routes](https://github.com/zahidrajudev/next-gmn/blob/main/pages/news/[...slug].tsx): content routes · News, episodes, live video, brand, and write-for-GMN pages. · `pages/news/[...slug].tsx`
- [Shop pages](https://github.com/zahidrajudev/next-gmn/blob/main/pages/shop/index.tsx): commerce routes · Shop catalog and item detail routes for public purchasing. · `pages/shop/index.tsx`

### Auth and commerce

Login, verification, checkout, and status flows.

- [Auth pages](https://github.com/zahidrajudev/next-gmn/blob/main/pages/login/index.tsx): auth routes · Login, register, email verification, password reset, and status pages. · `pages/login/index.tsx`
- [Checkout flow](https://github.com/zahidrajudev/next-gmn/blob/main/pages/checkout/index.tsx): commerce flow · Checkout and checkout status surfaces used by customers. · `pages/checkout/index.tsx`
- [Payment providers](https://github.com/zahidrajudev/next-gmn/blob/main/components/checkout/stripe/index.tsx): payments · Stripe, bKash, Nagad, add-card, and subscription checkout integrations. · `components/checkout/stripe/index.tsx`

### Dashboards

Authenticated admin and role-specific workspaces.

- [Dashboard shell](https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/index.tsx): admin workspace · Entry point for the authenticated dashboard and role-based variants. · `pages/dashboard/index.tsx`
- [Content admin](https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/news/index.tsx): admin content · News, articles, press releases, brand, product, and package management. · `pages/dashboard/news/index.tsx`
- [Media library](https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/media/index.tsx): asset management · Media browsing, uploads, trash, folders, and archive widgets. · `pages/dashboard/media/index.tsx`
- [Payments admin](https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/payments/gateway/index.tsx): finance ops · Gateways, transactions, earnings, payouts, and subscription logs. · `pages/dashboard/payments/gateway/index.tsx`
- [Promotion admin](https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/promotion/index.tsx): growth ops · Promotion settings, Google integration, reports, and referrals. · `pages/dashboard/promotion/index.tsx`
- [Users and roles](https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/user/index.tsx): access control · User, role, journalist, and team-oriented dashboard management. · `pages/dashboard/user/index.tsx`
- [Dashboard variants](https://github.com/zahidrajudev/next-gmn/blob/main/pages/dashboard/v2/index.tsx): alternate dashboards · Versioned dashboard experiences and specialized workspaces such as v2-v5 and GMN AI. · `pages/dashboard/v2/index.tsx`

## Connections

- App bootstrap → Public pages: renders · Bootstraps the public page tree.
- App bootstrap → Auth pages: renders · Bootstraps authentication and status pages.
- App bootstrap → Dashboard shell: renders · Bootstraps authenticated dashboard routes.
- Public pages → Layouts: uses · Public pages share the main layout shell.
- Content routes → Layouts: uses · Content-heavy pages use the main site layout.
- Shop pages → Layouts: uses · Shop pages share the public shell.
- Auth pages → State hooks: uses · Auth flows rely on shared state and preferences.
- Checkout flow → Payment providers: uses · Checkout screens delegate to payment integrations.
- Checkout flow → API clients: calls · Checkout status and order updates use API helpers.
- Payment providers → API clients: calls · Gateway-specific logic uses shared request abstractions.
- Dashboard shell → Content admin: routes to · Dashboard splits into domain-specific admin areas.
- Dashboard shell → Media library: routes to · Dashboard exposes media workflows.
- Dashboard shell → Payments admin: routes to · Dashboard exposes finance workflows.
- Dashboard shell → Promotion admin: routes to · Dashboard exposes promotion workflows.
- Dashboard shell → Users and roles: routes to · Dashboard exposes users and roles.
- Dashboard shell → Dashboard variants: routes to · Versioned dashboard branches coexist alongside the main admin shell.
- Content admin → UI kit: uses · Admin editors and tables are built from shared primitives.
- Media library → UI kit: uses · Media managers use uploaders, drawers, tables, and image widgets.
- Payments admin → API clients: calls · Payment ops pages rely on admin/user API helpers.
- Promotion admin → API clients: calls · Promotion tools use shared backend access wrappers.
- Users and roles → State hooks: uses · Role-aware dashboard state and context support people management.
- Public pages → UI kit: uses · Public pages assemble from shared components.
- Dashboard shell → Layouts: uses · Admin pages use dashboard-specific layouts and sidebars.
- Dashboard shell → State hooks: uses · Dashboard behavior is coordinated through shared app state.
- Public pages → API clients: calls · Public screens fetch shared backend data through lib helpers.
- Public pages → Server entry: served by · The custom server/API wrapper sits under the app boundary.
