# HRMS — notes for Codex

Active code lives in `frontend/src` and `backend/src`. The nested
`frontend/frontend/` and `backend/backend/` folders are stale copies — don't edit them.

## Global Search (keep it in sync when adding modules)

Global Search (topbar, `frontend/src/components/GlobalSearch.jsx` →
`GET /api/search`, `backend/src/controllers/searchController.js`) only finds
what it's told about:

- **New menu page** (`frontend/src/config/menu.js`): searchable automatically.
- **New Master Setup entity**: add it to `backend/src/config/masterEntities.js`
  and `frontend/src/pages/master-setup/masterFieldConfigs.js` (same `apiPath`)
  as usual — it becomes searchable automatically.
- **New module with its own records table** (anything else): add a
  `source({...})` entry to `SOURCES` in `searchController.js` — searchable
  columns (`cols`), the column to rank prefix matches by (`rank`), and a
  `map` returning `{ title, subtitle, path }` where `path` is the record's
  view page route in `frontend/src/App.jsx`. Search the same columns the
  module's own list endpoint searches. If the module has an attachments
  table, add a `Documents` group source for it too (see the existing ones).

Missing tables/columns are skipped at runtime, so a source can ship before
its migration has run everywhere.

## Screen protection

`frontend/src/components/ScreenProtection.jsx` (mounted in `MainLayout`)
blanks the screen on capture attempts and logs them to
`screen_capture_events`. Set `VITE_SCREEN_PROTECTION=off` in `frontend/.env`
when working with DevTools open locally.
