A real-time collaborative document editing application that allows multiple users to edit the same document simultaneously from different devices.
- Real-time collaborative editing - Multiple users can edit the same document simultaneously
- Rich text formatting - Support for bold, italic, underline, headers, lists, and colors
- Conflict resolution - Uses Operational Transformation to merge concurrent edits
- WebSocket synchronization - Low-latency bidirectional communication
- Offline support - Queue changes when disconnected and sync on reconnection
- Auto-save - Documents are automatically persisted to storage
- AWS deployment - Production-ready infrastructure with auto-scaling
- Frontend: React 18 + Vite + Quill editor + Socket.io-client
- Backend: Node.js + Express + Socket.io WebSocket server
- Database: AWS DynamoDB for document persistence
- Infrastructure: AWS ECS Fargate, Application Load Balancer, S3 + CloudFront CDN
- IaC: AWS CDK for infrastructure as code
- Node.js 18+ - Download
- npm - Comes with Node.js
- AWS CLI (for deployment) - Installation guide
- AWS CDK (for deployment) - Install with
npm install -g aws-cdk
-
Clone the repository
git clone <repository-url> cd collaborative-editor
-
Install dependencies
# Install all dependencies at once cd client && npm install cd ../server && npm install cd ../infrastructure && npm install cd ..
-
Configure environment variables
Client configuration:
cd client cp .env.example .env # Edit .env if needed (default: http://localhost:3001)
Server configuration:
cd server cp .env.example .env # Edit .env if needed (defaults are set for local development)
Option 1: Run both servers together (recommended)
npm run devOption 2: Run servers separately
# Terminal 1 - Start the backend server
npm run dev:server
# Terminal 2 - Start the frontend dev server
npm run dev:clientThe application will be available at:
- Frontend: http://localhost:5173
- Backend: http://localhost:3001
- Hot reloading - Both frontend and backend support hot reloading
- In-memory storage - No DynamoDB required for local development
- CORS enabled - Configured for localhost development
Run all tests:
npm testRun tests for specific components:
npm run test:client # Frontend tests
npm run test:server # Backend testsRun tests in watch mode (for development):
cd client && npm run test:watch
# or
cd server && npm run test:watchBuild the frontend application:
npm run buildThis creates an optimized production build in client/dist/.
-
Configure AWS credentials
aws configure
Enter your AWS Access Key ID, Secret Access Key, and preferred region.
-
Bootstrap CDK (only needed once per AWS account/region)
npm run deploy:bootstrap
-
Review infrastructure changes (optional)
npm run deploy:diff
-
Deploy to AWS
npm run deploy
This command will:
- Build the frontend application
- Deploy the CDK stack (DynamoDB, ECS, ALB, S3, CloudFront)
- Upload frontend assets to S3
- Deploy the backend container to ECS Fargate
The deployment takes approximately 10-15 minutes.
-
Get deployment URLs
After deployment completes, CDK will output:
- CloudFront URL - Your frontend application URL
- ALB DNS Name - Your backend WebSocket server URL
- DynamoDB Table Name - The document storage table
-
Update frontend environment
Update
client/.envwith the production backend URL:VITE_SERVER_URL=https://your-alb-url.amazonaws.comThen redeploy:
npm run deploy
To remove all AWS resources and avoid charges:
npm run deploy:destroyWarning: This will delete all documents stored in DynamoDB.
collaborative-editor/
├── client/ # React frontend application
│ ├── src/
│ │ ├── components/
│ │ │ ├── Editor.jsx # Quill editor component
│ │ │ └── Editor.test.jsx # Editor tests
│ │ ├── App.jsx # Root component
│ │ ├── socket.js # WebSocket connection
│ │ └── main.jsx # Application entry point
│ ├── .env.example # Environment variables template
│ └── package.json
│
├── server/ # Node.js WebSocket server
│ ├── server.js # Main server file
│ ├── documentStore.js # Storage abstraction
│ ├── server.test.js # Server tests
│ ├── .env.example # Environment variables template
│ ├── Dockerfile # Container image definition
│ └── package.json
│
├── infrastructure/ # AWS CDK infrastructure code
│ ├── lib/
│ │ └── stack.js # CDK stack definition
│ ├── app.js # CDK app entry point
│ └── package.json
│
├── package.json # Root package.json with scripts
└── README.md # This file
| Variable | Description | Default |
|---|---|---|
VITE_SERVER_URL |
WebSocket server URL | http://localhost:3001 |
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3001 |
CLIENT_URL |
Frontend URL for CORS | http://localhost:5173 |
USE_DYNAMODB |
Enable DynamoDB storage | false |
DYNAMODB_TABLE_NAME |
DynamoDB table name | CollaborativeDocuments |
AWS_REGION |
AWS region | us-east-1 |
| Script | Description |
|---|---|
npm run dev |
Run both client and server in development mode |
npm run dev:client |
Run only the frontend dev server |
npm run dev:server |
Run only the backend dev server |
npm run build |
Build the frontend for production |
npm test |
Run all tests (client + server) |
npm run test:client |
Run frontend tests |
npm run test:server |
Run backend tests |
npm run deploy |
Deploy to AWS |
npm run deploy:bootstrap |
Bootstrap CDK (first-time setup) |
npm run deploy:diff |
Preview infrastructure changes |
npm run deploy:destroy |
Remove all AWS resources |
- Open the application in your browser
- Start typing - Your changes are automatically saved
- Share the URL with collaborators - They'll see your changes in real-time
- Format text using the toolbar (bold, italic, headers, lists, colors)
- Connection status is shown in the header (green = connected, red = disconnected)
- Active users count is displayed in the header
If port 3001 or 5173 is already in use:
# Change the port in server/.env
PORT=3002
# Change the port in client/.env
VITE_SERVER_URL=http://localhost:3002- Ensure the backend server is running
- Check that
VITE_SERVER_URLinclient/.envmatches the server URL - Verify firewall settings allow WebSocket connections
- Ensure the ECS task role has DynamoDB permissions
- Verify
USE_DYNAMODB=truein production environment - Check CloudWatch logs for detailed error messages
- Ensure AWS credentials are configured:
aws configure - Run
npm run deploy:bootstrapif you haven't bootstrapped CDK - Check that you have sufficient AWS permissions
- Document load time: < 1 second for documents up to 100KB
- Change propagation: < 100ms latency
- Concurrent users: Supports 1000+ users per document
- Document size limit: 10 MB maximum
- Auto-scaling: ECS tasks scale based on CPU/memory utilization
- HTTPS/WSS: All production traffic uses secure connections
- CORS: Configured to allow only specified origins
- Input validation: Document IDs and operations are validated
- Rate limiting: 100 operations per second per client
- DynamoDB encryption: Data encrypted at rest
MIT