This guide will help you set up the Real-Time Collaborative Document Editor on your local machine or server.
-
Clone the repository
git clone https://github.com/Anjan50/real-time-collaborative-editor.git cd real-time-collaborative-editor -
Configure environment variables
cp .env.example .env # Edit .env with your AWS credentials -
Create DynamoDB table
- Go to AWS Console → DynamoDB
- Create table named
SocketDocuments - Set partition key:
id(String) - Leave other settings as default
-
Start the application
docker-compose up --build
-
Access the application
- Open browser: http://localhost
- Create a new document or navigate to
/editor/{document-id}
-
Navigate to backend directory
cd backend -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set environment variables
export AWS_ACCESS_KEY_ID=your-key export AWS_SECRET_ACCESS_KEY=your-secret export AWS_DEFAULT_REGION=us-east-1
-
Run the server
uvicorn main:app --reload --port 8000
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Start development server
npm start
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- Log in to AWS Console
- Navigate to DynamoDB service
- Click "Create table"
- Configure:
- Table name:
SocketDocuments - Partition key:
id(String) - Table settings: Use default settings
- Table name:
- Click "Create table"
{
"TableName": "SocketDocuments",
"KeySchema": [
{
"AttributeName": "id",
"KeyType": "HASH"
}
],
"AttributeDefinitions": [
{
"AttributeName": "id",
"AttributeType": "S"
}
]
}| Variable | Description | Example |
|---|---|---|
AWS_ACCESS_KEY_ID |
AWS access key | AKIAIOSFODNN7EXAMPLE |
AWS_SECRET_ACCESS_KEY |
AWS secret key | wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
AWS_DEFAULT_REGION |
AWS region | us-east-1 |
| Variable | Description | Example |
|---|---|---|
ECR_REGISTRY |
AWS ECR registry URL | 123456789.dkr.ecr.us-east-1.amazonaws.com |
GIT_BRANCH |
Git branch name | main |
Problem: Unable to locate credentials
Solution:
- Verify AWS credentials in
.envfile - Check AWS credentials have DynamoDB permissions
- Ensure
AWS_DEFAULT_REGIONis set correctly
Problem: WebSocket connection not establishing Solution:
- Check backend is running on port 8000
- Verify Nginx configuration if using Docker
- Check firewall settings
Problem: Address already in use
Solution:
- Change port in
docker-compose.yml - Or stop the process using the port:
# Find process lsof -i :8000 # Linux/Mac netstat -ano | findstr :8000 # Windows # Kill process kill -9 <PID> # Linux/Mac taskkill /PID <PID> /F # Windows
Problem: Build errors during docker-compose up --build
Solution:
- Check Docker is running
- Verify Docker has enough resources allocated
- Try rebuilding without cache:
docker-compose build --no-cache
-
Launch EC2 instance
- Choose Ubuntu 20.04 or later
- Configure security group to allow ports 80, 443, 22
-
Install Docker and Docker Compose
sudo apt update sudo apt install docker.io docker-compose -y sudo usermod -aG docker $USER -
Clone and configure
git clone https://github.com/Anjan50/real-time-collaborative-editor.git cd real-time-collaborative-editor cp .env.example .env # Edit .env with production credentials
-
Start services
sudo docker-compose up -d
-
Set up domain (optional)
- Point domain to EC2 public IP
- Configure SSL certificate (Let's Encrypt recommended)
-
Test document creation
- Navigate to http://localhost
- Click "New Document" or go to
/editor/{new-id} - Verify document loads
-
Test real-time collaboration
- Open document in two browser windows
- Type in one window
- Verify changes appear in other window
-
Test persistence
- Create/edit document
- Close browser
- Reopen document
- Verify content is saved
Use curl or Postman to test endpoints:
# Health check
curl http://localhost/api/hello
# Get document
curl http://localhost/api/database/documents/get/{document-id}
# Create document
curl -X POST http://localhost/api/database/documents \
-H "Content-Type: application/json" \
-d '{"id": "test-id", "Data": "Hello World"}'- Review ARCHITECTURE.md for system design details
- Check CONTRIBUTING.md for contribution guidelines
- See README.md for project overview