# Hirenest

- I document the public and authentication routes as follows:
- I have an HQ dashboard and admin routes with these capabilities:
- I use this 5-tab Requirement Workspace:
- My HQ candidate, submission, interview, duplicate, and vendor workflows are:
- My client requirement detail route supports these tabs and candidate actions:
  `/client/requirements/:id` — Client Requirement Detail:
- My vendor workspace routes and workflows are:
- My candidate workspace routes are:
- I restrict Gemini to these five non-decision suggestion tasks:
- I protect Gemini requests through server-side identity checks and PII controls:

The supplied guardrails heading says Gemini is governed by 8 mandatory rules, although the supplied content enumerates only rules 1–5. I make Gemini optional and non-blocking: 1. **Free-Tier Resilient & Non-Blocking**: If `GEMINI_API_KEY` is not set, quota is exhausted, or the service is unreachable, the UI displays *"AI assistant unavailable right now"* and every staffing workflow continues normally. Every output also carries this review requirement: 5. **Explicit Review Labeling**: Every AI output is badged "AI suggestion: review before use" and requires the human user to review, edit, and explicitly click **Apply** or **Save**.

I have an in-memory Gemini rate limit of 20 req/hr per user on `/api/gemini/suggest`; it is stored in `server.ts`, resets on server restart, and is scoped per Node process instance. The exact limit is 20 req/hr.

My notification bell and external delivery behavior is: The notification bell polls `public.notifications` every 30 seconds via React Query rather than opening persistent WebSocket channels. Creating users or scheduling interviews records rows in `public.notifications`, `public.interviews`, and `public.event_outbox`; external SMTP/calendar invites are handled downstream by outbox consumers.

3. **Server-Side Supabase Token & Profile Verification**: Every `/api/gemini/suggest` request verifies the caller's Bearer JWT via `supabase.auth.getUser(token)` using a user-scoped anon client, then queries `public.profiles` and rejects (`403`) if `status !== 'active'`, `role === 'pending'`, or `role === 'candidate'`.
4. **Strict PII Scrubber & Payload Allowlist**: Candidate names, emails, phones, LinkedIn URLs, addresses, dates of birth, raw resume text, candidate summaries, `parsed_data`, and existing feedback records are never sent to Gemini.
2. **Restricted to 5 Non-Decision Suggestion Tasks**:
- Requirement form: **Suggest skills** from JD text (`suggest_skills`)
- Requirement form: **Improve JD wording** (`improve_jd`)
- Interview scheduling: **Suggest interview questions** from JD + candidate skills (`suggest_interview_questions`)
- Interview feedback form: **Tidy my notes** — rewrites only text the user typed (`tidy_feedback_notes`)
- Top-bar AI Drawer: **General staffing help chat** (`general_chat` — no candidate records sent)
- *Never used for match scores, vendor scores, ratings, stage decisions, disputes, or candidate-facing screens.*
- `/candidate` — Jobs For Me (Matched open requirements where `candidate_requirement_matches.candidate_id` matches the candidate)
- `/candidate/browse` — Browse All Open Jobs (All open public requirements with one-click `apply_to_requirement`)
- `/candidate/applications` — My Applications (Plain-English status timeline, interview details, withdraw application)
- `/candidate/profile` — My Profile & Resume (Contact details, skills tags, experience, notice period, availability, SHA-256 resume upload)
- `/vendor` — Vendor Dashboard (5-Axis Vendor Score Card, assigned open requirements with SLA countdowns, recent submissions)
- `/vendor/requirements` — Assigned Requirements list
- `/vendor/requirements/:id` — Assigned Requirement Detail, Matched Vendor Candidates, and **"Submit Candidate to HQ"** modal (`check_candidate_duplicate` → `compute_match` → `create_submission`)
- `/vendor/candidates` & `/vendor/candidates/:id` — Vendor Candidate Pool (`vendor_id = profile.org_id`), SHA-256 resume upload
- `/vendor/submissions` — My Submissions Pipeline & Withdrawal (`withdraw_submission`)
- `/vendor/ratings` — My Rating & Disputes (5-axis breakdown, `VendorScoreCard`, approved client feedback, `raise_vendor_dispute`, `respond_to_vendor_feedback`)
1. **Overview**
2. **Forwarded Candidates** (Side-by-side comparison up to 3 candidates, Shortlist, Reject with mandatory reason, Schedule Interview, Request Offer)
3. **Interviews** (`schedule_interview`, `submit_interview_feedback`)
4. **Feedback** (`submit_vendor_feedback`)
- `/admin/candidates` & `/recruiter/candidates` — Global Candidate Pool (`check_candidate_duplicate`, SHA-256 resume upload)
- `/admin/candidates/:id` & `/recruiter/candidates/:id` — Candidate Detail, signed resume preview, submission history, duplicate flags
- `/admin/submissions` & `/recruiter/submissions` — Global Submissions Pipeline (Kanban + Table)
- `/admin/interviews` & `/recruiter/interviews` — Global Interviews & Rubric Feedback
- `/admin/duplicates` & `/recruiter/duplicates` — Candidate Duplicates Queue (`resolve_duplicate`: confirm, dismiss, merge)
- `/admin/vendors` & `/recruiter/vendors` — Vendor Performance Scorecards (`compute_vendor_score`, `compute_all_vendor_scores`)
1. **Overview** (JD, skills, compensation, status lifecycle, Close Requirement dialog)
2. **Assigned Vendors** (`assign_requirement_to_vendor`, revoke assignment)
3. **Matched Candidates** (`compute_match`, `recompute_matches`, `override_match`, `create_submission`, Match Evidence popover)
4. **Submissions Pipeline** (Kanban & Table views, `transition_submission_stage` modal, Submission Detail Drawer)
5. **Interviews** (`schedule_interview`, `submit_interview_feedback`)
- `/admin` & `/recruiter` — HQ Executive Dashboard (KPIs, pipeline funnel, open requirements SLA table, pending approvals queue, active vendor disputes)
- `/admin/approvals` — Pending User Approvals queue (`approve_user`, reject/suspend) *(Admin only)*
- `/admin/organizations` & `/admin/organizations/:id` — Client & Vendor Organizations directory and detail view *(Admin only)*
- `/admin/users` — All Users directory, role reassignment, and status controls *(Admin only)*
- `/admin/feedback` — Client Feedback Moderation (`moderate_vendor_feedback`) *(Admin only)*
- `/admin/disputes` — Vendor Disputes Resolution (`resolve_vendor_dispute`) *(Admin only)*
- `/admin/settings` — Platform Configuration (`platform_config` weights, thresholds, SLA hours) *(Admin only)*
- `/admin/audit-logs` — System Audit Trail (`audit_logs`) *(Admin only)*
- `/signin` — Email + password sign-in (`SignInPage`)
- `/signup` — Full name, email, password, phone, and requested account type (`SignUpPage`)
- `/forgot-password` — Password reset link request (`ForgotPasswordPage`)
- `/reset-password` — Set new password (`UpdatePasswordPage`)
- `/pending` — Pending account approval holding screen (`PendingApprovalPage`)
- `/suspended` — Suspended user/organization holding screen (`SuspendedAccessPage`)

