Unison is a powerful, scalable backend for real-time document collaboration. Built with performance and reliability in mind, it leverages Socket.IO and Yjs for conflict-free replicated data types (CRDTs), ensuring seamless multi-user editing experiences.
- 🔄 Real-time Collaboration: Instant updates with Socket.IO and Yjs CRDT.
- 🔐 Secure Authentication: JWT-based auth with Passport.js (Google/GitHub OAuth support).
- 🗄️ Robust Database: PostgreSQL managed via Prisma ORM.
- ⚡ High Performance: Redis caching and Pub/Sub for horizontal scaling.
- 🛡️ Security First: Rate limiting, input validation (Zod), and secure headers.
- 🐳 Docker Ready: Full containerization support for easy deployment.
- 📝 Type Safety: 100% TypeScript codebase.
- Node.js v18+
- PostgreSQL database
- Redis server
- npm or yarn
-
Clone the repository:
git clone https://github.com/ellay21/Unison.git cd Unison -
Install dependencies:
npm install
-
Configure environment:
cp .env.example .env # Update .env with your database and redis credentials -
Initialize database:
npx prisma db push npx prisma generate
-
Start the server:
npm run dev
The server will start on http://localhost:3000.
-
Build the image:
docker build -t unison-backend . -
Run the container:
docker run -p 3000:3000 --env-file .env unison-backend
The API is fully documented using .http files for easy testing.
api-docs.http: Detailed API endpoint descriptions.api-test.http: Ready-to-use requests for testing all endpoints.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/register |
Register a new user |
POST |
/api/auth/login |
Login and receive JWT |
GET |
/api/documents |
List user documents |
POST |
/api/documents |
Create a new document |
WS |
document:join |
Join a collaboration session |
graph TD
Client[Client App] <-->|WebSocket| Socket[Socket.IO Server]
Client <-->|HTTP| API[Express API]
Socket <-->|Pub/Sub| Redis[Redis]
API -->|Query| Prisma[Prisma ORM]
Prisma -->|Persist| DB[(PostgreSQL)]
Socket -->|Sync| Yjs[Yjs CRDT]
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
Distributed under the MIT License. See LICENSE for more information.