# C4 — Component view: backend layers

The Level-3 (Component) view — the dependency directions between the backend
layers of `app/app/` (Controller, Service, Model, Job, …). Unlike the
hand-drawn [c4-context.md](c4-context.md), this diagram is **generated from
code** by deptrac, so it cannot drift. See [README](README.md) for the boundary
rule and [ADR-005](../adr/ADR-005-architecture-fitness-deptrac.md).

```mermaid
flowchart TD;
    Console -->|3| Service;
    Console -->|3| Model;
    Console -->|2| Job;
    Controller -->|190| Model;
    Controller -->|11| Request;
    Controller -->|8| Service;
    Controller -->|1| Mail;
    Controller -->|5| Job;
    Controller -->|6| Resource;
    Middleware -->|1| Model;
    Resource -->|1| Model;
    Job -->|75| Model;
    Job -->|28| Service;
    Job -->|4| Mail;
    Job -->|8| Exception;
    Mail -->|17| Model;
    Provider -->|2| Service;
    Repository -->|3| Model;
    Service -->|87| Model;
    Service -->|1| Repository;
    Service -->|13| Exception;
    Service -->|7| Mail;
    Service -->|5| Job;
```

## Notes

- Edge labels are dependency counts. Every edge shown is an **allowed**
  direction — `deptrac analyse` reports **0 violations** (481 allowed
  cross-layer dependencies, 977 uncovered framework/vendor references). The
  layer model and ruleset live in `app/deptrac.yaml`; the conformance gate is
  lefthook pre-commit job 10.
- This is the **Component** level, derived from code. To regenerate after a
  change to the layer model:

```bash
cd app && php vendor/bin/deptrac analyse --formatter=mermaidjs
```

- The **Context** level ([c4-context.md](c4-context.md) — external systems) is
  not code-derived and stays hand-maintained with the `mermaid` skill.
