Skip to content

marcodonatucci/ruggine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ruggine Chat Application πŸ¦€

A modern, real-time chat application built with Rust backend and React frontend, featuring group management and user invitations.

Rust React SQLite

πŸš€ Features

  • 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

πŸ—οΈ Project Structure

β”œβ”€β”€ 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

πŸ› οΈ Technology Stack

Backend (Rust)

  • 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

Frontend (React)

  • 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

⚑ Quick Start

Prerequisites

  • Rust (latest stable version)
  • Node.js (16+)
  • npm or yarn

Installation

  1. Clone the repository

    git clone https://github.com/marcodonatucci/ruggine.git
    cd ruggine
  2. Set up the backend

    # Install Rust dependencies and run
    cargo run

    The server will start on http://localhost:8000

  3. Set up the frontend

    cd frontend
    npm install
    npm start

    The React app will start on http://localhost:3000

First Run

  1. Register a new user account
  2. Create your first group
  3. Invite other users by their ID
  4. Start chatting!

πŸ“‘ API Endpoints

Authentication

  • POST /auth/register - User registration
  • POST /auth/login - User login

Users

  • GET /users/user/:id - Get user information

Groups

  • GET /groups/user/:user_id - Get user's groups
  • POST /groups - Create new group

Messages

  • GET /messages/:group_id - Get group messages
  • POST /messages - Send message

Invitations

  • GET /invitations/user/:user_id - Get user invitations
  • POST /invitations - Create invitation
  • PUT /invitations/:id/accept - Accept invitation
  • PUT /invitations/:id/reject - Reject invitation

🎨 Key Features Implementation

Real-time Updates

  • Messages: Polling every 3 seconds
  • Invitations: Polling every 5 seconds (optimized to prevent UI glitches)
  • Groups: Dynamic updates on invitation acceptance

Username Resolution

  • Custom React hook (useUsernames) for efficient username caching
  • Smart fallback to user ID when username unavailable
  • Preloading of usernames for better performance

Responsive Design

  • Two-column layout with groups management and chat
  • Mobile-friendly responsive design
  • Custom CSS with Rust-themed orange color scheme

Database Schema

  • Users: Authentication and profile data
  • Groups: Chat group information
  • Messages: Chat messages with timestamps
  • Invitations: Group invitation system

πŸ”’ Security Features

  • Password hashing with bcrypt
  • CORS configuration for secure frontend-backend communication
  • Input validation and sanitization
  • Error handling and user feedback

🚧 Development Notes

Code Organization

  • Repository Pattern: Clean separation of data access
  • Service Layer: Business logic abstraction
  • Controller Pattern: HTTP request handling
  • Custom Hooks: Reusable React state management

Performance Optimizations

  • Database connection pooling with SQLx
  • React component memoization
  • Efficient polling strategies to minimize server load
  • Username caching to reduce API calls

πŸ“ Future Enhancements

  • WebSocket implementation for true real-time messaging
  • File sharing capabilities
  • User presence indicators
  • Message search functionality
  • Push notifications
  • Message encryption
  • User roles and permissions

πŸ‘₯ Contributing

This project was developed as part of a university course on distributed systems. Contributions and suggestions are welcome!

πŸ“„ License

This project is for educational purposes. Please check with the original authors for licensing information.


Built with ❀️ using Rust and React

About

real-time chat web application using Rust [University Project]

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors