# vieduckk/trade-master architecture

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

- Interactive diagram: https://gitdiagram.com/vieduckk/trade-master
- Repository: https://github.com/vieduckk/trade-master

## Overview

##### Project type and purpose
- This is a Next.js-based full-stack web application that uses React and the new “app” router.
- It provides a multilingual marketing/site front-end (EN/VI) with server-side rendering (SSR)/static-site generation (SSG).
- It hosts static assets (images, fonts, audio, video) in the `public/` folder and uses Tailwind CSS for styling.

##### File structure
Top-level files & folders:
- next.config.mjs, middleware.ts – Next.js configuration and edge/middleware logic
- public/ – static assets (fonts, images, videos, audio) served directly by Next.js
- src/app/ – the “app” directory, organized by locale (`[lng]`) with React components, pages, layouts
- src/app/i18n/ – internationalization logic, locale files and settings
- src/configs/ – site-wide configuration (fonts, navigation, news data)
- tailwind.config.ts, postcss.config.mjs – CSS/build configuration
- tsconfig.json, package.json – TS and dependency management

Patterns & architectural hints:
- i18n routing: `src/app/[lng]/layout.tsx` plus `middleware.ts` to redirect based on locale
- Component hierarchy: shared UI pieces under `components/` (Header, Footer, Button, IntroVideo, etc.)
- Data/config entry points: JSON files under `src/app/i18n/locales/…`, `src/configs/*.ts`
- Static asset serving: fonts, videos, images under `public/` with direct URL mapping

##### Extract insights from the README
- Standard create-next-app project – no custom backend beyond Next’s SSR/SSG.
- Deploys on Vercel (edge functions, static hosting).
- Uses `next/font` for Google Font optimization.

##### Detailed breakdown of components
- Build Pipeline
– Tools: TypeScript compiler, PostCSS, Tailwind, next/font optimizer
– Outputs: compiled server code, client bundles, optimized assets
- Next.js Server / Edge
– Middleware.ts: language detection and rewrite rules
– Routing: `src/app/[lng]/layout.tsx` → page.tsx
– SSR/SSG: loads React components + JSON config + locale files
- Config & i18n Store
– `src/configs/*.ts`: navigation, fonts, news data
– `src/app/i18n/locales/*/*.json`: field-level translations
- Component Library
– UI primitives (Button, Header, Footer) under `components/`
– Page-specific components (Roadmap, Tokenomics, News, IntroVideo)
- Static Asset Host
– `public/`: directly served assets (fonts, images, videos, audio)
– CDN layer in front of `public/` for caching

## Diagram (Mermaid)

```mermaid
flowchart TB
    classDef runtime fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef buildtime fill:#90EE90,stroke:#333,stroke-width:1px
    classDef static fill:#FFA500,stroke:#333,stroke-width:1px

    subgraph "Build Time" 
        direction TB
        BuildPipeline["Build Pipeline"]:::buildtime
        subgraph "Config & i18n Store"
            direction TB
            Configs["Site-wide Config Store"]:::buildtime
            I18n["Internationalization Store"]:::buildtime
        end
        subgraph "Component Library"
            direction TB
            Button["Button"]:::buildtime
            Header["HeaderBase"]:::buildtime
            Footer["Footer"]:::buildtime
        end
    end

    subgraph "Runtime" 
        direction TB
        Browser["Browser"]:::runtime
        Edge["Edge Middleware"]:::runtime
        NextServer["Next.js Server"]:::runtime
    end

    subgraph "Static Host" 
        direction TB
        StaticHost["Static Asset Host (Public/CDN)"]:::static
    end

    Browser -->|"HTTP GET"| Edge
    Edge -->|"route & locale detection"| NextServer
    NextServer -->|"serves HTML/CSS/JS"| Browser
    Browser -->|"fetch assets"| StaticHost

    BuildPipeline -->|"build output"| NextServer
    BuildPipeline -->|"outputs static assets"| StaticHost

    Configs -->|"import configs"| NextServer
    I18n -->|"import locale files"| NextServer

    Button -->|"import UI component"| NextServer
    Header -->|"import UI component"| NextServer
    Footer -->|"import UI component"| NextServer

    click Edge "https://github.com/vieduckk/trade-master/blob/master/next.config.mjs"
    click Edge "https://github.com/vieduckk/trade-master/blob/master/middleware.ts"
    click NextServer "https://github.com/vieduckk/trade-master/blob/master/src/app/[lng]/layout.tsx"
    click NextServer "https://github.com/vieduckk/trade-master/blob/master/src/app/[lng]/page.tsx"
    click I18n "https://github.com/vieduckk/trade-master/blob/master/src/app/i18n/client.ts"
    click I18n "https://github.com/vieduckk/trade-master/blob/master/src/app/i18n/index.ts"
    click I18n "https://github.com/vieduckk/trade-master/blob/master/src/app/i18n/settings.ts"
    click I18n "https://github.com/vieduckk/trade-master/tree/master/src/app/i18n/locales/en/"
    click I18n "https://github.com/vieduckk/trade-master/tree/master/src/app/i18n/locales/vi/"
    click I18n "https://github.com/vieduckk/trade-master/blob/master/src/i18n.ts"
    click Configs "https://github.com/vieduckk/trade-master/blob/master/src/configs/navigation.ts"
    click Configs "https://github.com/vieduckk/trade-master/blob/master/src/configs/fonts.ts"
    click Configs "https://github.com/vieduckk/trade-master/blob/master/src/configs/news.ts"
    click Button "https://github.com/vieduckk/trade-master/blob/master/src/app/[lng]/components/Button.tsx"
    click Header "https://github.com/vieduckk/trade-master/blob/master/src/app/[lng]/components/Header/HeaderBase.tsx"
    click Footer "https://github.com/vieduckk/trade-master/blob/master/src/app/[lng]/components/Footer.tsx"
    click StaticHost "https://github.com/vieduckk/trade-master/tree/master/public/fonts/"
    click StaticHost "https://github.com/vieduckk/trade-master/tree/master/public/images/"
    click StaticHost "https://github.com/vieduckk/trade-master/tree/master/public/videos/"
    click StaticHost "https://github.com/vieduckk/trade-master/tree/master/public/audios/"
    click StaticHost "https://github.com/vieduckk/trade-master/tree/master/public/icons/"
    click BuildPipeline "https://github.com/vieduckk/trade-master/blob/master/tsconfig.json"
    click BuildPipeline "https://github.com/vieduckk/trade-master/blob/master/package.json"
    click BuildPipeline "https://github.com/vieduckk/trade-master/blob/master/postcss.config.mjs"
    click BuildPipeline "https://github.com/vieduckk/trade-master/blob/master/tailwind.config.ts"
```
