# fu-self-learning/fu-self-learning-ui architecture

> Architecture diagram of the GitHub repository fu-self-learning/fu-self-learning-ui, 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/fu-self-learning/fu-self-learning-ui
- Repository: https://github.com/fu-self-learning/fu-self-learning-ui

## Overview

##### Project Type and Purpose
- This is a full-stack frontend application (Next.js + React) that provides the UI for the FU Self Learning platform.
- It handles authentication, user profiles, social content, and demo/private routes; it does not include its own data store but interacts with backend APIs (e.g., authentication and content services).

##### Main Architectural Components
A. Client Layer (Browser)
- Next.js-rendered pages & components (src/app, src/components)
- Static assets (public/images, public/svgs, CSS via Tailwind, Ant Design styles)
B. Frontend Application Server
- Next.js server (SSR/CSR) running on Node.js
- Custom routing under src/app using the Next.js App Router
C. State & Data-Fetching Layer
- Redux Toolkit (authSlice, store)
- React Query (QueryClientProvider)
- React Context providers (AuthHydration, Theme, ReduxProvider)
D. API Layer
- Shared API clients (src/shared/api/auth.api.ts, index.ts)
- Hooks that call API (useLogin, useRegister, useProfile)
E. External Backend Services
- Authentication API
- Content / Social API endpoints
F. Infrastructure & Deployment
- Docker container running Next.js + Node
- Nginx reverse-proxy (nginx.conf)
- docker-compose orchestration
- CI/CD workflow (GitHub Actions .github/workflows/deploy.yml)

##### Relationships & Data Flow
1. User opens browser → requests a page (e.g., /login)
2. Request hits Nginx → forwarded to Next.js container
3. Next.js composes the page:
- Executes server-side code (if SSR)
- Hydrates context providers (AuthHydration checks existing token)
- Renders React components, applying global CSS (Tailwind) and Ant Design styling
4. Client code calls data-fetch layer:
- React Query hooks fetch data via shared API clients
- Redux Toolkit stores authentication state, user profile, etc.
5. API calls traverse to external backend services over HTTP
6. Responses flow back to React Query / Redux, update UI

##### Architectural Patterns & Design Principles
- Component-Based Architecture (reusable UI components organized under src/components)
- Separation of Concerns:
- Presentation (components) vs. State (Redux) vs. Data Fetching (React Query) vs. Routing (Next.js App Router)
- Context-Driven Configuration (AuthHydration, Theme toggling via custom hooks)
- Containerization & Infrastructure as Code (Dockerfile, docker-compose.yml, Nginx config)

