# System Stack Spec (v1)
## Takeoff → Supplier Bid Library → Automated Accounting

## Objective
Create a straight-through, auditable process that converts takeoff data into supplier bidding packages and automatically posts approved awards/POs into accounting.

---

## 1) Architecture Overview

### Core Layers
1. **Input Layer:** Takeoff files + quantity data
2. **Workflow Layer:** OpenClaw orchestration + automation rules
3. **Supplier Layer:** Bid distribution + quote intake
4. **Decision Layer:** Comparison + approvals + PO issuance
5. **Accounting Layer:** AP posting + 3-way match + audit logs

---

## 2) Recommended Stack

- **OpenClaw**: orchestration, routing, approvals, digest reporting
- **Supplier Bid Library**: controlled repository of bid packages and returns
- **Email/API Delivery**: supplier distribution channel
- **Accounting System Connector**: PO/AP sync endpoint
- **Storage**: versioned files with immutable history
- **Dashboard**: status by project, package, award, payment state

---

## 3) Workflow States (Standard)

1. Draft Takeoff
2. Ready for Bid
3. Bid Package Sent
4. Quotes Received
5. Comparison Complete
6. Approval Pending
7. Awarded / PO Issued
8. Posted to Accounting
9. Closed / Archived

No package can skip approval states.

---

## 4) Automation Rules

- Trigger on status = **Ready for Bid**
- Auto-generate bid package (scope, quantities, due date)
- Auto-route to approved suppliers by trade and geography
- Auto-remind suppliers at T-48h and T-24h before due time
- Auto-compile quote comparison table after deadline
- Auto-route approval request by threshold matrix
- On approval, auto-create PO and push to accounting
- Auto-open exception ticket for missing/invalid bids

---

## 5) Controls & Compliance

- Role-based access (buyer, approver, finance, audit)
- Full event log (who/what/when)
- Version lock on final award package
- No payment without PO + delivery/invoice match
- Exception queue monitored daily

---

## 6) KPI Dashboard

- Bid cycle time
- # invited suppliers / # responding suppliers
- Savings vs baseline estimate
- Approval turnaround time
- PO-to-posting time
- Invoice mismatch rate

---

## 7) Implementation Phases

### Phase 1 (Week 1–2)
- Field mapping finalized
- Supplier master normalized
- Approval matrix configured

### Phase 2 (Week 3–4)
- Pilot on one project/trade
- Validate PO + accounting posting

### Phase 3 (Week 5+)
- Scale to all projects
- Add predictive pricing alerts

---

## 8) Decision Gates

- Gate A: Data quality pass
- Gate B: Supplier response minimum met
- Gate C: Approval policy met
- Gate D: Accounting posting verified

If any gate fails, package remains open with assigned owner and due date.
