A modern, real-time collaborative code editing platform built with Spring Boot and React
- Overview
- Features
- Architecture
- Tech Stack
- Prerequisites
- Getting Started
- Project Structure
- API Documentation
- WebSocket Events
- Configuration
- Development
- Docker Deployment
- Contributing
- License
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.
- 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
-
π 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
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) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- REST API: Traditional HTTP endpoints for CRUD operations
- WebSocket (STOMP): Real-time bidirectional communication for:
- Code synchronization
- Cursor position updates
- Chat messages
- Presence notifications
| 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 |
| 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 |
- Docker & Docker Compose: Containerization
- pgAdmin: Database management
- ESLint: Code linting
- PostCSS: CSS processing
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
git clone https://github.com/Rohith1905/codetogether.git
cd codetogetherCreate a PostgreSQL database:
CREATE DATABASE codetogether;
CREATE USER rohith WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE codetogether TO rohith;Update backend/src/main/resources/application.yml with your database credentials:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/codetogether
username: rohith
password: rohith19psqlcd backend
mvn clean install
mvn spring-boot:runThe backend will start on http://localhost:8081
cd frontend
npm install
npm run devThe frontend will start on http://localhost:5173
Run the entire stack with Docker Compose:
cd backend
docker-compose up -dThis will start:
- Backend:
http://localhost:8081 - PostgreSQL:
localhost:5432 - pgAdmin:
http://localhost:5050
For the frontend:
cd frontend
npm install
npm run devbackend/
βββ 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/
βββ 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
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register |
Register new user | No |
| POST | /api/auth/login |
Login user | No |
| 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 |
| 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 |
| 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 |
STOMP Endpoint: ws://localhost:8081/ws
| 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 |
| 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 |
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,metricsCreate .env file in frontend/:
VITE_API_BASE_URL=http://localhost:8081
VITE_WS_URL=ws://localhost:8081/wsBackend:
cd backend
mvn testFrontend:
cd frontend
npm run testFrontend:
npm run lintBackend:
mvn clean package
java -jar target/backend-0.0.1-SNAPSHOT.jarFrontend:
npm run build
npm run previewcd backend
docker-compose up --build- Backend API: http://localhost:8081
- PostgreSQL: localhost:5432
- pgAdmin: http://localhost:5050
- Email:
[email protected] - Password:
admin
- Email:
CodeTogether Team
- Email: [email protected]
- GitHub: @Rohith1905