- Conflict Resolution: Document contains datatype(eg. text, array, map, etc). Document updates are commutative, associative, and idempotent means changes applied to doc in any order results same output.
- Sync Protocol: Client sends a State Vector. Server calculates the between server doc and client doc and sends back only the missing updates.
- Awareness: Multiple users can edit same doc. Awareness protocol shares metadata about users (eg. cursor position, name, color) to other users in real-time.
- Users can do CRUD operations on doc.
- Multiple users can connect to same doc.
- Users can see real-time changes of other users on doc.
- Users can see realtime cursor movement of others.
- Millions of users, Millions of documents.
- Up to 100 concurrent users per document.
- Latency max 200ms.
- Documents to converge / consistency
-
Reverse Proxy: Client requests first hit the Reverse Proxy, which routes them to the appropriate backend services.
-
Load Balancer: The Load Balancer distributes incoming connections across multiple Editor Service instances (Currently only 2), using nginx round-robin distribution.
-
Server: The Server handles WebSocket connections, REST APIs with the database and Redis for persistence and pub/sub functionality.
-
MongoDB: The MongoDB database stores the document data, including the Y.Doc state and user awareness information. Currently using MongoDB Atlas.
-
Pub/Sub: The Pub/Sub system is implemented using Redis. It allows the websocket service instances to communicate with each other, Used to scale node.js servers horizontally.
| Layer | Choice | Why |
|---|---|---|
| Frontend | React + yjs(Data Structures) |
yjs handles CRDTs and it is Local-first architecture |
| Backend | Node.js + ws + Redis + yjs(Data Structures) |
pairs well with yjs |
| DB | MongoDB |
simple, deployable |
| Deploy | Hostinger VPS using Docker | Production environment |
Setup license for minio
-
Clone the repository
mkdir CoTex cd CoTex git clone https://github.com/tanujsharma911/CoTex.git . -
Install dependencies for both frontend and backend
cd client npm install cd ../server npm install -
Install latex compiler
- For Windows: Install MiKTeX from https://miktex.org/download
- For Mac OS: Install MacTeX from http://www.tug.org/mactex/
-
Create
.envfile in client folder. Paste thisVITE_HTTP_SEVER=http://localhost:3000 VITE_WS_SEVER=ws://localhost:3000 -
Create
.envfile in server folder. Paste this and update with your keysPORT=3000 CLIENT_URL=http://localhost:5173 TOKEN_SECRET=<RANDOM_LONG_STRING> TOKEN_EXPIRY=1d MONGODB_URL=<MONGO_DB_ATLAS_URL> REDIS_PORT=6379 REDIS_HOST=localhost -
Run Redis server (if not already running)
docker run -d \ --name redis \ -p 6379:6379 \ redis:latest -
Start the backend server
cd server npm run dev -
Start the frontend development server
cd client npm run dev -
Open the application in your browser at
http://localhost:5173and start collaborating on LaTeX documents in real-time!
-
Clone the repository
mkdir CoTex cd CoTex git clone https://github.com/tanujsharma911/CoTex.git . -
Create
.env.dockerfile in client folder. Paste thisVITE_HTTP_SEVER=http://localhost:8000 VITE_WS_SEVER=ws://localhost:8000 -
Create
.env.dockerfile in server folder. Paste this and update with your keysPORT=3000 CLIENT_URL=http://localhost:5175 TOKEN_SECRET=<RANDOM_LONG_STRING> TOKEN_EXPIRY=1d MONGODB_URL=<MONGO_DB_ATLAS_URL> REDIS_PORT=6379 REDIS_HOST=localhost -
Build tex compiler image
cd server docker build -t tex-compiler -f Dockerfile.tex . -
Start
docker compose up --build -
Open the application in your browser at
http://localhost:5175and start collaborating on LaTeX documents in real-time!

