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
| Module | File | Contract |
|---|---|---|
auth | src/lib/auth.ts | auth / authClient |
authClient | src/lib/auth-client.ts | auth / authClient |
prisma | src/lib/prisma.ts | Prisma Client |
proxy | src/proxy.ts | Middleware |
Question / handler | src/pages/api/question.ts | Question API |
HeaderSimple | src/components/Navbar.tsx | UI Components |
Subgrid | src/components/DifficultyGrid.tsx | UI Components |
PartnerSearch | src/components/PartnerSearch.tsx | UI Components |
LoginPage | src/pages/login.tsx | Pages |
SignUpPage | src/pages/signup.tsx | Pages |
DashboardPage | src/pages/dashboard/index.tsx | Pages |
FindPartnerPage | src/pages/findPartnerPage.tsx | Pages |
| Socket.IO server | server.js | WebSocket |
PlayGameRoom | src/pages/playGame/[gameID].tsx | WebSocket |
CoderPOV | src/components/coderPOV.tsx | WebSocket |
TesterPOV | src/components/testerPOV.tsx | WebSocket |
ChatBox | src/components/ChatBox.tsx | WebSocket |
Error-handling conventions
- API handlers never throw. They return
{ error: string }with an appropriate status code. - Unexpected errors are logged with
console.errorbefore sending a500. - Unauthenticated access to protected endpoints returns
401. - Wrong HTTP method returns
405. - Errors from
authClientare surfaced through theonErrorcallback or the returnederrorfield, not thrown.