How sahishy/studium-app works
Purpose and Topology
This is a Firebase-backed student platform with a React/Vite frontend and Node backend. It combines personal/circle agendas, courses and reviews, profiles/social graphs, and real-time multiplayer SAT-style games. Firebase configuration and security boundaries are defined in firebase.json, firestore.rules, and storage.rules.
Application Entry Points
The browser application starts at frontend/src/main.jsx, composes routing and application UI in frontend/src/App.jsx, and initializes Firebase client access in frontend/src/lib/firebase.jsx. The backend entry is backend/src/index.js; it uses Admin SDK initialization from backend/src/lib/firebaseAdmin.js, exposing server-side multiplayer/game endpoints and triggers.
Frontend Feature Architecture
Feature folders own pages, state contexts, UI, and client Firebase/service adapters. Core user-facing domains include:
• Agenda task lifecycle and board/calendar/list views: frontend/src/features/agenda/contexts/TasksContext.jsx, frontend/src/features/agenda/services/taskService.jsx, frontend/src/features/agenda/pages/Agenda.jsx.
• Authentication and user provisioning: frontend/src/features/auth/contexts/AuthContext.jsx, frontend/src/features/auth/services/userService.jsx.
• Course catalog, enrollment, teachers, and reviews: frontend/src/features/courses/contexts/CoursesContext.jsx, frontend/src/features/courses/services/courseService.jsx, frontend/src/features/courses/pages/Courses.jsx.
• Profiles, stats/XP, and avatars: frontend/src/features/profile/contexts/UserStatsContext.jsx, frontend/src/features/profile/services/statsService.jsx, frontend/src/features/profile/services/avatarService.jsx.
• Friends and circles, including shared circle agendas: frontend/src/features/socials/contexts/CirclesContext.jsx, frontend/src/features/socials/services/circleService.jsx, frontend/src/features/socials/pages/CircleAgenda.jsx.
Route, Session, and UI Boundaries
Route guards and index redirects centralize navigation constraints, notably authenticated access and multiplayer-session routing: frontend/src/routes/PrivateRoute.jsx, frontend/src/routes/MultiplayerSessionRedirect.jsx, frontend/src/routes/MaintenanceRoute.jsx. Shared modal/toast contexts and reusable components provide cross-feature interaction primitives: frontend/src/shared/contexts/ModalContext.jsx, frontend/src/shared/contexts/ToastContext.jsx, frontend/src/shared/components/ui/Sidebar.jsx.
Multiplayer Control Plane
Multiplayer is split between a frontend session context/game renderer and authoritative backend services. The client starts matchmaking, joins rooms, observes chat/session state, and dispatches games through frontend/src/features/multiplayer/contexts/MultiplayerContext.jsx, frontend/src/features/multiplayer/services/matchmakingService.jsx, and frontend/src/features/multiplayer/games/GameHandler.jsx. The backend routes requests through controllers/services into persistence repositories: backend/src/features/multiplayer/routes/multiplayerRoutes.js, backend/src/features/multiplayer/services/roomService.js, backend/src/features/multiplayer/repositories/roomRepository.js.
SAT Classic Game Flow
SAT Classic is a paired client/server game module. Client gameplay renders questions, answers, health, and match end state in frontend/src/features/multiplayer/games/sat-classic/SatClassicGame.jsx, submitting actions through frontend/src/features/multiplayer/games/sat-classic/services/satClassicGameService.jsx. Backend game routes invoke controller/service logic, using the bundled question source backend/src/data/dsat_questions.json: backend/src/features/multiplayer/games/sat-classic/routes/satClassicRoutes.js, backend/src/features/multiplayer/games/sat-classic/services/satClassicService.js.
Data, Infrastructure, and External Boundaries
Firebase is the primary platform: client-side Auth/Firestore/Storage access is mediated by feature services; backend Admin SDK code performs trusted mutations and room-event triggers (backend/src/features/multiplayer/triggers/roomTriggers.js). Local Firebase Emulator exports exist under emulator-data/, supporting development through the root emulator command. The frontend also has shared API, AI, storage, cache, and content-censor service boundaries: frontend/src/shared/services/apiService.jsx, frontend/src/shared/services/aiService.jsx, frontend/src/shared/services/storageService.jsx.
Main entry points: App.jsx App shell & routes · firebase.jsx Firebase client · firebase.json Auth, Firestore & Storage · index.js Backend entry
Components 22
React frontend
- Browser entry
frontend/src/main.jsx - App shell & routes
frontend/src/App.jsx - Route guards · Protects authenticated, maintenance, and multiplayer-session routes.
frontend/src/routes/PrivateRoute.jsx - Firebase client
frontend/src/lib/firebase.jsx - Agenda domain · Supports personal and circle task lifecycle and agenda views.
frontend/src/features/agenda/contexts/TasksContext.jsx - Auth & provisioning
frontend/src/features/auth/contexts/AuthContext.jsx - Courses domain · Catalog, enrollment, teachers, and reviews.
frontend/src/features/courses/contexts/CoursesContext.jsx - Profile & XP
frontend/src/features/profile/contexts/UserStatsContext.jsx - Friends & circles · Includes shared circle agendas.
frontend/src/features/socials/contexts/CirclesContext.jsx - Shared UI contexts
frontend/src/shared/contexts/ModalContext.jsx - Shared client services
frontend/src/shared/services/apiService.jsx - Multiplayer session · Starts matchmaking and observes room and chat state.
frontend/src/features/multiplayer/contexts/MultiplayerContext.jsx - Game dispatcher
frontend/src/features/multiplayer/games/GameHandler.jsx - SAT Classic client
frontend/src/features/multiplayer/games/sat-classic/SatClassicGame.jsx
Node backend
- Backend entry
backend/src/index.js - Firebase Admin
backend/src/lib/firebaseAdmin.js - Room control plane · Authoritative room lifecycle and persistence operations.
backend/src/features/multiplayer/services/roomService.js - SAT Classic authority · Validates game actions and drives match state.
backend/src/features/multiplayer/games/sat-classic/services/satClassicService.js - DSAT questions
backend/src/data/dsat_questions.json - Room event triggers
backend/src/features/multiplayer/triggers/roomTriggers.js
Firebase platform
- Auth, Firestore & Storage · Security boundaries are defined by Firebase and Firestore/Storage rules.
firebase.json - Emulator exports
Connections 29
- Browser entry → App shell & routes: mounts
- App shell & routes → Route guards: applies
- App shell & routes → Auth & provisioning: provides session
- App shell & routes → Agenda domain: renders feature
- App shell & routes → Courses domain: renders feature
- App shell & routes → Profile & XP: renders feature
- App shell & routes → Friends & circles: renders feature
- App shell & routes → Multiplayer session: renders feature
- App shell & routes → Shared UI contexts: uses
- Auth & provisioning → Firebase client: authenticates via
- Agenda domain → Firebase client: persists tasks via
- Courses domain → Firebase client: reads and writes via
- Profile & XP → Firebase client: loads stats and avatars via
- Friends & circles → Firebase client: manages circles via
- Firebase client → Auth, Firestore & Storage: client access
- Multiplayer session → Shared client services: uses API
- Multiplayer session → Game dispatcher: dispatches
- Game dispatcher → SAT Classic client: renders
- SAT Classic client → Shared client services: submits actions
- Shared client services → Backend entry: HTTP requests
- Backend entry → Firebase Admin: initializes
- Backend entry → Room control plane: routes multiplayer
- Backend entry → SAT Classic authority: routes SAT game
- Room control plane → Auth, Firestore & Storage: persists rooms
- SAT Classic authority → DSAT questions: loads questions
- SAT Classic authority → Auth, Firestore & Storage: updates match state
- Room event triggers → Auth, Firestore & Storage: reacts to room events
- Firebase Admin → Auth, Firestore & Storage: trusted access
- Emulator exports → Auth, Firestore & Storage: local emulator state