Skip to main content

Internal Code Contracts

Contracts must stay in sync with the implementation. If a method signature, exception condition, or behavior changes, update the contract in the same PR.

Modules

ModuleFileContract
authsrc/lib/auth.tsauth / authClient
authClientsrc/lib/auth-client.tsauth / authClient
prismasrc/lib/prisma.tsPrisma Client
proxysrc/proxy.tsMiddleware
Question / handlersrc/pages/api/question.tsQuestion API
HeaderSimplesrc/components/Navbar.tsxUI Components
Subgridsrc/components/DifficultyGrid.tsxUI Components
PartnerSearchsrc/components/PartnerSearch.tsxUI Components
LoginPagesrc/pages/login.tsxPages
SignUpPagesrc/pages/signup.tsxPages
DashboardPagesrc/pages/dashboard/index.tsxPages
FindPartnerPagesrc/pages/findPartnerPage.tsxPages
Socket.IO serverserver.jsWebSocket
PlayGameRoomsrc/pages/playGame/[gameID].tsxWebSocket
CoderPOVsrc/components/coderPOV.tsxWebSocket
TesterPOVsrc/components/testerPOV.tsxWebSocket
ChatBoxsrc/components/ChatBox.tsxWebSocket

Error-handling conventions

  • API handlers never throw. They return { error: string } with an appropriate status code.
  • Unexpected errors are logged with console.error before sending a 500.
  • Unauthenticated access to protected endpoints returns 401.
  • Wrong HTTP method returns 405.
  • Errors from authClient are surfaced through the onError callback or the returned error field, not thrown.