A comprehensive Rules set for building, scaling, and maintaining a modern mentorship platform (matching, scheduling, feedback loops) with a TypeScript/Node.js/React stack.
Transform your mentorship program from a glorified calendar app into an intelligent platform that actually drives career outcomes. These Cursor Rules deliver a production-ready TypeScript stack that handles smart matching, structured feedback loops, and real-time collaboration—everything you need to build mentorship software that people actually want to use.
Most mentorship platforms fail because they're built like dating apps—match people and hope for the best. But effective mentorship requires structured interactions, progress tracking, psychological safety, and intelligent pairing based on skills, not just availability.
The typical development nightmare:
A complete mentorship platform architecture that solves real-world problems:
Smart Matching Engine: Weighted scoring algorithm that considers skills, goals, availability, timezones, and capacity—not just "who's available"
Structured Sessions: Built-in templates for different mentorship scenarios (career planning, technical skills, leadership development) with progress tracking
Real-Time Collaboration: VS Code Live Share integration for pair programming sessions and code reviews
Privacy-First Design: Separate private notes, anonymity options, and encrypted PII handling for sensitive career discussions
Analytics That Matter: Pre/post skill assessments, NPS tracking, and actual career outcome measurement
60% Less Architecture Decisions: Domain-driven design with clear bounded contexts (Matching, Scheduling, Sessions, Feedback) eliminates guesswork about where code belongs.
Zero Security Debt: Built-in OWASP compliance, PII encryption, audit logging, and row-level security patterns from day one.
Instant Feedback Loops: Error handling with RFC 7807 Problem Details and structured logging means you'll know exactly what's broken and where.
Production-Ready from Commit One: Terraform IaC, Docker configurations, and full CI/CD pipeline with automated testing and security scans.
// Before: Generic user matching with basic filters
const findMatches = async (userId: string) => {
return db.users.findMany({ where: { available: true } });
};
// After: Intelligent mentorship pairing with business logic
const generateMentorPairings = async (menteeId: string): Promise<Result<MatchingScore[], MatchingError>> => {
const mentee = await menteeService.findById(menteeId);
if (!mentee.success) return err(mentee.error);
const weights = {
skillAlignment: 0.4,
timezone: 0.3,
capacity: 0.2,
experience: 0.1
};
return matchingAlgorithm.score(mentee.value, weights);
};
// Built-in timezone complexity and conflict detection
model MentorshipSession {
id String @id @default(uuid())
startTime DateTime
endTime DateTime
timezone String
@@constraint(exclude_overlapping_gist("mentor_id", "tsrange(start_time, end_time)"))
}
// Domain-specific feedback models instead of generic comments
interface SessionFeedback {
sessionId: string;
skillProgress: SkillAssessment[];
goalProgress: GoalUpdate[];
mentorNotes: PrivateNote; // Encrypted, mentor-only
menteeReflection: Reflection;
npsScore: NPSRating;
}
# Clone and setup with full development environment
pnpm i && pnpm dev # Boots frontend, backend, and Dockerized Postgres
pnpm storybook # UI components including mentorship widgets
// src/domain/matching/algorithm.ts
export const MatchingWeights = {
skillAlignment: 0.4, // Technical skill overlap
timezone: 0.3, // ±4 hour compatibility
capacity: 0.2, // Mentor availability
experience: 0.1 // Seniority gap appropriateness
} as const;
The rules enforce clean separation between:
# Infrastructure provisioning
terraform apply # RDS, Redis, CloudWatch dashboards
# Feature flag rollouts
# Start with 5% for AI suggestions, expand based on metrics
Development Velocity: Skip 2-3 weeks of architecture decisions with pre-built domain models and service boundaries.
Code Quality: Automatic 80% test coverage gate with unit, integration, and E2E tests prevents regression bugs.
Security Compliance: Built-in OWASP scanning, PII encryption, and audit logging means you'll pass security reviews.
Operational Excellence: Structured logging with request IDs, error codes, and context makes debugging production issues straightforward.
Business Impact: Analytics dashboard tracks actual mentorship outcomes—skill development, career progression, and program ROI.
Real-World Performance:
These aren't just configuration files—they're a complete mentorship platform architecture that handles the complex domain logic, security requirements, and scalability challenges that make mentorship software actually work.
Ready to build mentorship software that drives real career outcomes? Implement these rules and focus on what makes your platform unique instead of rebuilding the same infrastructure everyone else struggles with.
You are an expert in TypeScript, Node.js, React, GraphQL, PostgreSQL, Prisma, Jest, Playwright, Docker, and Terraform.
Key Principles
- Build features that directly support mentorship outcomes: smart matching, structured check-ins, feedback capture, analytics.
- Domain-driven design (DDD): isolate bounded contexts (Matching, Scheduling, Sessions, Feedback).
- Functional, declarative code preferred; keep side effects at boundaries (DB, network, IO).
- Small, composable modules (≤150 LOC) with single responsibility.
- Fail fast: validate inputs immediately; use exhaustive guards and return typed results.
- Treat psychological-safety features (private notes, anonymity options) as first-class product requirements.
- Infrastructure as Code (IaC) and CI/CD are mandatory; all merges must pass full test battery & static analysis.
TypeScript
- Always enable "strict", "noImplicitAny", "exactOptionalPropertyTypes" in tsconfig.
- Prefer `interface` for contracts, `type` for unions & primitives.
- Use `Readonly` & `const` assertions to model immutability.
- Use `Result<T, E>` (e.g., `neverthrow`) instead of exceptions in domain layer; map to HTTP/GraphQL errors at edge.
- Never use `any`. If unavoidable, isolate in `__unsafe__` folder and document.
- File anatomy: domain (entities, value objects) → services → controllers → routes/resolvers.
- Naming: verbs for functions (`generatePairings`), nouns for data (`MentorProfile`).
Error Handling & Validation
- Centralised error map: `errors/*.ts` enumerates codes (e.g., `MENTOR_NOT_AVAILABLE`, `MATCH_CONFLICT`).
- Each API returns RFC 7807 Problem Details; GraphQL uses `extensions.code`.
- Zod schemas validate every API payload at boundary; map failures to 400.
- Use early returns. Example:
```ts
if (!schema.safeParse(body).success) return problem(400, 'INVALID_PAYLOAD');
```
- Log with structured logger (Pino) including `requestId`, `actorId`, `context`.
- Do not leak PII in error messages—mask emails & names.
React (Next.js)
- Use Server Components for data fetching; Client Components only when interaction needed.
- Co-locate GraphQL operations with components via `*.gql.ts`.
- State management: React Query + Zustand for ephemeral UI state.
- Directory: `app/(public|dashboard)/feature/page.tsx`, `components/ui/*`, `lib/hooks/*`.
- Accessibility first: every interactive element must have discernible label.
- Pair-programming widget: integrate VS Code Live Share—lazy-load module, handle missing permission errors.
Node.js (Fastify Server)
- `src/server.ts` boots Fastify; register `plugins/*` for auth, db, tracing.
- Use `@fastify/cors` with allow-list from env.
- GraphQL server via Mercurius; each schema module under `src/graphql/*` with resolver map + SDL.
- Background jobs (matching runs, reminders) in BullMQ; store metadata in Redis with TTL.
- Config via environment variables validated at startup (dotenv + zod `EnvSchema`).
Database (PostgreSQL + Prisma)
- Schema follows DDD contexts (matching, feedback). Example:
```prisma
model Mentor {
id String @id @default(uuid())
skills Skill[] @relation("MentorSkills")
capacity Int @default(3) // max mentees
...
}
```
- Use nullable columns sparingly; instead model optionality with association tables.
- Soft-delete via `deleted_at` timestamp; always scope queries with `WHERE deleted_at IS NULL` middleware.
- Use row-level security for multi-tenant deployments.
Matching Algorithm Rules
- Inputs: mentor skills, mentee goals, availability, time zones, preferred language.
- Weighted scoring (0-100) = Σ(weight × normalizedFactor).
- Hard constraints: capacity, non-overlapping time zones ±4 h, HR compliance blockers.
- Run nightly; expose dry-run endpoint for admins.
Testing
- Unit: Jest with 80% branch coverage gate.
- Integration: Spin ephemeral Postgres via Testcontainers; run GraphQL end-to-end scenarios.
- E2E: Playwright scripts cover onboarding flow, scheduling, feedback submission.
- Contract tests against mentoring platforms API (e.g., Zoom) using Pact.
Performance
- Index foreign keys & search columns (`skills`, `time_zone`).
- Cache GET /mentors & GET /mentees with Redis for 5 min; bust on update.
- Use `EXPLAIN` in CI to block queries with cost > 100k.
Security
- SSO via SAML/OIDC; fallback password auth disabled in prod.
- Rate-limit login 5/min/IP; graphite metrics.
- All PII encrypted at rest (Postgres pgcrypto). Audit log immutable table.
- OWASP dependency check in pipeline; auto-create PRs for vulnerabilities.
DevOps
- Docker images pinned to digest; multi-stage build to keep runtime ≤120 MB.
- Terraform modules provision RDS, Redis, CloudWatch dashboards.
- Feature flags via Unleash; roll out mentoring-AI suggestions to 5% first.
Analytics & Feedback
- Capture mentor/mentee NPS after each session; send to Segment.
- Pre/post-assessment tables for skill deltas. Dashboards in Metabase.
Documentation
- Use `docs/adr/*.md` for architecture decisions (ADR-0001-matching-algorithm.md).
- `/api` endpoint auto-docs via GraphQL voyager + Markdown examples.
Folder Structure (root)
```
.
├─ src
│ ├─ domain
│ ├─ services
│ ├─ graphql
│ ├─ plugins
│ ├─ jobs
│ └─ server.ts
├─ app (Next.js)
├─ prisma
├─ tests
├─ docker
└─ docs
```
Common Pitfalls & Guards
- Avoid circular mentor–mentee links: unique composite (mentorId, menteeId) with constraint.
- Detect session conflicts: `EXCLUDE USING gist` on tsrange.
- Ensure timezone math uses `luxon`; forbid native `Date` in code review.
Linting & Formatting
- ESLint + @typescript-eslint + Prettier (printWidth = 100, trailingComma = all).
- CI fails on any lint error; husky pre-commit runs `lint-staged`.
Commit & PR Rules
- Conventional Commits; PR title must follow `<type>(scope): summary`.
- Require linked issue & changelog entry.
Onboarding for Contributors
- Run `pnpm i && pnpm dev` boots frontend & backend with Dockerized Postgres.
- `pnpm storybook` to view UI components including mentorship widgets.
End of Rules