Code Structure
RushChat project code structure documentation.
Code Structure Overview
Project Structure
RushChat/
├── server-rust/ # Rust Backend
│ ├── src/
│ │ ├── main.rs
│ │ ├── config.rs
│ │ ├── db.rs
│ │ ├── models/ # Data models
│ │ ├── handlers/ # HTTP handlers
│ │ ├── websocket/ # WebSocket handlers
│ │ └── utils/ # Utility functions
│ └── Cargo.toml
├── client/ # React Frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── utils/ # Utility functions
│ │ ├── i18n/ # Internationalization
│ │ └── config/ # Configuration files
│ └── package.json
├── database/ # Database files
│ ├── schema.sql
│ └── migration_*.sql
├── docs/ # Documentation
└── gitbook/ # GitBook documentation
Backend Structure
models/
Data models, containing CRUD operations for all database tables:
user.rs- User modelmessage.rs- Message modelchannel.rs- Channel modelban.rs- Ban model- etc...
handlers/
HTTP request handlers:
auth.rs- Authentication relateduser.rs- User relatedchannel.rs- Channel relatedmessage.rs- Message related- etc...
websocket/
WebSocket connection and event handling:
connection.rs- Connection managementevents.rs- Event handlingstate.rs- State management
utils/
Utility functions:
rpc.rs- RPC utilities (NFT verification, etc.)permissions.rs- Permission checking
Frontend Structure
components/
React components:
ChatRoom.js- Chat roomChannelManager.js- Channel managementMessageList.js- Message listWalletConnect.jsx- Wallet connection- etc...
utils/
Utility functions:
websocket.js- WebSocket connectionwallet.js- Wallet utilitiescontract.js- Contract interaction
i18n/
Internationalization:
index.js- i18n configurationlocales/zh.js- Chinese translationslocales/en.js- English translations
Code Standards
Rust
- Use
rustfmtfor formatting - Use
clippyfor checking - Follow Rust best practices
JavaScript
- Use ESLint
- Use Prettier
- Follow React best practices