Skip to content

Rohith1905/codeTogether

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeTogether

A modern, real-time collaborative code editing platform built with Spring Boot and React

Version Java Spring Boot React TypeScript

πŸ“‹ Table of Contents

🌟 Overview

CodeTogether is a real-time collaborative code editing platform that enables multiple developers to work together on the same codebase simultaneously. Built with modern technologies, it provides seamless synchronization, live cursor tracking, integrated chat, and presence awareness.

Key Highlights

  • Real-time Collaboration: Multiple users can edit code simultaneously with instant synchronization
  • Live Presence Tracking: See who's online and what files they're working on
  • Cursor Synchronization: View other users' cursor positions in real-time
  • Integrated Chat: Communicate with team members without leaving the editor
  • Secure Authentication: JWT-based authentication with Spring Security
  • File & Folder Management: Organize your code with a hierarchical file structure
  • Code Editor: Powered by CodeMirror with syntax highlighting for multiple languages

✨ Features

Core Features

  • πŸ” User Authentication & Authorization

    • JWT-based secure authentication
    • User registration and login
    • Protected API endpoints
  • πŸ“ File & Folder Management

    • Create, read, update, and delete files and folders
    • Hierarchical folder structure
    • Room-based organization
  • πŸ‘₯ Real-time Collaboration

    • Multi-user code editing
    • Operational Transformation for conflict resolution
    • Live code synchronization across all connected clients
  • πŸ“ Presence & Cursor Tracking

    • See who's currently in the room
    • Track active users on specific files
    • Real-time cursor position sharing
  • πŸ’¬ Integrated Chat

    • Room-based messaging
    • Real-time message delivery via WebSocket
  • 🎨 Modern Code Editor

    • Syntax highlighting (JavaScript, Java, and more)
    • Auto-completion
    • Line numbers and code folding

πŸ—οΈ Architecture

CodeTogether follows a modern client-server architecture with real-time communication:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         Frontend                            β”‚
β”‚  React + TypeScript + Redux + CodeMirror + STOMP           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                        β”‚ HTTP/REST + WebSocket (STOMP)
                        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Backend                              β”‚
β”‚   Spring Boot + Spring Security + WebSocket + JWT          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Controllers β”‚ Services β”‚ Repositories β”‚ Security           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                        β”‚ JPA/Hibernate
                        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    PostgreSQL Database                      β”‚
β”‚              (Users, Rooms, Files, Folders)                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Communication Patterns

  • REST API: Traditional HTTP endpoints for CRUD operations
  • WebSocket (STOMP): Real-time bidirectional communication for:
    • Code synchronization
    • Cursor position updates
    • Chat messages
    • Presence notifications

πŸ› οΈ Tech Stack

Backend

Technology Version Purpose
Java 21 Programming language
Spring Boot 3.3.0 Application framework
Spring Security 6.x Authentication & authorization
Spring WebSocket 6.x Real-time communication
Spring Data JPA 3.x Data persistence
PostgreSQL 18 Relational database
Flyway Latest Database migrations
JWT (jjwt) 0.12.6 Token-based authentication
MapStruct 1.6.3 DTO mapping
Lombok Latest Boilerplate reduction
Maven 3.x Build tool

Frontend

Technology Version Purpose
React 19.2.0 UI library
TypeScript 5.9.3 Type-safe JavaScript
Vite 6.0.0 Build tool & dev server
Redux Toolkit 2.11.0 State management
React Router 7.9.6 Client-side routing
CodeMirror 4.25.3 Code editor component
STOMP.js 7.2.1 WebSocket client
Axios 1.13.2 HTTP client
TailwindCSS 3.4.17 Utility-first CSS
Lucide React 0.555.0 Icon library
React Hot Toast 2.6.0 Toast notifications

DevOps & Tools

  • Docker & Docker Compose: Containerization
  • pgAdmin: Database management
  • ESLint: Code linting
  • PostCSS: CSS processing

πŸ“¦ Prerequisites

Before running the application, ensure you have the following installed:

  • Java Development Kit (JDK): Version 21 or higher
  • Node.js: Version 18 or higher
  • npm: Version 9 or higher
  • PostgreSQL: Version 14 or higher (or use Docker)
  • Maven: Version 3.8 or higher
  • Docker (optional): For containerized deployment

πŸš€ Getting Started

Option 1: Local Development Setup

1. Clone the Repository

git clone https://github.com/Rohith1905/codetogether.git
cd codetogether

2. Setup PostgreSQL Database

Create a PostgreSQL database:

CREATE DATABASE codetogether;
CREATE USER rohith WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE codetogether TO rohith;

3. Configure Backend

Update backend/src/main/resources/application.yml with your database credentials:

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/codetogether
    username: rohith
    password: rohith19psql

4. Run Backend

cd backend
mvn clean install
mvn spring-boot:run

The backend will start on http://localhost:8081

5. Run Frontend

cd frontend
npm install
npm run dev

The frontend will start on http://localhost:5173

Option 2: Docker Deployment

Run the entire stack with Docker Compose:

cd backend
docker-compose up -d

