# Code audit

This section is a candid architectural read of the codebase as it exists today,
written the way a staff engineer would brief a founder before a beta. It is
grounded in a full read of `server.py`, the Expo app, and both dependency
manifests — every claim here is traceable to code.

## The honest summary

Drape is a **capable, security-conscious product carrying the debt you would
expect from a solo founder shipping fast**. The security invariants are real and
enforced (see [security](../architecture/security.md)); the try-on pipeline is
genuinely sophisticated. The debt is concentrated in three places: an oversized
dependency footprint, a few doc-vs-code drifts, and render-quality issues inherent
to the AI.

```mermaid
graph LR
    subgraph "Healthy"
        H1["Enforced BIPA + auth invariants"]
        H2["Fail-closed rate limits"]
        H3["Signed webhook + idempotency"]
        H4["Error boundary + retry states"]
    end
    subgraph "Debt to manage"
        D1["Dependency bloat"]
        D2["Doc/code drift"]
        D3["Render quality + silent failures"]
        D4["~8,900-line server.py"]
    end
```

## The two audit pages

- **[Dependencies](./dependencies.md)** — the single highest-leverage cleanup.
  The backend `requirements.txt` ships large stacks the code never imports
  (Google AI, AWS, litellm, pandas, Iceberg) plus dev tooling in production; the
  frontend carries a few unused packages. All findings are grep-verified.
- **[Tech debt](./tech-debt.md)** — the structural and correctness debt worth
  tracking: doc/code reconciliation items (including a **live CORS finding**),
  the dual-write body-photo pattern, dormant FLUX.2 routing, silent pipeline
  failures, and repo hygiene.

## What "good" looks like here

The founder's own [Engineering Ownership Protocol](https://github.com/KCB1099/Drape-)
sets the bar: *if we don't understand it, we don't ship it; claim ownership
through naming; delete ruthlessly.* This audit is written in that spirit — not to
rewrite working code, but to shrink the surface area that has to be understood and
maintained. Every recommendation is **extend-or-remove**, never a rewrite.

:::note[Scope]
This audit reflects the codebase at the time of writing. Two prior dependency
audits under `frontend/docs/` are **stale** and, on the python-jose question,
inverted — the [dependencies page](./dependencies.md) corrects them.
:::
