Skip to main content

Internal Code Contracts

Contracts must stay in sync with implementation. If route behavior, context state, emitted/listened socket events, or component props change, update these docs in the same PR.

Frontend + context modules

ModuleFileContract
App shell and provider compositionsrc/pages/_app.tsxPages, Frontend Context Providers
Home + onboarding pagessrc/pages/index.tsx, src/pages/tutorial.tsxPages
Auth pagessrc/pages/login.tsx, src/pages/signup.tsxPages
Matchmaking flowsrc/pages/matchmaking.tsx, src/components/home/FindLobbySection.tsx, src/components/home/DifficultySection.tsxPages, UI Components
Game room flowsrc/pages/game/[gameID].tsxPages
Results flowsrc/pages/results/[gameID].tsx, src/hooks/useGameResults.tsPages
Socket lifecyclesrc/contexts/SocketContext.tsxFrontend Context Providers
Party + friend lifecyclesrc/contexts/PartyContext.tsx, src/contexts/FriendshipContext.tsxFrontend Context Providers
Matchmaking shared statesrc/contexts/MatchmakingContext.tsxFrontend Context Providers
Game-local shared statesrc/contexts/GameStateContext.tsx, src/contexts/GameTestCasesContext.tsxFrontend Context Providers
Navbar + side panelsrc/components/Navbar.tsx, src/components/sidebar/*UI Components
Game-room componentssrc/components/ProblemBox.tsx, src/components/ChatBox.tsx, src/components/GameTimer.tsx, src/components/gameTests/*UI Components
Results componentssrc/components/Analysisbox.tsx, src/components/TestCaseResultsBox.tsxUI Components

Shared backend modules

ModuleFileContract
auth./src/lib/auth.tsauth / authClient
authClient./src/lib/auth-client.tsauth / authClient
prisma./src/lib/prisma.tsPrisma Client
proxy./src/proxy.tsMiddleware
sockets./server/index.jsWebsockets
execution./server/sockets/handlers/executionHandlers.jsExecution

Error-handling conventions

  • API handlers should return typed error payloads with status codes (4xx/5xx) instead of crashing the process.
  • UI-level errors are surfaced through notification helpers (e.g., showErrorNotification) or local page-state messaging.
  • Unauthenticated access is guarded both by middleware/proxy rules and by page-level session checks.