@ -1,7 +1,7 @@
# SiMS HQ — Build Status
_Internal ops console for running our software business. Not shipped to clients._
_Last reviewed: 2026-07-19 · Version 0.1.0_
_Last reviewed: 2026-07-20 · Version 0.1.0_
HQ is the back-office console we use to run ~300 Classic client relationships:
the client book, our software module catalogue and dated price book, quotations /
@ -35,6 +35,18 @@ clear** — `HQ_SECRET_KEY` was removed, so portal/gateway passwords, modul
passwords and the Gmail token are plaintext and keyless (login passwords stay scrypt-hashed);
a DB dump exposes them, so the DB file and its backups are the security boundary.
**Since 2026-07-19 (D34–D37).** **Employee master imported** (11 staff; username = first name,
default password `<name>@123` ) with a `must_change_password` "Invited" flag that clears on the
first self password-change (D34). Clients gained a **type** (PACS vs Store) and a **society
category** matching the Kerala co-op directory taxonomy (Service Bank / Urban / Vanitha /
Housing / Employees / Agricultural / …), both derived from the name and filterable on the
Clients screen (D35/D37). A founder-approved **data-correction session** cleaned 187 client
names and appended **LTD/registration numbers to 141 PACS** , sourced from the Kerala govt co-op
directory via a multi-agent web-lookup (D35). **Login history** (D36): every sign-in attempt
(success/failed/locked) is logged with IP + device in a `login_event` table, viewable on a new
owner **Login history** screen; an invited user is sent to Profile to change their default
password on first sign-in.
## Verification state
| Check | Result |
@ -82,7 +94,7 @@ live under `apps/hq/test/`, `apps/hq-web/test/`, and
## Database schema (`apps/hq/src/db.ts`)
The schema creates 31 tables on open; `migrate()` additively backfills the
The schema creates 32 tables on open; `migrate()` additively backfills the
post-launch columns on older DBs (`module.quote_content`, `email_log.bounced` ,
`document.due_date` , `staff_user.phone` /`title`, `client.owner_id` plus the
D18 support fields `anydesk` /`os`/`district`/`sector`/`db_password_enc`, and
@ -95,7 +107,8 @@ and widens two CHECK constraints via a guarded, transactional table rebuild
| --- | --- |
| `staff_user` | Console logins / employees — owner · manager · staff role, scrypt salt+hash, active flag |
| `session` | Bearer session tokens with expiry |
| `client` | Client registry — code, name, GSTIN, state, contacts (JSON), status, account owner (`owner_id` → `staff_user` ), source |
| `login_event` | Login attempt log — staff_id/username, outcome (success/failed/locked), IP, user-agent (D36) |
| `client` | Client registry — code, name, GSTIN, state, contacts (JSON), status, account owner (`owner_id`), `client_type` (PACS/Store, D35), `category` (society type, D37), source |
| `module` | Software module catalogue — SAC, allowed billing kinds, multi-sub flag, quote-content lines |
| `module_price_book` | Dated prices per module/edition/kind (latest effective row wins) |
| `client_module` | A module assigned to a client — lifecycle status, install/complete/train dates, next renewal, provider/username/password (plaintext, D32), module-defined `field_values` (D21) |
@ -296,6 +309,7 @@ command palette, Gmail status pill, theme/accent switcher and a user menu
| `/portals` | `Portals` | Every stored login across all modules — Open ↗ links, 🔑 = password on file (reveal on Client 360) |
| `/mis` | `Mis` | Owner cockpit: this-month billing / collections / outstanding / pipeline / renewals / tickets / SMS-low, each tile click-through |
| `/audit` | `Audit` | Owner audit-log viewer: entity/action filters (from server facets), paginated before/after key-diff |
| `/login-history` | `LoginHistory` | Owner login history: every sign-in (success/failed/locked) with IP + parsed device, outcome filter, paginated (D36) |
| `/settings` | `Settings` | Settings hub (Pinterest-style left rail, `?s=` deep-links): Company profile · Document template (live preview) · Reminders (dated cadence rows, append-only) · Sharing default expiry · Integrations status · Appearance. Owner-only except Appearance; `/settings/template` redirects here |
| `/employees` | `Employees` | Owner-only staff management: add / edit / re-role / reset password / deactivate / reactivate, surfacing the last-owner and self-deactivation guards |
| `/profile` | `Profile` | Self-service: edit display name/phone (email + role read-only), change own password (current password required; other sessions purged) |