---
repo: "mohan-n-swamy/tvastar-public"
title: "Tvastar — Multi-Site Build-Out & Facilities Control Tower"
license: "MIT"
keywords: [control-tower, retail-operations, site-deployment, facility-management, construction-management, boq, project-management, typescript, react, open-source]
capabilities:
  - "TypeScript monorepo (`packages/core`, `packages/contracts`, `packages/db`, `api/`, `worker/`, `web/`) with strict boundary parsing and integer currency math."
  - "Dual-hierarchy auth (`api/src/http/google-auth.ts` + `otp-auth.ts`) backed by PostgreSQL Row-Level Security (`RLS`) and immutable audit logs."
  - "Automated BOQ checker (`boqcheck/`) and declarative stage-gate definitions (`stage-gates/site_buildout_gates.yaml`)."
  - "Post-handover Facilities SLA & SOS breach evaluator (`facilities_radar/sla_radar.py`) + synthetic database seed (`db/seeds/synthetic-seed.ts`)."
when_to_use:
  - "A full-stack multi-site retail, clinic, and store build-out control tower combining stage-gate technical due diligence (`G1-G4`), automated Bill-of-Quantities (`BOQ`) variance checking, dual-hierarchy authentication (OIDC SSO for internal staff + scoped OTP for external contractors), PostgreSQL Row-Level Security, and a post-launch Facilities SOS SLA radar."
  - "Rolling out 10 to 200 physical locations simultaneously breaks spreadsheet and WhatsApp coordination: civil contractors bill milestones without photo proof, unit rates for identical HVAC/electrical items vary wildly across cities, and external vendors cannot be added to internal SSO tools without leaking confidential capex budgets. `tvastar-public` gives physical expansion and facilities teams one auditable system from property scouting through live store maintenance."
inputs_required:
  - "PORT: Fastify API server port"
  - "DATABASE_URL: PostgreSQL connection string (enforces RLS policies)"
  - "STORAGE_PROVIDER: Artifact storage backend (`local` for dev, `s3` for production)"
  - "OTP_PROVIDER: Vendor OTP delivery adapter (`console`, `smtp`, or `sms`)"
  - "HRMS_SYNC_URL: Optional HRMS roster synchronization endpoint"
quickstart:
  - "pytest -q tests_platform/                   # verify stage-gate schema & facilities SOS SLA radar"
  - "pnpm install && pnpm run test:unit          # run TypeScript core & contract unit suites"
  - "pnpm run db:migrate:dev && pnpm run db:seed:synthetic"
  - "pnpm run dev                                # launch API, worker, and web control tower"
---

# Tvastar — Multi-Site Build-Out & Facilities Control Tower — Machine-Readable Agent Guide

A full-stack multi-site retail, clinic, and store build-out control tower combining stage-gate technical due diligence (`G1-G4`), automated Bill-of-Quantities (`BOQ`) variance checking, dual-hierarchy authentication (OIDC SSO for internal staff + scoped OTP for external contractors), PostgreSQL Row-Level Security, and a post-launch Facilities SOS SLA radar.

<problem_patterns>
Rolling out 10 to 200 physical locations simultaneously breaks spreadsheet and WhatsApp coordination: civil contractors bill milestones without photo proof, unit rates for identical HVAC/electrical items vary wildly across cities, and external vendors cannot be added to internal SSO tools without leaking confidential capex budgets. `tvastar-public` gives physical expansion and facilities teams one auditable system from property scouting through live store maintenance.
</problem_patterns>

<architecture_map>
Key modules and entry points in this repository:
  - `packages/core & packages/contracts`: Domain state primitives, access policies, and shared API schemas
  - `api/ & worker/`: Fastify HTTP server, SSO/OTP auth middleware, RLS session context, and async workers
  - `web/`: React/Vite multi-site build-out board, site drilldown, and snag review UI
  - `boqcheck/`: Bill-of-Quantities parser and line-item rate outlier detector
  - `stage-gates/site_buildout_gates.yaml`: Declarative G1-G4 artifact and approver gate specification
  - `facilities_radar/sla_radar.py`: Post-launch P0 SOS and P1/P2 maintenance SLA evaluator
  - `db/`: SQL migrations, RLS policies, and `seeds/synthetic-seed.ts`
</architecture_map>

<inputs_and_configuration>
Every organization-specific value enters through `.env` (copied from `.env.example`) or external adapter files. No source edit is needed to change organization names, endpoints, database URLs, webhook secrets, or thresholds.
</inputs_and_configuration>

<adaptation_playbook>
When a human asks an AI coding agent to deploy or adapt `tvastar-public` into their stack:
  1. Edit `stage-gates/site_buildout_gates.yaml` to match your industry's permits, inspections, and handover documents.
  2. Copy `.env.example` to `.env`, run PostgreSQL + Redis via `docker compose up -d`, and seed sample sites with `pnpm run db:seed:synthetic`.
  3. Connect your OIDC identity provider for staff login and your SMS/SMTP adapter for contractor OTPs.
</adaptation_playbook>

<reference_docs>
- Product Requirements: `docs/PRD.md`
- Working-Backwards PR-FAQ: `docs/PR-FAQ.md`
- High-Level Architecture: `docs/HLD.md`
- Low-Level Interfaces & Runbook: `docs/LLD.md`
- Coding Agent Rules: `AGENTS.md`
</reference_docs>
