|
| 1 | +# InternHack, Codex Instructions |
| 2 | + |
| 3 | +## Project Overview |
| 4 | +InternHack is a full-stack internship/career platform for students with AI-powered tools, learning modules, and recruiter features. |
| 5 | + |
| 6 | +## Quick Start |
| 7 | +- **Server:** `cd server && npm run dev` (runs `tsx watch src/index.ts`) |
| 8 | +- **Client:** `cd client && npm run dev` (Vite on port 5173) |
| 9 | +- **Migrations:** Must run from `server/src/database/`, that's where `prisma.config.ts` lives |
| 10 | + |
| 11 | +## Repo Map |
| 12 | +**Always read `.Codex/REPO_MAP.md` before any editing task.** It maps every module, route, model, and component. |
| 13 | + |
| 14 | +## Stack |
| 15 | +- **Client:** React 18 + Vite 7 + TailwindCSS 4 + React Router 7 + Framer Motion + Zustand + React Query |
| 16 | +- **Server:** Express 5 + TypeScript 5 + Prisma 7 + PostgreSQL |
| 17 | +- **AI:** Google Gemini (`gemini-2.5-flash-lite`) |
| 18 | +- **Auth:** JWT in `Authorization: Bearer <token>` header; Zustand auth store on client |
| 19 | +- **Payments:** dodo payment |
| 20 | +- **Storage:** AWS S3 with local fallback |
| 21 | + |
| 22 | +## Code Style Rules |
| 23 | + |
| 24 | +### TailwindCSS v4 |
| 25 | +- Use canonical TW v4 classes only |
| 26 | +- No `bg-gradient-*` shorthand, use `bg-linear-to-*` instead |
| 27 | +- No arbitrary bracket sizes like `text-[17px]`, use standard scale classes |
| 28 | +- No gradient backgrounds on icons, use flat color or bare colored icons |
| 29 | + |
| 30 | +### UI Conventions |
| 31 | +- **No pill badges**, do not use `rounded-full` category/section tag pills above page headings. Use `mt-6` on the header wrapper for top spacing instead |
| 32 | +- Company avatars: first-letter initial in neutral box, not generic icon |
| 33 | +- DRY: no duplicate helpers, shared animation variants per file |
| 34 | + |
| 35 | +### TypeScript |
| 36 | +- Strict mode enabled on both client and server |
| 37 | +- Use Zod for all server-side validation (see `*.validation.ts` files) |
| 38 | +- Client types mirror server models in `client/src/lib/types.ts` |
| 39 | + |
| 40 | +### Module Pattern (Server) |
| 41 | +Every server module follows: `<name>.routes.ts` → `<name>.controller.ts` → `<name>.service.ts` |
| 42 | +- Routes: Express router with middleware chain (auth, role, usage-limit, validation) |
| 43 | +- Controller: Handles request/response, calls service, formats errors |
| 44 | +- Service: Business logic, DB queries, external API calls |
| 45 | + |
| 46 | +### Premium Gating Pattern |
| 47 | +For premium-only features (see `latex-chat.controller.ts`): |
| 48 | +```typescript |
| 49 | +const user = await prisma.user.findUnique({ |
| 50 | + where: { id: req.user.id }, |
| 51 | + select: { subscriptionPlan: true, subscriptionStatus: true }, |
| 52 | +}); |
| 53 | +const isPremium = |
| 54 | + (user.subscriptionPlan === "MONTHLY" || user.subscriptionPlan === "YEARLY") && |
| 55 | + user.subscriptionStatus === "ACTIVE"; |
| 56 | +``` |
| 57 | + |
| 58 | +### Usage Limits |
| 59 | +Daily usage limits are enforced via `usageLimit(action)` middleware. |
| 60 | +Actions: `ATS_SCORE`, `COVER_LETTER`, `GENERATE_RESUME`, `JOB_APPLICATION`, `MOCK_INTERVIEW` |
| 61 | +Config in `server/src/config/usage-limits.ts`. |
| 62 | + |
| 63 | +## Key Patterns |
| 64 | + |
| 65 | +### Adding a New API Endpoint |
| 66 | +1. Create/update `*.routes.ts` with Express router |
| 67 | +2. Create/update `*.controller.ts` with request handling |
| 68 | +3. Create/update `*.service.ts` with business logic |
| 69 | +4. Create/update `*.validation.ts` with Zod schemas |
| 70 | +5. Register routes in `server/src/index.ts` |
| 71 | + |
| 72 | +### Adding a New Client Page |
| 73 | +1. Create page component in `client/src/module/<area>/<PageName>.tsx` |
| 74 | +2. Add lazy import in `client/src/App.tsx` |
| 75 | +3. Add route in the appropriate route group (public/student/recruiter/admin) |
| 76 | + |
| 77 | +### AI Integration (Gemini) |
| 78 | +- Use `GoogleGenerativeAI` from `@google/generative-ai` |
| 79 | +- Model: `gemini-2.5-flash-lite` |
| 80 | +- For structured responses with LaTeX content, use XML tags (`<reply>`, `<latex>`) instead of JSON |
| 81 | +- Always handle parse failures with fallbacks |
| 82 | + |
| 83 | +### Button Component |
| 84 | +Use the reusable `Button` from `client/src/components/ui/button.tsx` (CVA-based) for all new buttons. |
| 85 | +- Variants: `primary`, `secondary`, `mono`, `ghost`, `danger` |
| 86 | +- Modes: `button` (default), `icon`, `link` |
| 87 | +- Sizes: `sm`, `md`, `lg` |
| 88 | +- Supports `asChild` (Radix Slot) for composing with `<Link>` or other elements |
| 89 | +- Import: `import { Button } from "../../components/ui/button"` |
| 90 | + |
| 91 | +### SEO on Internal Pages |
| 92 | +All admin and recruiter pages must include `<SEO title="Page Title" noIndex />`. Public pages use full SEO props. |
| 93 | + |
| 94 | +### File Upload Validation |
| 95 | +`DynamicFieldRenderer.tsx` validates file uploads client-side (size ≤ 5 MB, allowed types). Follow this pattern for any new file upload UI. |
| 96 | + |
| 97 | +### React.memo Convention |
| 98 | +Wrap list-rendered child components (cards, badges, list items) with `React.memo` when they receive stable props and don't have internal state that changes frequently. Use named function form: |
| 99 | +```tsx |
| 100 | +export const MyCard = React.memo(function MyCard({ data }: Props) { ... }); |
| 101 | +``` |
| 102 | + |
| 103 | +### Repo Request Approval Flow |
| 104 | +Students can suggest repos via `POST /api/opensource/requests`. Admin reviews at `/admin/repo-requests`. On approval, the repo is auto-created and the student gets an email. Routes are in `opensource.routes.ts`, `/requests/*` routes must appear BEFORE `/:id` to avoid route conflicts. |
| 105 | + |
| 106 | +## Do NOT |
| 107 | +- Create Prisma migrations without confirming, run from `server/src/database/` |
| 108 | +- Use `bg-gradient-*` in TailwindCSS, use `bg-linear-to-*` |
| 109 | +- Add `rounded-full` pill badges above headings |
| 110 | +- Fabricate new UsageAction enum values, reuse existing ones to avoid migrations |
| 111 | +- Push to remote without explicit permission |
0 commit comments