# Tvastar — Multi-Site Build-Out & Facilities Control Tower — Complete AI & LLM Reference Corpus (`llms-full.txt`)
- Repository: https://github.com/mohan-n-swamy/tvastar-public
- Web Discovery URL: https://mohan-n-swamy.github.io/repos/tvastar-public/
- License: MIT
- Keywords: control-tower, retail-operations, site-deployment, facility-management, construction-management, boq, project-management, typescript, react, open-source
---
## File: `AI-README.md` — AI-README.md
---
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.
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.
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`
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.
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.
- 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`
---
## File: `.env.example` — Environment Contract (.env.example)
```ini
# tvastar-public — Multi-Site Build-Out & Facilities Control Tower
PORT=4000
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/tvastar
REDIS_URL=redis://localhost:6379
STORAGE_PROVIDER=local
S3_BUCKET=tvastar-site-artifacts
HRMS_SYNC_URL=https://hrms.ops.example.org/api/employees
OTP_PROVIDER=console
SESSION_JWT_SECRET=replace_with_32_byte_random_secret
```
---
## File: `AGENTS.md` — AGENTS.md
# AGENTS.md — Tvastar — Multi-Site Build-Out & Facilities Control Tower
Read this file first before modifying `tvastar-public`.
## Purpose
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.
## Commands
```bash
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
```
## Module Map
- `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`
## Invariants
1. Keep all organization names, credentials, domains, and thresholds in `.env` or external config files. Never hardcode company names, host IPs, or secrets in source files.
2. Deterministic business logic belongs in code and lookup tables, not inside LLM prompts.
3. Update `docs/HLD.md`, `docs/LLD.md`, and `.env.example` in the same commit whenever an interface or environment variable changes.
4. Run the repository smoke check and secret scan before opening a pull request.
---
## File: `docs/PRD.md` — Product Requirements Document (docs/PRD.md)
# Product Requirements Document — Tvastar — Multi-Site Build-Out & Facilities Control Tower
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.
## 1. Problem
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.
## 2. Users and Jobs-to-be-Done
| Persona | Job-to-be-Done |
|---|---|
| VP Expansion / Projects Director | Track every site across G1 Due Diligence, G2 BOQ Lock, G3 Execution, and G4 Handover with hard artifact gates. |
| External Civil / MEP Vendor | Log in via zero-license OTP to upload milestone evidence and close snag items strictly on assigned sites. |
| Facilities & Operations Lead | Monitor post-opening P0 SOS and P1 maintenance SLAs across all live locations. |
## 3. Core 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`).
## 4. Configurable Inputs
Adopters configure the system for their own organization without editing core application logic:
| Variable | Default / Example | Purpose |
|---|---|---|
| `PORT` | `4000` | Fastify API server port |
| `DATABASE_URL` | `postgresql://postgres:postgres@localhost:5432/tvastar` | PostgreSQL connection string (enforces RLS policies) |
| `STORAGE_PROVIDER` | `local` | Artifact storage backend (`local` for dev, `s3` for production) |
| `OTP_PROVIDER` | `console` | Vendor OTP delivery adapter (`console`, `smtp`, or `sms`) |
| `HRMS_SYNC_URL` | `https://hrms.ops.example.org/api/employees` | Optional HRMS roster synchronization endpoint |
## 5. Phasing and Stability Exit Criteria
1. **Phase 1 (Local Synthetic Run):** Clone the repository, copy `.env.example` to `.env`, and run the quickstart commands against synthetic seed data. Exit criterion: smoke checks pass with zero external credentials.
2. **Phase 2 (Read-Only Shadow Wiring):** Connect read-only credentials or webhook listeners in shadow/dry-run mode. Exit criterion: 100 consecutive events or queries reconcile cleanly against source records.
3. **Phase 3 (Production Cutover):** Enable live writes, alerts, or routing behind bounded retry and idempotency guards.
## 6. Non-Goals
- Shipping organization-specific business rules hardcoded in application source.
- Storing credentials, personal customer records, or tenant URLs inside version control.
- Replacing deterministic validation or arithmetic with unconstrained model prompts.
---
## File: `docs/PR-FAQ.md` — Working-Backwards PR-FAQ (docs/PR-FAQ.md)
# Working-Backwards PR-FAQ — Tvastar — Multi-Site Build-Out & Facilities Control Tower
**Release Summary:** `tvastar-public` gives engineering and operations teams a self-hosted, open-source implementation of Tvastar — Multi-Site Build-Out & Facilities Control Tower that configures via `.env` and runs on standard infrastructure in minutes.
## Press Release
Operations and engineering teams often rebuild the same internal workflows behind closed doors or pay per-seat SaaS markups for rigid tools that cannot match their field reality. `tvastar-public` open-sources a battle-tested implementation of Tvastar — Multi-Site Build-Out & Facilities Control Tower, stripped of all single-company assumptions and packaged with clear adapter boundaries, synthetic demo data, and machine-readable agent documentation.
Any team can fork `tvastar-public`, supply their own `.env` inputs and taxonomy config, and deploy locally or in production with Docker, Python, or Node. AI coding assistants such as Claude Code, Codex, and Cursor can read `AI-README.md` and `llms.txt` to wire custom ERP, CRM, or warehouse adapters in a single session.
## External Adopter FAQ
**Q1: How long does it take to run locally after cloning?**
Under five minutes. Copy `.env.example` to `.env` and run the quickstart commands in `README.md`. Synthetic fixtures let you inspect the workflow before connecting live credentials.
**Q2: Do I need to rewrite source files to use my own company name, channels, or rules?**
No. Organization names, endpoints, thresholds, and credentials sit in `.env` and declarative config files. External system specifics live behind narrow adapter modules documented in `docs/LLD.md`.
**Q3: What license governs this repository?**
MIT License. You can fork, modify, self-host, and use it commercially without restriction.
## Internal Engineering & Security FAQ
**Q4: How do we prevent tenant or employer data from ever entering a public fork?**
The repository starts from a clean git history, excludes raw exports and binary dumps, validates every commit through `gitleaks`, and ships only synthetic fixtures.
**Q5: What happens when an upstream API or model provider is slow or unavailable?**
Inbound webhooks persist raw payloads before processing, outbound writes carry idempotency keys with bounded exponential backoff, and model-backed paths fail open to deterministic rules or explicit human queues.
---
## File: `docs/HLD.md` — High-Level Design (docs/HLD.md)
# High-Level Design (HLD) — Tvastar — Multi-Site Build-Out & Facilities Control Tower
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.
## 1. System Topology
```mermaid
flowchart LR
Staff["Internal Staff (SSO)"] --> API["Fastify API + Access Policy"]
Vendor["Contractors (Scoped OTP)"] --> API
API --> RLS["PostgreSQL + Row-Level Security"]
BOQ["boqcheck/ Analyzer"] --> API
Gates["stage-gates/ G1..G4 YAML"] --> API
Live["Live Store Tickets"] --> Radar["facilities_radar/ P0 SOS Engine"]
```
## 2. Architectural Decisions and Rejected Alternatives
| Decision | Why It Holds | Rejected Alternative |
|---|---|---|
| PostgreSQL RLS + Dual Auth (SSO + Vendor OTP) | Enables external contractors to work in the same system of record without per-seat SaaS fees or cross-site data exposure. | Separate vendor portal syncing over brittle webhooks |
| Declarative Stage-Gate YAML (`1010..1040` integer codes) | Adapts cleanly from medical clinics to retail stores, cafés, or EV charging hubs without changing state-machine code. | Hardcoded string stage names scattered across UI and SQL |
| Unified Build-Out + Post-Launch Facilities Radar | Preserves MEP drawings, vendor warranties, and snag history when a site transitions from Projects to Facilities. | Throwing handover PDFs over the wall into a disconnected ticketing tool |
## 3. Data Flow and Failure Boundaries
1. **Configuration Boundary:** Startup validates `.env` variables and declarative config schemas before accepting traffic or running scheduled jobs.
2. **Adapter Boundary:** External services (databases, chat channels, HRMS, warehouses, or LLM providers) sit behind explicit adapter modules so failures stay isolated and testable with local mocks.
3. **Observability and Audit:** State transitions and job executions emit structured logs and deterministic status records rather than mutating state silently.
## 4. Scaling Notes
- **1x to 10x load:** Single-node Docker Compose or process supervisor handles standard team workloads with indexed database queries and bounded worker concurrency.
- **First bottleneck at 10x+:** High-frequency webhook or batch ingestion queues; mitigate by separating the stateless HTTP receiver from background worker processes sharing Redis or PostgreSQL locks.
---
## File: `docs/LLD.md` — Low-Level Design & Runbook (docs/LLD.md)
# Low-Level Design (LLD) & Operations Runbook — Tvastar — Multi-Site Build-Out & Facilities Control Tower
This document defines the module responsibilities, environment contract, and operational procedures for `tvastar-public`.
## 1. Module and File Inventory
| Path | Responsibility |
|---|---|
| `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` |
## 2. Environment Variable Contract
| Variable | Default / Example | Required | Description |
|---|---|---|---|
| `PORT` | `4000` | Yes | Fastify API server port |
| `DATABASE_URL` | `postgresql://postgres:postgres@localhost:5432/tvastar` | Yes | PostgreSQL connection string (enforces RLS policies) |
| `STORAGE_PROVIDER` | `local` | Yes | Artifact storage backend (`local` for dev, `s3` for production) |
| `OTP_PROVIDER` | `console` | Yes | Vendor OTP delivery adapter (`console`, `smtp`, or `sms`) |
| `HRMS_SYNC_URL` | `https://hrms.ops.example.org/api/employees` | Yes | Optional HRMS roster synchronization endpoint |
## 3. Extension Recipe
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.
## 4. Operations Runbook
### 1. Run platform Python & BOQ verification
```bash
pytest -q tests_platform/
```
### 2. Seed synthetic multi-city build-out portfolio
```bash
pnpm run db:seed:synthetic
```
### 3. Run full monorepo lint & unit checks
```bash
pnpm run test:unit
```
---
## File: `docs/RESEARCH-2026.md` — 2026 Research & Landscape Notes (docs/RESEARCH-2026.md)
# 2026 Multi-Site Capex Build-Out & Facilities Control Tower Research
Expanding physical footprints (retail stores, outpatient clinics, EV hubs, dark stores, or restaurants) across dozens of locations fails when teams manage contractors over WhatsApp and spreadsheets: BOQ unit rates drift 20-35% across regions, lease rent starts before power/HVAC due diligence finishes, and handover snags vanish after launch.
Commercial construction ERPs (Procore, Autodesk Build) price per-seat or % of capex and overwhelm agile retail/clinic rollouts, while generic task boards (Asana, Monday) lack **itemized BOQ variance checking**, **PostgreSQL Row-Level Security (RLS) separating external OTP vendors from internal staff**, and **integrated post-handover facilities SLA tracking**. `tvastar-public` unifies all three under MIT.