# stratezone/web architecture

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

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

## Overview

##### Project type and purpose
- This is a full-stack Next.js (App Router) web application written in TypeScript.
- It serves a multilingual chess and community platform with features like authentication (NextAuth), booking/chess appointments, user profiles, communities, wallets, and notifications.

##### File structure
- Top-level:
- config.ts, constants/, messages/ (i18n resources), next.config.ts, postcss.config.mjs, tailwind.config.ts, tsconfig.json
- public/: static assets (images, logos)
- .github/workflows/: CI/CD pipelines for preview/production
- src/
- src/app/[locale]/…: the Next.js App Router layout and pages organized per locale, including nested routes for account, auth API, chess appointments, community, wallet, etc.
- src/app/products, src/app/store.ts: global app config and data stores
- src/State/Auth: Redux actions, reducers, root reducer for global client-side state
- src/components/: reusable UI pieces (navbar, sidebar, dialogs, cards, etc.)
- src/utils, src/i18n, src/auth.ts, middleware.ts: helper functions, session management, localization routing, middleware
- Configuration: ESLint, GitHub Actions, PostCSS, Tailwind, NextAuth type declarations

##### README for additional insights
- Bootstrapped with create-next-app
- Uses next/font for font optimization
- Standard Next.js dev and deploy instructions

a. Main components
- Client (browser)
- Next.js Frontend (React + App Router + Tailwind)
- Next.js Backend / API Routes (Route Handlers under app/[locale]/api)
- Authentication service (NextAuth + external OAuth or credentials provider)
- Redux store (client-side state)
- Database (e.g., MongoDB/Postgres—configure in NextAuth and API services)
- External services: Payment gateways (walletService, paymentService), Email/SMS for OTP/notifications
- i18n subsystem (messages/en.json, vi.json, routing.ts)
- CDN / Static asset host (public/)
b. Relationships & interactions
- Browser ↔ Next.js Frontend via SSR/CSR and API calls
- Frontend dispatches Redux actions, renders components
- Frontend calls route handlers for auth, booking, community, wallet
- API handlers interact with DB and external services (payment gateways, email/SMS)
- NextAuth middleware and route handlers manage session cookies, tokens
- Middleware.ts enforces locale and auth on protected routes
c. Architectural patterns & design principles
- App Router pattern: file-system routing with nested layouts per locale
- Separation of concerns:
- UI (components/)
- State management (Redux under src/State)
- Business logic & API (app/[locale]/api, walletService, etc.)
- Presentation (Tailwind + PostCSS)
- i18n pattern: dynamic routing by locale segment, message lookup
- CI/CD: GitHub Actions for preview vs production
d. Key technologies/frameworks
- Next.js (React, App Router)
- TypeScript
- Redux (plain or Redux Toolkit)
- NextAuth for authentication
- Tailwind CSS + PostCSS
- GitHub Actions
- Node.js environment

