Skip to content

Repository files navigation

Unison - Real-Time Collaboration Platform

Build StatusLicenseTypeScriptNode.jsExpressPrismaRedisSocket.IO

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.

Architecture

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]
Loading

Features

  • 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.

Tech Stack

CategoryTechnologyDescription
RuntimeNode.jsJavaScript runtime environment
FrameworkExpressWeb framework for Node.js
LanguageTypeScriptTyped superset of JavaScript
DatabasePostgreSQLRelational database system
ORMPrismaNext-generation ORM
CachingRedisIn-memory data structure store
Real-timeSocket.IOReal-time event-based communication

Quick Start

Prerequisites

  • Node.js v18+
  • PostgreSQL database
  • Redis server
  • npm or yarn

Installation

  1. Clone the repository:

    git clone https://github.com/ellay21/Unison.git
    cd Unison
  2. Install dependencies:

    npm install
  3. Configure environment:

    cp .env.example .env
    # Update .env with your database and redis credentials
  4. Initialize database:

    npx prisma db push
    npx prisma generate
  5. Start the server:

    npm run dev

The server will start on http://localhost:3000.

Docker Deployment

  1. Build the image:

    docker build -t unison-backend .
  2. Run the container:

    docker run -p 3000:3000 --env-file .env unison-backend

API Documentation

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.

Key Endpoints

MethodEndpointDescription
POST/api/auth/registerRegister a new user
POST/api/auth/loginLogin and receive JWT
GET/api/documentsList user documents
POST/api/documentsCreate a new document
WSdocument:joinJoin a collaboration session

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request Distributed under the MIT License. See LICENSE for more information.

About

Backend for a real-time collaborative editor featuring conflict-free synchronization

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages