A modern, real-time chat application built with Rust backend and React frontend, featuring group management and user invitations.
- Real-time Messaging: Live chat with automatic message updates
- Group Management: Create and manage chat groups
- User Invitations: Invite users to groups with acceptance/rejection system
- User Authentication: Secure login and registration system
- Username Display: Smart username resolution with ID fallback
- Responsive UI: Modern React interface with custom styling
- API-First Design: RESTful API architecture
βββ src/ # Rust Backend
β βββ main.rs # Application entry point
β βββ server.rs # Server configuration
β βββ config/ # Database configuration
β βββ controllers/ # HTTP request handlers
β βββ models/ # Data models (User, Group, Message, Invitation)
β βββ repositories/ # Database access layer
β βββ routes/ # API route definitions
β βββ services/ # Business logic layer
β βββ utils/ # Utility functions
βββ frontend/ # React Frontend
β βββ src/
β β βββ components/ # React components
β β βββ hooks/ # Custom React hooks
β β βββ services/ # API service layer
β βββ public/ # Static assets
βββ data/ # SQLite database
βββ target/ # Rust build artifacts
- Axum: Modern web framework for Rust
- SQLx: Async SQL toolkit with compile-time verification
- SQLite: Lightweight, embedded database
- Tokio: Asynchronous runtime
- Serde: Serialization/deserialization framework
- bcrypt: Password hashing
- Tower-HTTP: CORS and middleware support
- React 18: Modern React with hooks
- JavaScript ES6+: Modern JavaScript features
- Custom Hooks: Reusable state logic
- CSS3: Custom styling with Flexbox/Grid
- Fetch API: HTTP client for API communication
- Rust (latest stable version)
- Node.js (16+)
- npm or yarn
-
Clone the repository
git clone https://github.com/marcodonatucci/ruggine.git cd ruggine -
Set up the backend
# Install Rust dependencies and run cargo runThe server will start on
http://localhost:8000 -
Set up the frontend
cd frontend npm install npm startThe React app will start on
http://localhost:3000
- Register a new user account
- Create your first group
- Invite other users by their ID
- Start chatting!
POST /auth/register- User registrationPOST /auth/login- User login
GET /users/user/:id- Get user information
GET /groups/user/:user_id- Get user's groupsPOST /groups- Create new group
GET /messages/:group_id- Get group messagesPOST /messages- Send message
GET /invitations/user/:user_id- Get user invitationsPOST /invitations- Create invitationPUT /invitations/:id/accept- Accept invitationPUT /invitations/:id/reject- Reject invitation
- Messages: Polling every 3 seconds
- Invitations: Polling every 5 seconds (optimized to prevent UI glitches)
- Groups: Dynamic updates on invitation acceptance
- Custom React hook (
useUsernames) for efficient username caching - Smart fallback to user ID when username unavailable
- Preloading of usernames for better performance
- Two-column layout with groups management and chat
- Mobile-friendly responsive design
- Custom CSS with Rust-themed orange color scheme
- Users: Authentication and profile data
- Groups: Chat group information
- Messages: Chat messages with timestamps
- Invitations: Group invitation system
- Password hashing with bcrypt
- CORS configuration for secure frontend-backend communication
- Input validation and sanitization
- Error handling and user feedback
- Repository Pattern: Clean separation of data access
- Service Layer: Business logic abstraction
- Controller Pattern: HTTP request handling
- Custom Hooks: Reusable React state management
- Database connection pooling with SQLx
- React component memoization
- Efficient polling strategies to minimize server load
- Username caching to reduce API calls
- WebSocket implementation for true real-time messaging
- File sharing capabilities
- User presence indicators
- Message search functionality
- Push notifications
- Message encryption
- User roles and permissions
This project was developed as part of a university course on distributed systems. Contributions and suggestions are welcome!
This project is for educational purposes. Please check with the original authors for licensing information.
Built with β€οΈ using Rust and React