##### Key Technologies & Frameworks
- Next.js 15.3.1 & React 19 (App Router, server/client boundaries)
- TypeScript (tsconfig.json)
- Redux Toolkit (src/providers/auth)
- React Query (src/context/QueryClientProvider.tsx)
- TailwindCSS (tailwind.config.js), Ant Design
- Docker, Docker Compose, Nginx
- GitHub Actions for CI/CD

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client Layer (Browser)"
        Browser["Browser"]:::client
    end

    subgraph "Infrastructure & Deployment"
        DockerCompose["docker-compose.yml"]:::infra
        Docker["Docker Container"]:::infra
        Nginx["Nginx Reverse Proxy (nginx.conf)"]:::infra
        CI["GitHub Actions (.github/workflows/deploy.yml)"]:::infra
    end

    subgraph "Next.js Server (SSR/CSR)"
        NextServer["Next.js Server (Node.js)"]:::server
        subgraph "Routing Layer"
            AppRouter["Next.js App Router"]:::frontend
        end
        RootLayout["Root Layout (layout.tsx)"]:::frontend
        GlobalCSS["Global CSS (globals.css)"]:::frontend
    end

    subgraph "UI Components"
        ComponentFolder["Components (src/components)"]:::ui
        subgraph "Auth Routes"
            Login["Login Page (page.tsx)"]:::ui
            Register["Register Page (page.tsx)"]:::ui
        end
        subgraph "Public Pages"
            Home["Home (page.tsx)"]:::ui
            Demo["Demo (page.tsx)"]:::ui
            Profile["Profile (page.tsx)"]:::ui
            Social["Social Listing (page.tsx)"]:::ui
            ContentSocial["Social Content (contentSocial.tsx)"]:::ui
        end
        subgraph "Private/Demo Routes"
            PrivateLayout["Private Layout (layout.tsx)"]:::ui
            Demo2["Demo2 (page.tsx)"]:::ui
            Demo3["Demo3 (page.tsx)"]:::ui
        end
    end

    subgraph "State & Data-Fetching"
        ReduxStore["Redux Store"]:::state
        QueryProvider["QueryClientProvider"]:::state
        AuthHydration["AuthHydration"]:::state
        ThemeProvider["Theme Provider"]:::state
    end

    subgraph "API Layer"
        AuthClient["auth.api.ts"]:::api
        IndexAPI["index.ts"]:::api
        subgraph "API Hooks"
            UseLogin["useLogin"]:::api
            UseRegister["useRegister"]:::api
            UseProfile["useProfile"]:::api
        end
    end

    subgraph "External Backend Services"
        AuthService["Authentication API"]:::external
        ContentService["Content/Social API"]:::external
    end

    Browser -->|"HTTP Request"| Nginx
    Nginx -->|"Proxy"| Docker
    DockerCompose --> Docker
    CI --> DockerCompose
    Docker --> Nginx
    Nginx --> NextServer
    NextServer --> AppRouter
    AppRouter --> RootLayout
    AppRouter --> ReduxStore
    AppRouter --> QueryProvider
    RootLayout --> GlobalCSS
    RootLayout --> Login
    RootLayout --> Register
    RootLayout --> Home
    RootLayout --> Demo
    RootLayout --> Profile
    RootLayout --> Social
    RootLayout --> PrivateLayout
    Login --> ComponentFolder
    Register --> ComponentFolder
    Home --> ComponentFolder
    Demo --> ComponentFolder
    Profile --> ComponentFolder
    Social --> ComponentFolder
    ContentSocial --> ComponentFolder
    PrivateLayout --> ComponentFolder
    Demo2 --> ComponentFolder
    Demo3 --> ComponentFolder
    ReduxStore --> AuthHydration
    ReduxStore --> ThemeProvider
    QueryProvider --> UseLogin
    QueryProvider --> UseRegister
    QueryProvider --> UseProfile
    UseLogin --> AuthClient
    UseRegister --> AuthClient
    UseProfile --> AuthClient
    AuthClient --> AuthService
    IndexAPI --> ContentService
    Browser ---|"CSR"| NextServer

    click AppRouter "https://github.com/fu-self-learning/fu-self-learning-ui/tree/main/src/app"
    click Login "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/(auth)/login/page.tsx"
    click Register "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/(auth)/register/page.tsx"
    click PrivateLayout "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/(private)/layout.tsx"
    click Demo2 "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/(private)/demo2/page.tsx"
    click Demo3 "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/(private)/demo3/page.tsx"
    click Home "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/home/page.tsx"
    click Demo "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/demo/page.tsx"
    click Profile "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/profile/page.tsx"
    click Social "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/social/page.tsx"
    click ContentSocial "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/social/contentSocial.tsx"
    click ComponentFolder "https://github.com/fu-self-learning/fu-self-learning-ui/tree/main/src/components"
    click RootLayout "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/layout.tsx"
    click GlobalCSS "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/app/globals.css"
    click ReduxStore "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/providers/store/index.ts"
    click QueryProvider "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/context/QueryClientProvider.tsx"
    click AuthHydration "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/context/AuthHydration.tsx"
    click AuthClient "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/shared/api/auth.api.ts"
    click IndexAPI "https://github.com/fu-self-learning/fu-self-learning-ui/blob/main/src/shared/api/index.ts"

    classDef client fill:#CCE5FF,stroke:#000,stroke-width:1px
    classDef server fill:#AED6F1,stroke:#000,stroke-width:1px
    classDef frontend fill:#D6EAF8,stroke:#000,stroke-width:1px
    classDef ui fill:#85C1E9,stroke:#000,stroke-width:1px
    classDef state fill:#ABEBC6,stroke:#000,stroke-width:1px
    classDef api fill:#F9E79F,stroke:#000,stroke-width:1px
    classDef external fill:#F5B7B1,stroke:#000,stroke-width:1px
    classDef infra fill:#D5D8DC,stroke:#000,stroke-width:1px
```
