> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.adid.dev/llms.txt.
> For full documentation content, see https://docs.adid.dev/llms-full.txt.

# Component Layering (Clean Architecture)

**Used in:** §9.1 API overview, §10.2 IDAClient, §14.x developer onboarding
**Audience:** Backend Developer, DevOps
**IA ID:** extra (referenced indirectly by §1.5)

```mermaid
graph LR
  classDef http fill:#dbeafe,stroke:#1d4ed8
  classDef svc  fill:#dcfce7,stroke:#15803d
  classDef repo fill:#fef9c3,stroke:#b45309
  classDef pkg  fill:#fae8ff,stroke:#a21caf
  classDef ext  fill:#e5e7eb,stroke:#475569

  Req["HTTP request"]:::ext
  Mw["Middleware (auth, logging, rate limit, RBAC)"]:::http
  H["handler/* (DID, VC, Agent, ZKP, ...)"]:::http
  S["service/* (business logic)"]:::svc
  R["repository/* (pgx)"]:::repo
  PG[("PostgreSQL")]:::ext
  Rds[("Redis")]:::ext

  subgraph PKG["pkg/* reusable"]
    PKGCrypto["crypto (Ed25519, secp256k1)"]:::pkg
    PKGDID["did (resolver, doc builder)"]:::pkg
    PKGCred["credential (sign, verify, status list)"]:::pkg
    PKGZKP["zkp (Airbender adapter)"]:::pkg
    PKGChain["blockchain (ethers-go bindings)"]:::pkg
    PKGDC["didcomm (envelope, pack/unpack)"]:::pkg
  end

  Chain["ADI chain registries"]:::ext

  Req --> Mw --> H --> S --> R --> PG
  S --> Rds
  S --> PKGCrypto
  S --> PKGDID
  S --> PKGCred
  S --> PKGZKP
  S --> PKGDC
  PKGChain --> Chain
  S --> PKGChain
```

**Reading guide:** Handlers never touch repositories or the chain directly. All chain calls flow through `pkg/blockchain`; all crypto goes through `pkg/crypto`. This is what doc-writer should reference when explaining the request lifecycle in §9.1.

***