A real-time chat application built with Rust (Axum) backend and React frontend.
- π User Authentication (Registration/Login)
- π¬ Real-time Messaging
- π₯ Friend Management System
- π’ Group Chat
- π File Upload and Sharing
- π€ Voice Messages
- π· Image and Video Sharing
- π Real-time Notifications
- π± Responsive Design
- Rust - Systems programming language
- Axum - Modern async web framework
- PostgreSQL - Primary database
- Redis - Caching and session storage
- WebSocket - Real-time communication
- JWT - Authentication
- SQLx - Database ORM
- React 19 - UI framework
- TypeScript - Type safety
- Tailwind CSS - Styling framework
- Vite - Build tool
- Socket.IO - WebSocket client
- Axios - HTTP client
- Rust 1.70+
- Node.js 18+
- PostgreSQL 13+
- Redis 6+
-
Clone the repository
git clone <repository-url> cd rusty-chat
-
Setup database
# Run database setup script ./scripts/setup_db.sh # Or setup manually createdb rusty_chat psql -d rusty_chat -f migrations/001_initial.sql
-
Configure environment variables
# Copy environment template cp .env.example .env # Edit .env file and set your database and Redis connection info
-
Start Redis
# macOS brew services start redis # Linux sudo systemctl start redis # Or run directly redis-server
-
Install frontend dependencies
cd frontend npm install
-
Start development servers
Backend (Terminal 1):
cargo run
Frontend (Terminal 2):
cd frontend npm run dev
-
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:3000
rusty-chat/
βββ src/ # Rust backend source code
β βββ handlers/ # API handlers
β βββ models/ # Data models
β βββ services/ # Business logic
β βββ config.rs # Configuration management
β βββ database.rs # Database connection
β βββ websocket.rs # WebSocket handling
β βββ main.rs # Application entry point
βββ frontend/ # React frontend
β βββ src/
β β βββ components/ # React components
β β βββ contexts/ # React Context
β β βββ pages/ # Page components
β β βββ services/ # API services
β β βββ types/ # TypeScript types
β βββ public/ # Static assets
βββ migrations/ # Database migrations
βββ scripts/ # Utility scripts
βββ uploads/ # File upload directory
POST /api/auth/register
- User registrationPOST /api/auth/login
- User loginPOST /api/auth/refresh
- Refresh token
GET /api/users/me
- Get current user infoGET /api/users/search
- Search users
GET /api/friends
- Get friends listPOST /api/friends/requests
- Send friend requestPOST /api/friends/requests/:id/accept
- Accept friend requestPOST /api/friends/requests/:id/reject
- Reject friend requestDELETE /api/friends/:id
- Remove friend
GET /api/groups
- Get groups listPOST /api/groups
- Create groupGET /api/groups/:id/members
- Get group membersPOST /api/groups/:id/members
- Add group memberDELETE /api/groups/:id/members/:user_id
- Remove group member
GET /api/messages/:chat_id
- Get chat messagesPOST /api/messages
- Send message
POST /api/upload
- Upload fileGET /api/files/:id
- Download file
authenticate
- Authenticationjoin_chat
- Join chat roomleave_chat
- Leave chat roomsend_message
- Send messagetyping_indicator
- Typing status indicator
new_message
- New messagetyping_indicator
- Typing statususer_online
- User onlineuser_offline
- User offlinefriend_request
- Friend requestgroup_invitation
- Group invitation
# Run tests
cargo test
# Check code
cargo clippy
# Format code
cargo fmt
cd frontend
# Run tests
npm test
# Code linting
npm run lint
# Build for production
npm run build
# Build frontend
cd frontend
npm run build
# Build backend
cargo build --release
# Build image
docker build -t rusty-chat .
# Run container
docker run -p 3000:3000 rusty-chat
# Start all services (database, redis, app)
docker-compose up -d
# Stop all services
docker-compose down
# Use the development script for automatic setup
./scripts/dev.sh
- Fork the project
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or suggestions, please create an Issue or contact the project maintainers.