A real-time collaborative document editing platform built with modern web technologies (Rust backend, React + TypeScript frontend). Features live collaboration, version history, and a beautiful user interface.
Try it out now! Experience real-time collaborative editing with our live demo:
π Live Demo - Collaborative Docs
Open the demo in multiple browser tabs to see real-time collaboration in action!
- Real-time Collaboration - Live editing with WebSocket-based synchronization
- Version History - Complete document history with timestamps and user tracking
- Beautiful UI - Modern React interface with Tailwind CSS
- User Authentication - Secure login and registration system
- Document Search - Full-text search across all documents
- Responsive Design - Works on desktop and mobile devices
- Production Ready - Docker support, comprehensive testing, and monitoring
This project follows a modern microservices architecture:
collaborative-docs/
βββ backend/ # Rust API server (Axum + PostgreSQL)
βββ frontend/ # React + TypeScript + Vite
βββ integration/ # End-to-end integration tests
Backend:
- Rust with Axum web framework
- PostgreSQL for data persistence
- WebSocket for real-time communication
- JWT for authentication
- Docker for containerization
Frontend:
- React 19 with TypeScript
- Vite for fast development
- Tailwind CSS for styling
- Radix UI for accessible components
- React Router for navigation
Testing:
- Jest for integration tests
- Vitest for unit tests
- Testing Library for component testing
- Rust (latest stable)
- Node.js (18+) and pnpm
- PostgreSQL (13+)
- Docker (optional, for containerized setup)
-
Clone the repository:
git clone https://github.com/yourusername/collaborative-docs.git cd collaborative-docs -
Start all services:
docker-compose up -d
-
Access the application:
- Frontend: http://localhost:5173
- Backend API: http://localhost:3000
-
Start the backend:
cd backend cargo run --bin collaborative-docs-rs -
Start the frontend:
cd frontend pnpm install pnpm dev -
Run integration tests (optional):
cd integration pnpm install pnpm test
For detailed deployment instructions, including port configuration, database setup, and reverse proxy configuration, see DEPLOYMENT.md.
- Backend: Configurable via
APP__SERVER__PORTenvironment variable or TOML config files - Frontend: Configurable via
VITE_PORTenvironment variable - Database: Configurable via
APP__DATABASE__PORTorDATABASE_URL
The application supports multiple database setup options:
- Docker PostgreSQL (automatic with docker-compose)
- Manual PostgreSQL installation
- Cloud database services (AWS RDS, Google Cloud SQL, etc.)
See DEPLOYMENT.md for complete database setup instructions.
collaborative-docs/
βββ backend/ # Rust API server
β βββ src/
β β βββ main.rs # Application entry point
β β βββ app.rs # Router and middleware
β β βββ handlers.rs # API endpoints
β β βββ database.rs # Database operations
β β βββ models.rs # Data structures
β β βββ config.rs # Configuration
β β βββ auth.rs # Authentication
β β βββ websocket.rs # Real-time communication
β β βββ crdt.rs # Conflict resolution
β βββ migrations/ # Database migrations
β βββ config/ # Configuration files
β βββ tests/ # Backend tests
βββ frontend/ # React application
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ services/ # API and WebSocket services
β β βββ contexts/ # React contexts
β β βββ lib/ # Utility functions
β βββ public/ # Static assets
βββ integration/ # End-to-end tests
β βββ src/
β β βββ websocket-crdt.test.ts
β β βββ websocket-deadlock.test.ts
β βββ jest.config.js
βββ docker-compose.yml # Docker orchestration
Copy the example environment file and modify as needed:
# Copy example environment file
cp env.example .env
# Edit the file with your settings
nano .envThe environment file includes configuration for:
- Database connection settings
- Server port and host configuration
- Frontend dev server settings
- CORS configuration
- Docker settings
- Production deployment settings
See env.example for all available options and their descriptions.
The backend uses TOML configuration files in backend/config/:
default.toml- Base configurationdevelopment.toml- Development overridesproduction.toml- Production overrides
cd backend
cargo testcd frontend
pnpm testcd integration
pnpm test# From project root
pnpm test:all-
Build and deploy:
docker-compose -f docker-compose.prod.yml up -d
-
Environment variables for production:
RUN_MODE=production RUST_LOG=warn DATABASE_URL=postgresql://user:pass@host:5432/db
-
Backend:
cd backend cargo build --release ./target/release/collaborative-docs-rs -
Frontend:
cd frontend pnpm build # Serve the dist/ directory with your web server
For comprehensive API documentation, see API_DOCUMENTATION.md.
Access the interactive Swagger UI at:
- Development:
http://localhost:3000/swagger-ui - Production:
https://api.example.com/swagger-ui
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/signup |
Register a new user |
POST |
/api/auth/login |
Authenticate user |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/doc |
Create a new document |
GET |
/api/doc/{id} |
Get document by ID |
PUT |
/api/doc/{id} |
Update document content |
GET |
/api/doc/{id}/history |
Get document version history |
GET |
/api/doc/{id}/stats |
Get document statistics |
GET |
/api/search?q=query |
Search documents |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/doc/{id}/crdt/state |
Get CRDT state |
POST |
/api/doc/{id}/crdt/update |
Apply CRDT update |
| Method | Endpoint | Description |
|---|---|---|
PUT |
/api/admin/users/{user_id}/role |
Update user role |
| Endpoint | Description |
|---|---|
ws://localhost:3000/ws/doc/{id} |
Real-time document collaboration |
GET /ws/info/{id} |
Get WebSocket connection info |
- JWT Authentication - Secure token-based authentication
- Input Validation - Comprehensive request validation
- CORS Protection - Configurable cross-origin policies
- SQL Injection Prevention - Parameterized queries
- Rate Limiting - Protection against abuse
-
Database Connection Errors:
# Check PostgreSQL is running brew services list | grep postgresql # Create database if needed createdb collaborative_docs
-
WebSocket Connection Issues:
# Check backend is running curl http://localhost:3000/api/doc # Check WebSocket endpoint curl http://localhost:3000/ws/info/test-doc
-
Frontend Build Errors:
# Clear node modules and reinstall cd frontend rm -rf node_modules pnpm-lock.yaml pnpm install
Enable debug logging:
# Backend
RUST_LOG=debug cargo run
# Frontend
pnpm dev --debug- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes following the existing code style
- Add tests for new functionality
- Run all tests to ensure nothing breaks
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Rust: Follow Rust best practices and use
cargo fmtandcargo clippy - TypeScript: Use strict TypeScript configuration and ESLint
- Testing: Maintain high test coverage for all new features
- Documentation: Update README files for any new features
This project is licensed under the MIT License - see the LICENSE file for details.
- Axum - Modern Rust web framework
- React - UI library
- Tailwind CSS - Utility-first CSS framework
- PostgreSQL - Reliable database
- WebSocket - Real-time communication protocol
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: riyad@islahlabs.com
Made with β€οΈ by the Collaborative Docs team