|
| 1 | +# Technical Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +**MXStatus** is a React-based web dashboard for monitoring the status of multiple machines, with a focus on GPU, user, and network information. The application is designed for clarity, responsiveness, and a "hacker" aesthetic, using a custom dark theme and modern UI/UX practices. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Technical Design Choices |
| 10 | + |
| 11 | +- **Framework**: Built with React (v17), using functional components and React Hooks for state and effect management. |
| 12 | +- **State Management**: Local state is managed via React's `useState` and `useEffect`. LocalStorage is used for persisting user preferences (e.g., refresh interval, view key, display options). |
| 13 | +- **Data Fetching**: Uses `axios` for HTTP requests to a backend API, with support for custom server endpoints and view keys. |
| 14 | +- **Componentization**: The UI is highly modular, with reusable components for cards, badges, copyable text, and more. |
| 15 | +- **Responsiveness**: Layouts and controls are responsive, adapting to mobile and desktop via CSS media queries. |
| 16 | +- **Performance**: Includes a loading animation and ensures a minimum loading time for smooth transitions. Auto-refresh is supported with configurable intervals. |
| 17 | +- **Accessibility**: Uses semantic HTML and accessible form controls, with focus and hover states for interactive elements. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Main Libraries Used |
| 22 | + |
| 23 | +- **React**: Core UI framework. |
| 24 | +- **axios**: For HTTP requests to the backend API. |
| 25 | +- **react-sortablejs** and **sortablejs**: (Listed as dependencies, but not directly used in the main code; possibly for future drag-and-drop features.) |
| 26 | +- **Bootstrap 5**: Included via CDN for grid and utility classes, but most styling is custom. |
| 27 | +- **Google Fonts**: "Source Code Pro" (monospace) and "Inter" (UI font) for a modern, technical look. |
| 28 | +- **Testing**: `@testing-library/react`, `@testing-library/jest-dom`, and `@testing-library/user-event` for unit and integration tests. |
| 29 | +- **web-vitals**: For measuring and reporting performance metrics. |
| 30 | + |
| 31 | +> **Note:** TailwindCSS is listed as a dependency but is not actually used or configured in the codebase. All styling is custom via CSS. |
| 32 | +
|
| 33 | +--- |
| 34 | + |
| 35 | +## Styling Choices |
| 36 | + |
| 37 | +- **Custom Theme**: All colors, spacing, and typography are defined via CSS variables in `index.css` (e.g., `--hacker-bg`, `--hacker-text-accent`). |
| 38 | +- **Dark Mode**: The default and only theme is a dark, "hacker" style with neon green accents (`#00ff41`), inspired by terminal UIs. |
| 39 | +- **Responsive Design**: Extensive use of media queries for font sizes, spacing, and layout adjustments on mobile and desktop. |
| 40 | +- **Animations**: Subtle animations for loading, hover, and status indicators (e.g., pulse for online status, animated loading spinner). |
| 41 | +- **Touch-Friendly**: Larger touch targets and spacing for mobile usability. |
| 42 | +- **Custom Components**: Custom cards, badges, and containers with consistent border radius, shadows, and transitions. |
| 43 | +- **Minimal Bootstrap**: Bootstrap is loaded but only lightly used; most layout and style is custom. |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Website Component Structure |
| 48 | + |
| 49 | +### Top-Level |
| 50 | + |
| 51 | +- **App.js**: Root component. Renders the main page (`PageMain`) and a footer. |
| 52 | + |
| 53 | +### Main Page (`PageMain.js`) |
| 54 | + |
| 55 | +- **CodeFlowBackground**: Animated code lines in the background for the welcome screen. |
| 56 | +- **LoadingAnimation**: Full-screen loading spinner and status. |
| 57 | +- **ErrorMessage**: Card for displaying connection or data errors. |
| 58 | +- **Control Center**: UI for entering the view key, selecting server, toggling auto-refresh, and hiding offline machines. |
| 59 | +- **Servers Grid**: Renders a list of `MachineCard` components, one for each machine. |
| 60 | + |
| 61 | +### Machine Display (`MachineCard.js`) |
| 62 | + |
| 63 | +- **Header**: Shows hostname, online/offline badge, GPU count, and a details toggle. |
| 64 | +- **Details Section**: Expands to show: |
| 65 | + - **Last seen** and **uptime** (with copy-to-clipboard). |
| 66 | + - **GPU Information**: Rendered via `GPUv2` (one per GPU). |
| 67 | + - **User Information**: Rendered via `UsersLine` (online/offline users). |
| 68 | + - **IP Addresses**: Rendered via `IP` and `SingleIP` (with copy-to-clipboard). |
| 69 | +- **Status Indicators**: Color-coded badges for online/offline, GPU presence, and more. |
| 70 | + |
| 71 | +### Supporting Components |
| 72 | + |
| 73 | +- **GPUv2**: Shows GPU utilization, temperature, memory usage, and model, with color-coded bars and badges. |
| 74 | +- **UsersLine**: Lists online and offline users with `UserBadge` for each. |
| 75 | +- **UserBadge**: Visual badge for a user, color-coded by online status. |
| 76 | +- **CopyableText**: Inline text with click-to-copy and feedback animation. |
| 77 | +- **DisplayPercent / DisplayRAM / DisplayTemp**: Utility components for formatting and color-coding percentages, RAM, and temperature. |
| 78 | +- **Footer**: Simple, centered copyright. |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## File Structure (Key Files) |
| 83 | + |
| 84 | +``` |
| 85 | +mxstatus/ |
| 86 | + src/ |
| 87 | + App.js |
| 88 | + App.css |
| 89 | + index.js |
| 90 | + index.css |
| 91 | + components/ |
| 92 | + PageMain.js |
| 93 | + MachineCard.js |
| 94 | + GPUv2.js |
| 95 | + UsersLine.js |
| 96 | + UserBadge.js |
| 97 | + CopyableText.js |
| 98 | + DisplayPercent.js |
| 99 | + DisplayRAM.js |
| 100 | + DisplayTemp.js |
| 101 | + IP.js |
| 102 | + SingleIP.js |
| 103 | + Footer.js |
| 104 | +``` |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## Notable UI/UX Features |
| 109 | + |
| 110 | +- **Animated Welcome Screen**: With code flow background and smooth transitions. |
| 111 | +- **Copy-to-Clipboard**: For hostnames, IPs, and other key data. |
| 112 | +- **Auto-Refresh**: User-configurable, with persistent settings. |
| 113 | +- **Offline Filtering**: Option to hide offline machines for clarity. |
| 114 | +- **Mobile-First**: All controls and cards are touch-friendly and responsive. |
| 115 | +- **Status Feedback**: Real-time online/offline, GPU, and user status with color and animation. |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## Summary |
| 120 | + |
| 121 | +MXStatus is a modern, highly-customized React dashboard for machine status monitoring, with a strong focus on UX, clarity, and a distinctive "hacker" aesthetic. The codebase is modular, maintainable, and ready for extension (e.g., more metrics, drag-and-drop, or additional views). |
| 122 | + |
| 123 | +--- |
0 commit comments