# tanphat0226/trello-web architecture

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

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

## Overview

##### Project type and purpose
- This is the front-end of a Trello-style Kanban application built with React, Redux Toolkit, and Vite. It serves as the UI layer in a MERN-style course, handling board rendering, card management, authentication flows, and real-time updates via WebSockets.

##### File structure
- Top-level:
- index.html – single page host
- vite.config.js – build/dev server config
- src/:
- main.jsx – React entrypoint, bootstraps App component inside Redux Provider & theme provider
- App.jsx – root component, defines routes (Auth, Boards, Settings, Users, 404)
- /apis – HTTP client (authorizeAxios) and mock-data stub
- /socketClient.js – WebSocket (socket.io-client) setup for real-time events
- /redux – Redux Toolkit slices (user, activeBoard, activeCard, notifications) and store.js
- /components + /pages – presentational & container components organized by feature (AppBar, Modals, Forms, Boards, etc.)
- /customHooks, /customLibs, /utils, theme.js – cross-cutting utilities, DnD kit sensors, formatters, validators, theme config

##### README for additional insights
- Confirms project is the React front-end for a Trello clone, part of a MERN Stack course using React 18, Vite, Redux, SWC plugin, ESLint, etc.

- Browser/Client (loads index.html, serves React SPA)
- React App
– Entry (main.jsx)
– Router layer (Auth, Boards, Settings, Users, 404)
– UI Components (AppBar, Forms, Modals, Boards/Columns/Cards)
- State Management
– Redux Store
– Slices: user, activeBoard, activeCard, notifications
- Service Layer
– HTTP API module (axios wrapper)
– WebSocket Client (socketClient.js)
- Static Assets & Build
– Vite Dev/Build pipeline
- External Services (outside repo)
– Backend REST API
– WebSocket / socket.io server
– Database

- Browser → React App (initial page load)
- React App ↔ Redux Store (dispatch actions, subscribe to state)
- React App → API Layer (REST calls via authorizeAxios) → Backend API → Redux Store (via dispatched thunks)
- React App ↔ WebSocket Client → socket.io server → Redux Store (real-time events)
- Components consume state and render UI; user events dispatch Redux actions

c. Architectural patterns & design principles:
- Single-Page Application (SPA) with client-side routing
- Container–Presentational separation: pages vs UI components
- Redux Toolkit for predictable global state
- Service layer abstraction for HTTP and WebSocket
- Custom hooks for cross-cutting concerns (debounce, focus)
- Utility modules for formatting, validation, constants

d. Key technologies & frameworks:
- React 18, JSX
- Vite + SWC plugin
- Redux Toolkit, React-Redux
- Axios (authorizeAxios wrapper)
- socket.io-client
- DnD Kit (custom DndKitSensors)
- ESLint, Prettier, jsconfig.json

##### Essential architectural elements
- Do not over-compartmentalize; illustrate logical groupings: UI, state, services.
- How actions in the UI propagate through Redux to services and back.
- Real-time WebSocket channel alongside REST calls.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend"
        subgraph "UI Layer"
            Browser["Browser/Client"]:::frontend
            Main["React Entrypoint<br/>main.jsx"]:::frontend
            App["Root Component & Router<br/>App.jsx"]:::frontend
            subgraph "UI Components"
                AppBar["AppBar"]:::frontend
                Form["Form"]:::frontend
                Loading["Loading"]:::frontend
                Modal["Modal"]:::frontend
                ModeSelect["ModeSelect"]:::frontend
                subgraph "AppBar Children"
                    Menu["Menu"]:::frontend
                    Notifications["Notifications"]:::frontend
                    SearchBoards["SearchBoards"]:::frontend
                end
            end
            subgraph "Page Containers"
                Auth["Auth"]:::frontend
                Boards["Boards"]:::frontend
                Settings["Settings"]:::frontend
                Users["Users"]:::frontend
                NotFound["404 Page"]:::frontend
            end
        end

        subgraph "State Management"
            Store["Redux Store"]:::state
            UserSlice["userSlice"]:::state
            BoardSlice["activeBoardSlice"]:::state
            CardSlice["activeCardSlice"]:::state
            NotificationsSlice["notificationsSlice"]:::state
        end

        subgraph "Service Layer"
            HTTP["HTTP API Module<br/>authorizeAxios"]:::service
            Mock["Mock Data Stub"]:::service
            Socket["WebSocket Client"]:::service
        end

        subgraph "Utilities & Config"
            Hooks["useDebounce"]:::util
            Libs["DndKitSensors"]:::util
            Const["constant"]:::util
            Formatters["formatters"]:::util
            Sorts["sorts"]:::util
            Validators["validators"]:::util
            Theme["theme.js"]:::util
        end

        subgraph "Build & Assets"
            Public["public/"]:::build
            Vite["Vite Config<br/>vite.config.js"]:::build
        end
    end

    %% Backend Layer
    subgraph "Backend (External)"
        API["REST API"]:::external
        WS["WebSocket Server"]:::external
        DB["Database"]:::external
    end

    %% Connections
    Browser -->|loads SPA| Main
    Main -->|mounts| App
    App -->|dispatches/subscribes| Store
    App -->|"HTTP Calls"| HTTP
    HTTP -->|REST over HTTP| API
    HTTP -->|dispatches data| Store
    App -->|"WebSocket Connect"| Socket
    Socket -->|WS Protocol| WS
    WS -->|real-time events| Store
    Store -->|provides state| App
    AppBar -->|dispatches actions| Store
    Boards -->|dispatches actions| Store

    %% Click Events
    click Browser "https://github.com/tanphat0226/trello-web/blob/main/index.html"
    click Main "https://github.com/tanphat0226/trello-web/blob/main/src/main.jsx"
    click App "https://github.com/tanphat0226/trello-web/blob/main/src/App.jsx"
    click AppBar "https://github.com/tanphat0226/trello-web/tree/main/src/components/AppBar"
    click Form "https://github.com/tanphat0226/trello-web/tree/main/src/components/Form"
    click Loading "https://github.com/tanphat0226/trello-web/tree/main/src/components/Loading"
    click Modal "https://github.com/tanphat0226/trello-web/tree/main/src/components/Modal"
    click ModeSelect "https://github.com/tanphat0226/trello-web/tree/main/src/components/ModeSelect"
    click Menu "https://github.com/tanphat0226/trello-web/tree/main/src/components/AppBar/Menu"
    click Notifications "https://github.com/tanphat0226/trello-web/tree/main/src/components/AppBar/Notifications"
    click SearchBoards "https://github.com/tanphat0226/trello-web/tree/main/src/components/AppBar/SearchBoards"
    click Auth "https://github.com/tanphat0226/trello-web/tree/main/src/pages/Auth"
    click Boards "https://github.com/tanphat0226/trello-web/tree/main/src/pages/Boards"
    click Settings "https://github.com/tanphat0226/trello-web/tree/main/src/pages/Settings"
    click Users "https://github.com/tanphat0226/trello-web/tree/main/src/pages/Users"
    click NotFound "https://github.com/tanphat0226/trello-web/tree/main/src/pages/404"
    click Store "https://github.com/tanphat0226/trello-web/blob/main/src/redux/store.js"
    click UserSlice "https://github.com/tanphat0226/trello-web/blob/main/src/redux/user/userSlice.js"
    click BoardSlice "https://github.com/tanphat0226/trello-web/blob/main/src/redux/activeBoard/activeBoardSlice.js"
    click CardSlice "https://github.com/tanphat0226/trello-web/blob/main/src/redux/activeCard/activeCardSlice.js"
    click NotificationsSlice "https://github.com/tanphat0226/trello-web/blob/main/src/redux/notifications/notificationsSlice.js"
    click HTTP "https://github.com/tanphat0226/trello-web/blob/main/src/apis/index.js"
    click Mock "https://github.com/tanphat0226/trello-web/blob/main/src/apis/mock-data.js"
    click Hooks "https://github.com/tanphat0226/trello-web/blob/main/src/customHooks/useDebounce.js"
    click Libs "https://github.com/tanphat0226/trello-web/blob/main/src/customLibs/DndKitSensors.js"
    click Const "https://github.com/tanphat0226/trello-web/blob/main/src/utils/constant.js"
    click Formatters "https://github.com/tanphat0226/trello-web/blob/main/src/utils/formatters.js"
    click Sorts "https://github.com/tanphat0226/trello-web/blob/main/src/utils/sorts.js"
    click Validators "https://github.com/tanphat0226/trello-web/blob/main/src/utils/validators.js"
    click Theme "https://github.com/tanphat0226/trello-web/blob/main/src/theme.js"
    click Public "https://github.com/tanphat0226/trello-web/tree/main/public/"
    click Vite "https://github.com/tanphat0226/trello-web/blob/main/vite.config.js"

    %% Styles
    classDef frontend fill:#cfe2f3,stroke:#0066cc,color:#003366
    classDef state fill:#d9ead3,stroke:#6aa84f,color:#274e13
    classDef service fill:#f9cb9c,stroke:#e69138,color:#974f0c
    classDef util fill:#fff2cc,stroke:#f1c232,color:#7f6000
    classDef build fill:#d0e0e3,stroke:#76a5af,color:#274142
    classDef external fill:#f4cccc,stroke:#cc0000,color:#660000
```