This will start:

  • Backend: http://localhost:8081
  • PostgreSQL: localhost:5432
  • pgAdmin: http://localhost:5050

For the frontend:

cd frontend
npm install
npm run dev

πŸ“‚ Project Structure

Backend Structure

backend/
β”œβ”€β”€ src/main/java/com/codetogether/backend/
β”‚   β”œβ”€β”€ config/              # Configuration classes (Security, WebSocket, CORS)
β”‚   β”œβ”€β”€ controller/          # REST & WebSocket controllers
β”‚   β”œβ”€β”€ dto/                 # Data Transfer Objects
β”‚   β”œβ”€β”€ exception/           # Custom exceptions & global handler
β”‚   β”œβ”€β”€ mapper/              # Entity-DTO mappers (MapStruct)
β”‚   β”œβ”€β”€ model/               # JPA entities (User, Room, File, Folder)
β”‚   β”œβ”€β”€ repository/          # Spring Data JPA repositories
β”‚   β”œβ”€β”€ security/            # Security filters & components
β”‚   β”œβ”€β”€ service/             # Business logic layer
β”‚   β”‚   └── impl/            # Service implementations
β”‚   β”œβ”€β”€ util/                # Utility classes (JWT, etc.)
β”‚   └── websocket/           # WebSocket configuration & handlers
β”œβ”€β”€ src/main/resources/
β”‚   β”œβ”€β”€ db/migration/        # Flyway database migrations
β”‚   └── application.yml      # Application configuration
└── pom.xml                  # Maven dependencies

Frontend Structure

frontend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/                 # API service layer (Axios)
β”‚   β”œβ”€β”€ assets/              # Static assets (images, icons)
β”‚   β”œβ”€β”€ components/          # Reusable React components
β”‚   β”œβ”€β”€ features/            # Feature-specific modules
β”‚   β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”œβ”€β”€ pages/               # Page components (Login, Dashboard, Room)
β”‚   β”œβ”€β”€ store/               # Redux store & slices
β”‚   β”œβ”€β”€ utils/               # Utility functions
β”‚   β”œβ”€β”€ App.tsx              # Main application component
β”‚   └── main.tsx             # Application entry point
β”œβ”€β”€ public/                  # Public assets
β”œβ”€β”€ package.json             # npm dependencies
β”œβ”€β”€ vite.config.ts           # Vite configuration
β”œβ”€β”€ tailwind.config.js       # TailwindCSS configuration
└── tsconfig.json            # TypeScript configuration

πŸ“‘ API Documentation

Authentication Endpoints

Method Endpoint Description Auth Required
POST /api/auth/register Register new user No
POST /api/auth/login Login user No

Room Endpoints

Method Endpoint Description Auth Required
GET /api/rooms Get all rooms Yes
POST /api/rooms Create new room Yes
GET /api/rooms/{id} Get room by ID Yes
PUT /api/rooms/{id} Update room Yes
DELETE /api/rooms/{id} Delete room Yes

File Endpoints

Method Endpoint Description Auth Required
GET /api/files/room/{roomId} Get files in room Yes
POST /api/files Create new file Yes
PUT /api/files/{id} Update file Yes
DELETE /api/files/{id} Delete file Yes

Folder Endpoints

Method Endpoint Description Auth Required
GET /api/folders/room/{roomId} Get folders in room Yes
POST /api/folders Create new folder Yes
PUT /api/folders/{id} Update folder Yes
DELETE /api/folders/{id} Delete folder Yes

πŸ”Œ WebSocket Events

Connection

STOMP Endpoint: ws://localhost:8081/ws

Subscribe Destinations

Destination Description
/topic/room/{roomId}/editor Code changes in room
/topic/room/{roomId}/chat Chat messages in room
/topic/room/{roomId}/presence User presence updates
/topic/room/{roomId}/cursor Cursor position updates

Send Destinations

Destination Payload Description
/app/room/{roomId}/edit FileEditRequest Send code changes
/app/room/{roomId}/chat ChatMessage Send chat message
/app/room/{roomId}/cursor CursorPosition Send cursor position
/app/room/{roomId}/presence RoomPresenceRequest Update presence

βš™οΈ Configuration

Backend Configuration

Key configuration in application.yml:

server:
  port: 8081

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/codetogether
    username: rohith
    password: rohith19psql

jwt:
  secret: your-secret-key-here
  expiration: 86400000  # 24 hours

management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics

Frontend Configuration

Create .env file in frontend/:

VITE_API_BASE_URL=http://localhost:8081
VITE_WS_URL=ws://localhost:8081/ws

πŸ”§ Development

Running Tests

Backend:

cd backend
mvn test

Frontend:

cd frontend
npm run test

Linting

Frontend:

npm run lint

Building for Production

Backend:

mvn clean package
java -jar target/backend-0.0.1-SNAPSHOT.jar

Frontend:

npm run build
npm run preview

🐳 Docker Deployment

Build and Run with Docker Compose

cd backend
docker-compose up --build

Access Services


πŸ“ž Contact

CodeTogether Team


Made with ❀️ by the CodeTogether Team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors