- π― About the Project
- β¨ Features
- π οΈ Technology Stack
- ποΈ Architecture
- π Installation
- π± Usage
- π§ Development
- π API Documentation
- π Security
- π€ Contributing
- π License
T-Force is a comprehensive authentication and real-time chat platform developed for modern web applications. It provides a high-performance, secure, and scalable solution using Rust backend and Next.js frontend.
- Security: Modern encryption and authentication standards
- Performance: Rust's speed and Next.js optimizations
- Scalability: Microservice architecture and Docker support
- User Experience: Modern UI/UX design
- β Email/Password Login: Secure user registration and login
- β OAuth Integration: Social login with Google and GitHub
- β Two-Factor Authentication (2FA): TOTP-based security
- β Password Reset: Secure password reset via email
- β Session Management: Multi-session control and termination
- β JWT Token System: Secure token-based authentication
- β WebSocket Connection: Instant messaging
- β Room System: Private and public chat rooms
- β Media Sharing: Image, video, and voice messages
- β Message History: Persistent message storage
- β Room Passwords: Secure private rooms
- β Auto Reconnection: Automatic recovery on connection loss
- β Profile Management: User information and profile pictures
- β Role-Based Authorization: Admin and user roles
- β User Status: Active/inactive user control
- β Admin Panel: User management and system control
- β Rate Limiting: API request rate limiting
- β CORS Protection: Cross-origin request security
- β SQL Injection Protection: ORM-based secure database operations
- β XSS Protection: Frontend security measures
- β Password Hashing: Secure password storage with Argon2
# Core Framework
actix-web = "4.4.0" # Web framework
actix-cors = "0.7.1" # CORS middleware
actix-web-actors = "4.2.0" # WebSocket support
# Database
sea-orm = "1.1.14" # ORM
postgres = "16-alpine" # Database
# Authentication
jsonwebtoken = "9.3.1" # JWT token
argon2 = "0.5.2" # Password hashing
oauth2 = "4.4.2" # OAuth integration
# Other
serde = "1.0.188" # Serialization
tokio = "1.32.0" # Async runtime
lettre = "0.11.18" # Email sending
{
"next": "15.5.0", // React framework
"react": "19.0.0", // UI library
"typescript": "5.0+", // Type safety
"tailwindcss": "3.4.0", // CSS framework
"shadcn/ui": "latest", // UI components
"react-hook-form": "7.62.0", // Form management
"jwt-decode": "4.0.0", // JWT parsing
"lucide-react": "0.541.0" // Icons
}
- PostgreSQL 16: Primary database
- Docker & Docker Compose: Containerization
- Traefik: Reverse proxy and load balancer
- Nginx (production): Static file serving
- Let's Encrypt: Automatic SSL certificates
- GitHub Actions: CI/CD pipeline
- Prometheus: Metrics collection
- Grafana: Monitoring dashboard
- Docker Health Checks: Service monitoring
- Automated Backups: Database backup scripts
- Log Aggregation: Structured logging
- Cargo: Rust package manager
- npm/yarn: Node.js package manager
- ESLint & Prettier: Code formatting
- TypeScript: Type checking
- Sea-ORM: Database ORM
- Actix-Web: Web framework
- Tailwind CSS: Utility-first CSS
- Shadcn/UI: Component library
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Traefik β β Backend β
β (Next.js) βββββΊβ (Reverse Proxy)βββββΊβ (Rust) β
β Port: 3000 β β Port: 80 β β Port: 8080 β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Static Files β β Load Balancer β β PostgreSQL β
β & Assets β β & SSL/TLS β β Database β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
POST /api/auth/register # User registration
POST /api/auth/login # Login
POST /api/auth/logout # Logout
GET /api/auth/validate # Token validation
POST /api/auth/forgot # Password reset request
POST /api/auth/reset # Password reset
GET /api/user/me # Get user information
PUT /api/user/profile # Update profile
POST /api/user/avatar # Upload profile picture
GET /api/user/sessions # Active sessions
DELETE /api/user/session/:id # Terminate session
GET /api/chat/rooms # Get chat rooms
POST /api/chat/rooms # Create a new room
GET /api/chat/rooms/:id # Get room details
DELETE /api/chat/rooms/:id # Delete room
GET /api/chat/messages # Get message history
POST /api/chat/upload # Upload media
WS /ws # WebSocket connection
- Docker & Docker Compose: Container management
- Git: Version control
- Node.js 18+: Frontend development (optional)
- Rust 1.70+: Backend development (optional)
- Clone the project
git clone https://github.com/togisoft/t-force.git
cd t-force
- Create environment file
cp env.prod.example .env.prod
# Edit the .env.prod file
- Start development environment
# For development
cp env.prod.example .env.dev
./scripts/dev.sh
# For production
./scripts/prod-deploy.sh
- Access the application
- Frontend: http://localhost
- Backend API: http://localhost/api
- Traefik Dashboard: http://localhost:8080
- Grafana: http://grafana.localhost
# Create production environment file
cp env.prod.example .env.prod
# Start in production mode
./scripts/prod-deploy.sh
- Click on "Sign Up" tab on the main page
- Enter email, name and a strong password
- Complete email verification
- Sign in or use OAuth for quick login
- Access the dashboard
- Click on "New Room" button
- Set room name and password (optional)
- Invite friends by sharing the room code
- Start sending messages, images, videos and audio
- Go to profile settings
- Open "Two-Factor Authentication" section
- Scan QR code and enter verification code
- Store your backup codes in a safe place
# Backend development
cd backend
cargo run
# Frontend development
cd frontend
npm install
npm run dev
# Database migration (handled automatically by prod-deploy.sh)
# Backend tests
cd backend
cargo test
# Frontend tests
cd frontend
npm test
# E2E tests
npm run test:e2e
All scripts should be run from the project root directory:
# Start development environment
./scripts/dev.sh
# Start production environment
./scripts/prod-deploy.sh
# Create backup
./scripts/backup.sh
# View logs
./scripts/logs.sh
# Stop services
./scripts/stop.sh
# Reset environment
./scripts/reset.sh
# Format check
cargo fmt --check
# Linting
cargo clippy -- -D warnings
# Run tests
cargo test
# Format check
npm run lint
# Type checking
npm run type-check
# Build test
npm run build
{
"name": "John Doe",
"email": "john@example.com",
"password": "securePassword123"
}
{
"email": "john@example.com",
"password": "securePassword123"
}
Response:
{
"user": {
"id": "uuid",
"email": "john@example.com",
"name": "John Doe",
"role": "user"
},
"token": "jwt_token_here"
}
{
"type": "join_room",
"room_id": "room_uuid",
"password": "optional_password"
}
{
"type": "send_message",
"room_id": "room_uuid",
"content": "Hello, world!",
"message_type": "text"
}
{
"type": "message",
"data": {
"id": "message_uuid",
"user": {
"id": "user_uuid",
"name": "John Doe"
},
"content": "Hello, world!",
"timestamp": "2024-01-01T12:00:00Z"
}
}
- Password Hashing: Argon2 algorithm
- JWT Token: Secure token-based authentication
- Rate Limiting: API request rate limiting
- CORS: Cross-origin request security
- SQL Injection: Protection via ORM usage
- XSS: Frontend sanitization
# Critical security settings
NEXTAUTH_SECRET=your-super-secret-key
JWT_SECRET=your-jwt-secret
DATABASE_URL=postgres://user:pass@localhost/db
# OAuth settings
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
- Use strong passwords
- Enable 2FA
- Keep environment variables secure
- Use HTTPS (in production)
- Perform regular updates
- Fork the project
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow code standards
- Write tests
- Update documentation
- Write descriptive commit messages
This project is licensed under the MIT License. See the LICENSE file for details.
Developed with β€οΈ