How shalvirajpura2/devsync-collaborative-code-editor works
1. Overall shape
DevSync is a two-tier application: a React/Vite frontend and a Python/FastAPI backend. The frontend handles all user interaction and editor state, while the backend owns authentication verification, room persistence, WebSocket coordination, and Python code execution.
2. Frontend boundary
The frontend/ tree is a standalone SPA built with React, Vite, and a large Radix/shadcn UI layer. It is organized by page (LandingPage, AuthPage, RoomSelectionPage, EditorPage, SettingsPage) and shared components (AuthPanel, CodeEditor, DashboardLayout), which suggests a route-driven user experience rather than a component library.
3. Editor-centric UX
The main product surface is the collaborative editor page. CodeEditor is the central interactive component, with surrounding dashboard/layout components providing room context, navigation, and settings. The frontend also includes Firebase auth hooks and a small axios wrapper, indicating that user session state and API calls are encapsulated locally in the client.
4. Authentication flow
Firebase Authentication is the identity provider. The frontend uses the Firebase JS SDK to sign in/out and obtain user tokens; the backend uses Firebase Admin / token verification logic under backend/src/core/ to trust those tokens on API requests. This creates a clear trust boundary: Firebase authenticates users, FastAPI authorizes backend operations.
5. Backend API layer
backend/src/api/ contains the HTTP entry points, split into room-related routes and request handling. This is the public server boundary exposed to the frontend for room creation/joining, state fetches, and code-run requests. FastAPI is the framework, and Uvicorn is the runtime entrypoint.
6. Real-time collaboration layer
WebSocket support is separated into backend/src/services/websocket_manager.py, which strongly suggests a room-based fan-out model. The expected flow is: one client edits code, the backend receives the update over a socket, and the manager broadcasts the new state to all connected users in that room.
7. Room and state persistence
Room data is modeled in backend/src/models/room.py and stored in MongoDB via backend/src/db/mongodb.py. MongoDB is the persistent source of truth for room metadata and likely any saved room/editor state, while the database connection is configured through backend/src/core/config.py.
8. Code execution boundary
backend/src/services/code_executor.py isolates Python execution from the rest of the API. This is an important architectural boundary: collaboration traffic and execution traffic are separate concerns, with execution returning output/errors back to the room participants after server-side evaluation.
9. Backend support services
The core/ package centralizes cross-cutting infrastructure: configuration, Firebase admin setup, and auth helpers. That separation keeps the API routes thin and pushes environment-specific setup into one place, which is useful for deployment and testing.
10. Static assets and deployment shape
There is a built frontend artifact under backend/src/static/, alongside a separate source frontend in frontend/. That implies at least one deployment path where the backend serves prebuilt static assets, even though the project is also structured as two independently built apps. The GitHub Actions workflows reinforce this split, with one workflow for the backend and one for Azure Static Web Apps.
11. Local development and environment inputs
The backend expects MongoDB and Firebase service-account credentials; the frontend expects Firebase project config and optionally API/WebSocket base URLs. This means the system depends on three external services/config domains: Firebase Auth, MongoDB, and the backend API/WebSocket endpoint.
12. Testing and operational checks
The repository includes dedicated connection test scripts for MongoDB and Firebase, which indicates the most failure-prone integration points are infrastructure connectivity and auth setup. Those scripts are likely used as sanity checks rather than full application tests.
13. Primary end-to-end data flow
A user signs in with Firebase in the browser, joins or creates a room, and the frontend talks to FastAPI for room operations. Editing events go through WebSockets for live synchronization, room data is persisted in MongoDB, and explicit run actions invoke the backend code executor, with results broadcast back to connected clients.
Main entry points: api HTTP API · pages Pages · App.jsx SPA shell · core Auth core
Components 19
Frontend
React/Vite SPA and client-side state
- SPA shell · Top-level client application and route entrypoint
frontend/src/App.jsx - Pages · Landing, auth, room selection, editor, and settings screens
frontend/src/pages - Code editor · Main collaborative editing surface
frontend/src/components/CodeEditor.jsx - Dashboard layout · Room-scoped navigation and surrounding dashboard chrome
frontend/src/components/DashboardLayout.jsx - Auth panel · Sign-in and sign-out UI for Firebase auth
frontend/src/components/AuthPanel.jsx - Auth hook · Firebase session and token handling in the browser
frontend/src/hooks/useFirebaseAuth.js - API client · Client-side HTTP access to backend endpoints
frontend/src/lib/axios.js - Firebase SDK · Browser-side Firebase authentication integration
frontend/src/lib/firebase.js - UI kit · Shared component library used across the SPA
frontend/src/components/ui
Backend
FastAPI server, persistence, and execution
- Server entry · Backend application bootstrap and runtime entrypoint
backend/src/main.py - HTTP API · Room and request endpoints exposed to the frontend
backend/src/api - Auth core · Firebase admin setup and token verification helpers
backend/src/core - Room model · Room persistence structure and shape
backend/src/models/room.py - WebSocket manager · Room-based live update coordination
backend/src/services/websocket_manager.py - Code executor · Server-side Python execution boundary
backend/src/services/code_executor.py - Mongo store · MongoDB connection and room data access
backend/src/db/mongodb.py - Static build · Prebuilt frontend assets served by the backend
backend/src/static
External services
Identity and database dependencies
- Firebase Auth · User authentication provider
- MongoDB · Persistent room and state storage
Connections 21
- SPA shell → Pages: routes to · Route-driven user experience
- Pages → Code editor: hosts · Editor page centers the main workflow
- Pages → Auth panel: hosts · Authentication surface for sign-in
- Pages → Dashboard layout: wraps · Room and dashboard chrome around pages
- Code editor → UI kit: uses · Editor and surrounding screens share UI primitives
- Dashboard layout → UI kit: uses · Layout builds on shared components
- Auth panel → Firebase SDK: signs in via · Browser authentication flow
- Auth hook → Firebase SDK: consumes · Session and token access
- SPA shell → API client: calls · Room and execution requests to backend
- API client → HTTP API: requests · HTTP boundary into the server
- Auth hook → Auth core: token sent to · Authenticated requests carry Firebase credentials
- Server entry → HTTP API: mounts · FastAPI route layer
- HTTP API → Auth core: verifies · Token/auth checks on incoming requests
- HTTP API → Room model: loads · Room payloads and state shape
- HTTP API → Mongo store: persists · Room metadata and stored state
- HTTP API → WebSocket manager: coordinates · Live collaboration events
- HTTP API → Code executor: runs code · Explicit execution requests
- Room model → Mongo store: stored in · Room records backed by MongoDB
- Auth core → Firebase Auth: trusts · Firebase admin verification boundary
- Mongo store → MongoDB: connects to · MongoDB persistence backend
- SPA shell → Static build: served as · Backend can serve built frontend assets