- 🚀 Real-time Communication - WebSocket-based instant messaging
- 🎨 Premium Design - Apple-inspired minimalist UI with elegant animations
- 👥 Multi-user Support - See online users and chat with anyone
- 💬 Chat History - Persistent conversation history per user
- 🎭 Dynamic Avatars - Auto-generated gradient avatars for each user
- 📱 Responsive Design - Works seamlessly on desktop and mobile
- 🌓 Dark Mode - Automatic dark mode support based on system preference
- ⚡ Smooth Animations - Micro-interactions and fluid transitions throughout
- Spring Boot 3.5.6 - Modern Java framework
- Jakarta WebSocket - Real-time bidirectional communication
- Fastjson2 - Fast JSON processing
- Lombok - Reduce boilerplate code
- Vanilla JavaScript - Pure JS, no frameworks
- CSS Variables - Theming and design system
- WebSocket API - Native browser WebSocket support
- Canvas API - Particle animation background
SpringBootWebSocket/
├── src/main/java/com/study/springbootwebsocket/
│ ├── config/
│ │ ├── WebSocketConfig.java # WebSocket configuration
│ │ └── GetHttpSessionConfigurator.java # Session management
│ ├── controller/
│ │ └── UserController.java # Login API
│ ├── ws/
│ │ └── ChatEndPoint.java # WebSocket endpoint
│ ├── pojo/
│ │ ├── User.java # User entity
│ │ ├── Message.java # Message entity
│ │ └── ResultMessage.java # Response entity
│ └── utils/
│ └── MessageUtils.java # Message utilities
└── src/main/resources/static/
├── login.html # Login page
├── chat.html # Chat room page
├── css/
│ └── style.css # Global styles
└── js/
└── chat.js # Chat logic
- Java 17 or higher
- Maven 3.6+
- Modern web browser (Chrome, Firefox, Safari, Edge)
-
Clone the repository
git clone <repository-url> cd SpringBootWebSocket
-
Build the project
mvn clean package
-
Run the application
mvn spring-boot:run
Or run directly from IDE:
Run SpringBootWebSocketApplication.java -
Access the application
Open your browser and navigate to:
http://localhost:8080/login.html
- Username: Any username you like
- Password:
123(default for all users)
- Open
http://localhost:8080/login.html - Enter any username
- Use password
123 - Click "Connect"
- After login, you'll see the chat room
- Online users appear in the left sidebar
- Click on a user to start chatting
- Type your message and press Enter or click Send
- Chat history is maintained for each conversation
- User Avatars: Each user gets a unique gradient avatar
- Online Status: Green dot indicator for online users
- Message Bubbles: Sent messages appear in gradient bubbles on the right
- Received Messages: Messages from others appear on the left
- Smooth Scrolling: Auto-scroll to latest messages
Inspired by Apple's design language, Nexus features:
- Minimalism: Clean layouts with generous whitespace
- Fluidity: Smooth cubic-bezier transitions (0.3s)
- Balance: Harmonious spacing and typography
- Elegance: Subtle gradients and soft shadows
- Micro-interactions: Delightful feedback on every action
- Primary:
#667eeato#764ba2gradient - Neutral: Carefully crafted grayscale palette
- Shadows: Multi-layer depth with low opacity
- Font: SF Pro Display / -apple-system
- Smooth rendering with antialiasing
- Balanced hierarchy and spacing
Edit application.properties:
server.port=8080Edit UserController.java:
if (user != null && "your-password".equals(user.getPassword())) {
// ...
}ws://localhost:8080/chat
Send Message:
{
"toName": "recipient_username",
"message": "Hello, World!"
}Receive Message:
{
"isSystemMessage": false,
"fromName": "sender_username",
"message": "Hello, World!"
}System Message (User List):
{
"isSystemMessage": true,
"message": ["user1", "user2", "user3"]
}Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
- Design inspiration from Apple's Human Interface Guidelines
- WebSocket implementation with Spring Boot
- Modern CSS techniques and animations
一个具有 Apple 风格设计语言的高端、极简实时聊天应用
- 🚀 实时通信 - 基于 WebSocket 的即时消息传递
- 🎨 高端设计 - Apple 风格的极简 UI 配合优雅动画
- 👥 多用户支持 - 查看在线用户并与任何人聊天
- 💬 聊天历史 - 为每个用户保持持久的对话历史
- 🎭 动态头像 - 为每个用户自动生成渐变色头像
- 📱 响应式设计 - 在桌面和移动端无缝运行
- 🌓 深色模式 - 根据系统偏好自动支持深色模式
- ⚡ 流畅动画 - 整体微交互和流畅过渡
- Spring Boot 3.5.6 - 现代 Java 框架
- Jakarta WebSocket - 实时双向通信
- Fastjson2 - 快速 JSON 处理
- Lombok - 减少样板代码
- 原生 JavaScript - 纯 JS,无框架
- CSS 变量 - 主题和设计系统
- WebSocket API - 浏览器原生 WebSocket 支持
- Canvas API - 粒子动画背景
SpringBootWebSocket/
├── src/main/java/com/study/springbootwebsocket/
│ ├── config/
│ │ ├── WebSocketConfig.java # WebSocket 配置
│ │ └── GetHttpSessionConfigurator.java # Session 管理
│ ├── controller/
│ │ └── UserController.java # 登录 API
│ ├── ws/
│ │ └── ChatEndPoint.java # WebSocket 端点
│ ├── pojo/
│ │ ├── User.java # 用户实体
│ │ ├── Message.java # 消息实体
│ │ └── ResultMessage.java # 响应实体
│ └── utils/
│ └── MessageUtils.java # 消息工具类
└── src/main/resources/static/
├── login.html # 登录页面
├── chat.html # 聊天室页面
├── css/
│ └── style.css # 全局样式
└── js/
└── chat.js # 聊天逻辑
- Java 17 或更高版本
- Maven 3.6+
- 现代浏览器 (Chrome, Firefox, Safari, Edge)
-
克隆仓库
git clone <repository-url> cd SpringBootWebSocket
-
构建项目
mvn clean package
-
运行应用
mvn spring-boot:run
或在 IDE 中直接运行:
运行 SpringBootWebSocketApplication.java -
访问应用
在浏览器中打开:
http://localhost:8080/login.html
- 用户名: 任意用户名
- 密码:
123(所有用户的默认密码)
- 打开
http://localhost:8080/login.html - 输入任意用户名
- 使用密码
123 - 点击 "Connect"
- 登录后,进入聊天室
- 在线用户显示在左侧边栏
- 点击用户开始聊天
- 输入消息并按 Enter 或点击发送
- 每个对话的聊天历史会被保留
- 用户头像: 每个用户获得独特的渐变色头像
- 在线状态: 在线用户显示绿色圆点指示器
- 消息气泡: 发送的消息显示在右侧的渐变气泡中
- 接收消息: 其他人的消息显示在左侧
- 平滑滚动: 自动滚动到最新消息
受 Apple 设计语言启发,Nexus 特点:
- 极简主义: 简洁的布局和充足的留白
- 流动感: 平滑的 cubic-bezier 过渡 (0.3s)
- 平衡性: 和谐的间距和排版
- 优雅性: 微妙的渐变和柔和的阴影
- 微交互: 每个操作都有愉悦的反馈
- 主色:
#667eea到#764ba2渐变 - 中性色: 精心设计的灰度色板
- 阴影: 低透明度的多层深度
- 字体: SF Pro Display / -apple-system
- 抗锯齿平滑渲染
- 平衡的层级和间距
编辑 application.properties:
server.port=8080编辑 UserController.java:
if (user != null && "your-password".equals(user.getPassword())) {
// ...
}ws://localhost:8080/chat
发送消息:
{
"toName": "接收者用户名",
"message": "你好,世界!"
}接收消息:
{
"isSystemMessage": false,
"fromName": "发送者用户名",
"message": "你好,世界!"
}系统消息 (用户列表):
{
"isSystemMessage": true,
"message": ["user1", "user2", "user3"]
}欢迎贡献!请随时提交 Pull Request。
本项目采用 MIT 许可证。
- 设计灵感来自 Apple 的人机界面指南
- 使用 Spring Boot 实现 WebSocket
- 现代 CSS 技术和动画
Made with ❤️ by Nexus Team