How singhutsav5502/hacktivate_socialcalcclone works
Project type and purpose
• This is a full-stack, real-time collaborative spreadsheet web application (“SocialCalc Clone”).
• Frontend: React single-page app using Redux Toolkit for state, Material-UI/Emotion for styling, React Router for navigation, axios for REST, and socket.io-client for live collaboration.
• Backend: Node.js/Express server with REST routes for user/session management, Socket.IO for WebSocket communication, Mongoose for MongoDB persistence, and diff-match-patch for merge/patch logic.
Main components
a. Frontend (social_calc_clone_frontend)
• Browser / React App
• UI Components: Login, CardComponent, SessionMenu, Toolbar, Spreadsheet
• State Store: Redux slices (userSlice, sessionSlice) + store.js
• Networking: axios (HTTP), socket.io-client (WebSocket)
• Routing: react-router-dom
• Styling: Material-UI, Emotion, CSS modules
b. Backend (social_calc_clone_backend)
• Express HTTP Server (index.js)
• REST Routes: sessionRoutes.js (login, create/join sessions)
• WebSocket Server: socket.io integration in index.js
• Models: Mongoose schemas for User and Session
• Utilities: diff-match-patch for computing/applying patches, async-lock for concurrency
• Security/Config: dotenv (.env), CORS, SSL certificates folder (certificate.crt, private.key, ca_bundle.crt)
c. Database
• MongoDB instance (sessions, users collections)
d. External / Infrastructure
• SSL/TLS termination (certs)
• Environment variables:
– REACT_APP_SERVER_URL (frontend)
– MONGO_DB_URL (backend)
Relationships & Data Flow
1. Browser requests React app via HTTP (GET /index.html)
2. User authenticates or creates/join a session through REST API (axios POST/GET → Express routes → MongoDB)
3. Upon entering a sheet, front end opens a WebSocket (socket.io) to the backend
4. User edits spreadsheet cells → diff-match-patch on frontend computes patch → socket.emit(“edit”, patch)
5. Server receives patch → applies diff-match-patch on stored document → saves to MongoDB → broadcasts patch to other clients in same session
6. Other clients receive patch events → apply to local sheet state via Redux
Architectural Patterns & Principles
• Client-Server separation with clear REST & WebSocket layers
• Unidirectional state flow on frontend via Redux
• Event-driven, real-time collaboration using operational transforms (diff-match-patch)
• MVC-style on backend (routes → controllers in index.js → models → database)
• Config and secrets externalized via dotenv and SSL certs