##### Detail is critical—capture
- Route hierarchy under app/[locale]
- Where Redux lives vs NextAuth vs API routes
- All external dependencies (i18n files, public assets, GitHub Actions)
- Communication paths (SSR requests, client fetch, middleware enforcement)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Browser"]:::client

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        NextFrontend["Next.js Frontend (App Router UI)"]:::frontend
        UIComponents["UI Components Library"]:::frontend
        ReduxProvider["ReduxProvider (Inject Store)"]:::frontend
        GlobalStore["Global Application Store"]:::frontend
        RootStyles["Root Layout & Global Styles"]:::frontend
    end

    %% State Management Layer
    subgraph "State Management"
        direction TB
        Action["Auth Actions"]:::service
        Reducer["Auth Reducer"]:::service
        RootReducer["Root Reducer"]:::service
        WalletSlice["Wallet State Slice"]:::service
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        AuthAPI["Authentication API (NextAuth)"]:::api
        APIHelper["API Helper Layer"]:::api
    end

    %% Business Services Layer
    subgraph "Business Services"
        direction TB
        WalletService["Wallet Business Service"]:::service
        PaymentService["Payment Business Service"]:::service
        SessionHelpers["Session Helpers"]:::service
    end

    %% i18n Subsystem
    subgraph "i18n Subsystem"
        direction TB
        MessagesEn["messages/en.json"]:::service
        MessagesVi["messages/vi.json"]:::service
        RoutingI18n["i18n Routing"]:::service
        LayoutLocale["Locale Layout"]:::service
    end

    %% Middleware
    Middleware["Middleware (locale & auth guard)"]:::service

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Database["Database"]:::data
        Redis["Redis / Session Store"]:::data
    end

    %% External Integrations
    subgraph "External Integrations"
        direction TB
        OAuth["OAuth Providers"]:::external
        PaymentGateway["Payment Gateway"]:::external
        CDN["CDN / Static Asset Host"]:::external
        CICD["CI/CD Pipelines"]:::external
    end

    %% Configuration
    config["Global Configuration"]:::service
    NextConfig["Next.js Server Config"]:::service
    Tailwind["Tailwind & PostCSS Config"]:::service
    TypesDecl["NextAuth Type Declarations"]:::service

    %% Connections
    Browser -->|"SSR/CSR requests"| NextFrontend
    NextFrontend -->|renders| UIComponents
    NextFrontend -->|useProvider| ReduxProvider
    ReduxProvider -->|provides| GlobalStore
    GlobalStore -->|dispatch| Action
    Action -->|update| Reducer
    Reducer -->|combine| RootReducer
    GlobalStore -->|reads| WalletSlice

    NextFrontend -->|fetch| AuthAPI
    NextFrontend -->|fetch| APIHelper
    AuthAPI -->|calls| SessionHelpers
    AuthAPI -->|reads/writes| Database
    APIHelper -->|wraps| AuthAPI

    AuthAPI -->|validates| OAuth
    WalletService -->|process| Database
    PaymentService -->|request| PaymentGateway
    SessionHelpers -->|persist| Redis

    NextFrontend -->|loads| RootStyles
    NextFrontend -->|invokes| Middleware
    Middleware -->|enforces| AuthAPI
    Middleware -->|routes| RoutingI18n

    RoutingI18n -->|uses| MessagesEn
    RoutingI18n -->|uses| MessagesVi
    NextFrontend -->|layout| LayoutLocale

    %% Configuration links
    NextFrontend --> config
    NextFrontend --> NextConfig
    NextFrontend --> Tailwind
    AuthAPI --> TypesDecl
    CICD -->|runs| config

    %% Static assets
    NextFrontend --> CDN

    %% Click Events
    click NextFrontend "https://github.com/stratezone/web/tree/master/src/app/[locale]"
    click AuthAPI "https://github.com/stratezone/web/blob/master/src/app/[locale]/api/auth/[...nextauth]/route.ts"
    click Action "https://github.com/stratezone/web/blob/master/src/State/Auth/Action.ts"
    click Reducer "https://github.com/stratezone/web/blob/master/src/State/Auth/Reducer.ts"
    click RootReducer "https://github.com/stratezone/web/blob/master/src/State/Auth/rootReduce.ts"
    click ReduxProvider "https://github.com/stratezone/web/blob/master/src/app/[locale]/providers/ReduxProvider.tsx"
    click WalletService "https://github.com/stratezone/web/blob/master/src/app/[locale]/wallet/walletService.ts"
    click PaymentService "https://github.com/stratezone/web/blob/master/src/app/[locale]/wallet/paymentService.ts"
    click WalletSlice "https://github.com/stratezone/web/blob/master/src/app/[locale]/wallet/walletSlice.ts"
    click MessagesEn "https://github.com/stratezone/web/blob/master/messages/en.json"
    click MessagesVi "https://github.com/stratezone/web/blob/master/messages/vi.json"
    click RoutingI18n "https://github.com/stratezone/web/blob/master/src/i18n/routing.ts"
    click LayoutLocale "https://github.com/stratezone/web/blob/master/src/app/[locale]/layout.tsx"
    click Middleware "https://github.com/stratezone/web/blob/master/src/middleware.ts"
    click UIComponents "https://github.com/stratezone/web/tree/master/src/components"
    click CDN "https://github.com/stratezone/web/tree/master/public/"
    click config "https://github.com/stratezone/web/blob/master/config.ts"
    click TypesDecl "https://github.com/stratezone/web/blob/master/constants/types/next-auth.d.ts"
    click CICD "https://github.com/stratezone/web/blob/master/.github/workflows/preview.yaml"
    click CICD "https://github.com/stratezone/web/blob/master/.github/workflows/production.yaml"
    click Tailwind "https://github.com/stratezone/web/blob/master/tailwind.config.ts"
    click NextConfig "https://github.com/stratezone/web/blob/master/next.config.ts"
    click GlobalStore "https://github.com/stratezone/web/blob/master/src/app/store.ts"
    click SessionHelpers "https://github.com/stratezone/web/blob/master/src/utils/sessionHelpers.ts"
    click APIHelper "https://github.com/stratezone/web/blob/master/src/app/[locale]/helper/api.ts"

    %% Styles
    classDef client fill:#f2f4f8,stroke:#333,stroke-width:1px
    classDef frontend fill:#dae8fc,stroke:#6c8ebf,stroke-width:1px
    classDef api fill:#fff2cc,stroke:#d6b656,stroke-width:1px
    classDef service fill:#d5e8d4,stroke:#82b366,stroke-width:1px
    classDef data fill:#f8cecc,stroke:#b85450,stroke-width:1px
    classDef external fill:#e1e1e1,stroke:#999,stroke-width:1px
```
