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!