Full login-to-endpoint flow, broken into 9 phases. Each phase builds on the previous one.
These rules apply every single session, every single phase.
- Subpart by subpart (STRICT): Explain ONLY ONE subpart per message. STOP after each and wait for confirmation.
- Line-level explanation: Every code block must be explained line by line.
- Code diff: Without vs With: Show WHY a technology exists by comparing manual code vs the project's code.
- Assume zero knowledge: Explain concepts like "JWT", "Middleware", and "ORM" from scratch.
- Always consult docs: Use
ZOD_FLOW.mdandORM_FLOW.mdfor project-specific examples.
| # | Phase | Core Technology | File(s) |
|---|---|---|---|
| 1 | Contract Layer | Zod + oRPC Contract | frontend/src/shared/contract.ts |
| 2 | Auth Architecture | JWT + Orchid ORM | backend/src/router.ts, backend/db/tables/user.table.ts |
| 3 | Authentication Flow | React + oRPC mutations | frontend/src/App.tsx |
| 4 | Cookie Management | HTTP Cookies, jwt | backend/index.ts, backend/src/router.ts |
| 5 | Express Server | Express.js, CORS | backend/index.ts |
| 6 | Context Injection ⭐ | oRPC Context | backend/index.ts |
| 7 | oRPC Implementation | oRPC Handler + Orchid ORM | backend/src/router.ts |
| 8 | oRPC Frontend Client | @orpc/client, fetch |
frontend/src/orpc.ts |
| 9 | React Integration | TanStack Query + React Hooks | frontend/src/App.tsx |
File: frontend/src/shared/contract.ts
Technologies: Zod, oRPC Contract
Everything already covered in session!
Files: backend/src/router.ts, backend/db/tables/user.table.ts
Technologies: JWT, Orchid ORM, bcrypt (or plain password check)
| # | Subpart | What it covers |
|---|---|---|
| 2.1 | What is Auth? | Theoretical overview of login/register in this app |
| 2.2 | The User Table | How users are stored in PostgreSQL (user.table.ts) |
| 2.3 | Register Logic | Password hashing (if applicable) and .create() query |
| 2.4 | Login Logic | Finding users with .where() and validating credentials |
| 2.5 | JWT Basics | What is a token and how do we sign it? |
| 2.6 | Cookies | How res.cookie is used inside a handler |
File: frontend/src/App.tsx
Technologies: useForm, oRPC mutations
Files: Browser DevTools, backend/index.ts
Technologies: HTTP Cookies, cookie-parser
File: backend/index.ts
Technologies: Express.js, CORS, JSON parsing
File: backend/index.ts
Technologies: oRPC context system
Files: backend/src/router.ts, backend/db/
Technologies: Orchid ORM, oRPC Procedures
File: frontend/src/orpc.ts
Technologies: oRPC client, credentials: 'include'
File: frontend/src/App.tsx
Technologies: useQuery, useMutation, React state