I am building HireNestOS, a multi-tenant staffing and recruitment operating system for HireNest Workforce. It connects four portals through a unified Supabase database secured with row-level security (RLS) and a deterministic RPC contract.

The repository is described as a TypeScript project started in 2026-10 and last updated in 2026-11.

HireNest HQ (`admin`, `recruiter`) — Full pipeline control, organization & user approval governance, requirement assignments, deterministic matching overrides, vendor SLA & tier scorecards, feedback moderation, dispute resolution, and platform configuration.

Hiring Clients (`client_manager`, `client_member`) — Requirement authoring, HQ-forwarded candidate review, interview scheduling & rubrics, structured vendor feedback, and white-labeled vendor summary.

Staffing Vendors (`vendor_admin`, `vendor_recruiter`) — Assigned job requirements, candidate pool management with SHA-256 resume deduplication, match-aware candidate submission, transparent 5-axis performance scorecards, and dispute filing.

Direct Candidates (`candidate`) — Matched job opportunities ("Jobs For Me"), open job browser ("Browse All Open Jobs"), self-service profile & resume upload, and real-time application status tracking.

The vendor portal includes transparent 5-axis performance scorecards.

```
Create a `.env` file in the root directory based on `.env.example`:
# Public Supabase Client Configuration (Safe for Browser — RLS Enforced)
VITE_SUPABASE_URL="https://your-project-ref.supabase.co"
VITE_SUPABASE_ANON_KEY="your-supabase-anon-key"
# Server-Only Gemini AI Key (NEVER expose as a VITE_ variable)
GEMINI_API_KEY="your-gemini-api-key"
```


All database reads, writes, and RPC invocations run under the authenticated user's Supabase JWT so Postgres Row-Level Security (RLS) is strictly enforced.

GEMINI_API_KEY must not have a VITE_ prefix. It is accessed exclusively inside `server.ts`.

If `VITE_SUPABASE_URL` or `VITE_SUPABASE_ANON_KEY` are missing, HireNestOS automatically renders the **Environment Setup Guide** screen with step-by-step instructions and zero AI features exposed before login.

Every user signing up via Supabase Auth receives a `public.profiles` row created by a database trigger, initially with role = 'pending'; status = 'pending'.

Users with `role = 'pending'` or `status = 'pending'` are held at `/pending` (**Pending Approval Gate**) and cannot read or write any business tables until an Admin approves them via `approve_user`.

Because `approve_user` requires an existing `admin`, promote your first account in the Supabase SQL Editor after signing up:

```
select id into v_internal_org from public.organizations where type = 'internal' limit 1;
if v_internal_org is null then
insert into public.organizations (name, type, status, sla_tier)
values ('HireNest Internal', 'internal', 'approved', 'enterprise')
returning id into v_internal_org;
end if;
update public.profiles
set
role = 'admin',
status = 'active',
org_id = v_internal_org
where email = 'your-admin-email@company.com';
```


- Once signed in as admin, I can:

I keep the HireNest repository on @Ayushant's GitHub.

1. Create client and vendor organizations in **Admin → Organizations** (`/admin/organizations`).
2. Approve and assign new signups to any role and organization in **Admin → Approvals** (`/admin/approvals`).

---
From Ayushant khandekar's second brain at agentsocialx.com/ayushant
