A full-stack real-time collaborative document editing platform inspired by Google Docs, built with modern web technologies. Multiple users can edit documents simultaneously with changes reflected in real-time across all connected clients.
- Features
- Tech Stack
- Architecture
- Project Structure
- Getting Started
- API Documentation
- Deployment
- Contributing
- License
- Real-Time Collaboration: Multiple users can edit documents simultaneously with instant synchronization
- WebSocket Communication: Low-latency bidirectional communication for real-time updates
- Document Persistence: All documents are stored in AWS DynamoDB for reliable data persistence
- RESTful API: Clean REST API endpoints for document management operations
- Responsive UI: Modern React-based user interface with rich text editing capabilities
- Dockerized Deployment: Containerized application for easy deployment and scaling
- Reverse Proxy: Nginx configuration for efficient request routing
- React 18.3 - Modern UI library
- React Router - Client-side routing
- Quill - Rich text editor
- WebSockets - Real-time communication
- Axios - HTTP client
- FastAPI - High-performance Python web framework
- WebSockets - Real-time bidirectional communication
- Boto3 - AWS SDK for Python
- Pydantic - Data validation
- AWS DynamoDB - NoSQL database for document storage
- Docker - Containerization
- Docker Compose - Multi-container orchestration
- Nginx - Reverse proxy and load balancer
┌─────────────────────────────────────────────────────────────┐
│ Client Browser │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ React Frontend Application │ │
│ │ - Document Editor (Quill) │ │
│ │ - WebSocket Client │ │
│ │ - REST API Client │ │
│ └──────────────────────────────────────────────────────┘ │
└────────────────────┬───────────────────┬────────────────────┘
│ │
│ HTTP/REST │ WebSocket
│ │
┌────────────────────▼───────────────────▼────────────────────┐
│ Nginx (Port 80) │
│ Reverse Proxy & Load Balancer │
└────────────────────┬───────────────────┬────────────────────┘
│ │
┌───────────┘ └───────────┐
│ │
┌────────▼────────┐ ┌─────────▼─────────┐
│ Frontend │ │ Backend │
│ Container │ │ Container │
│ (Port 3000) │ │ (Port 8000) │
│ │ │ │
│ - React App │ │ - FastAPI │
│ - Static Files │ │ - WebSocket API │
│ │ │ - REST API │
└─────────────────┘ └────────┬──────────┘
│
│ AWS SDK
│
┌──────────▼──────────┐
│ AWS DynamoDB │
│ Document Storage │
└─────────────────────┘
User Action → Frontend → WebSocket/REST → Backend → DynamoDB
↓ ↓
UI Update ← WebSocket Broadcast ← Backend
↓
Other Connected Users
1. Client connects to WebSocket endpoint (/api/socket/ws/{document_id})
2. Backend accepts connection and adds to active connections pool
3. Client requests document: {"key": "get-document", "value": document_id}
4. Backend fetches from DynamoDB and sends document data
5. User makes changes → Client sends: {"key": "changes-received", "value": delta}
6. Backend broadcasts changes to all other connected clients
7. Client saves periodically: {"key": "save-changes", "value": document_data}
8. Backend updates DynamoDB
real-time-collaborative-editor/
│
├── backend/ # FastAPI Backend Application
│ ├── api/ # API Routes
│ │ ├── __init__.py
│ │ ├── database_api.py # DynamoDB CRUD operations
│ │ ├── socket_api.py # WebSocket endpoints
│ │ ├── home_api.py # Home/test endpoints
│ │ └── SocketManager.py # WebSocket connection manager
│ │
│ ├── schema/ # Data Models
│ │ ├── __init__.py
│ │ └── Document.py # Document Pydantic model
│ │
│ ├── main.py # FastAPI application entry point
│ ├── requirements.txt # Python dependencies
│ └── Dockerfile # Backend container configuration
│
├── frontend/ # React Frontend Application
│ ├── public/ # Static assets
│ │ ├── index.html
│ │ └── ...
│ │
│ ├── src/ # React source code
│ │ ├── components/ # React components
│ │ │ ├── Home.js # Home page component
│ │ │ ├── TextEditor.js # Main editor component
│ │ │ └── ...
│ │ │
│ │ ├── App.js # Main App component
│ │ ├── index.js # Application entry point
│ │ └── ...
│ │
│ ├── package.json # Node.js dependencies
│ └── Dockerfile # Frontend container configuration
│
├── config/ # Configuration files
│ └── nginx.conf # Nginx reverse proxy configuration
│
├── docker-compose.yml # Multi-container orchestration
├── .gitignore # Git ignore rules
└── README.md # Project documentation
- Docker and Docker Compose installed
- AWS Account with DynamoDB access
- AWS Access Key ID and Secret Access Key
- Node.js 18+ (for local development)
- Python 3.8+ (for local development)
-
Clone the repository
git clone https://github.com/Anjan50/real-time-collaborative-editor.git cd real-time-collaborative-editor -
Set up AWS Credentials
Copy the example environment file and update with your credentials:
cp .env.example .env
Edit
.envfile with your AWS credentials:AWS_ACCESS_KEY_ID=your-access-key-id AWS_SECRET_ACCESS_KEY=your-secret-access-key AWS_DEFAULT_REGION=us-east-1 ECR_REGISTRY=your-ecr-registry GIT_BRANCH=main
-
Create DynamoDB Table
Create a table named
SocketDocumentsin AWS DynamoDB with:- Partition Key:
id(String)
- Partition Key:
-
Build and Run with Docker Compose
docker-compose up --build
-
Access the Application
- Frontend: http://localhost
- Backend API: http://localhost/api
- WebSocket: ws://localhost/api/socket/ws/{document_id}
cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000cd frontend
npm install
npm startGET /api/database/documents/get/{document_id}- Get document by IDGET /api/database/documents/getorcreate/{document_id}- Get or create documentPOST /api/database/documents- Create new documentPUT /api/database/documents/{document_id}- Update document
GET /api/hello- Health check endpointGET /api/home/test- Home API test endpoint
WS /api/socket/ws/{document_id}- WebSocket connection for real-time collaboration
Get Document:
{
"key": "get-document",
"value": "document_id"
}Send Changes:
{
"key": "changes-received",
"value": "delta_changes"
}Save Document:
{
"key": "save-changes",
"value": "document_content"
}The application is containerized and can be deployed using Docker Compose:
docker-compose up -d- Build Docker images
- Push to AWS ECR
- Deploy to EC2 or ECS
- Configure Nginx reverse proxy
- Set up environment variables
Required environment variables:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_DEFAULT_REGIONECR_REGISTRYGIT_BRANCH
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your 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 open source and available under the MIT License.
Anjan Diyora
- GitHub: @Anjan50
- Quill.js for the rich text editor
- FastAPI for the excellent Python web framework
- AWS DynamoDB for scalable document storage
⭐ If you find this project helpful, please consider giving it a star!