> ## Documentation Index
> Fetch the complete documentation index at: https://cona.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Package Graph

> The monorepo's apps and packages, their real dependency edges measured from imports, and whether the layering rules actually hold

# Package Graph

Every edge below is counted from real `import` statements across the 3,088 tracked
TypeScript source files — not from `package.json`. Numbers are import statements, not
files.

Split into two diagrams because the combined graph exceeds what one picture can carry.

## Applications → packages

```mermaid theme={null}
flowchart LR
    subgraph Apps["Applications"]
        WebApp["@cona/webapp"]
        Portal["@cona/portal"]
        Console["@cona/console"]
        Workers["@cona/temporal-workers"]
        Docs["@cona/internal-docs<br/>no code edges"]
    end

    UI["@cona/ui"]
    Core["@cona/core"]
    Database["@cona/database"]
    Types["@cona/types"]
    Utils["@cona/utils"]
    Workflows["@cona/temporal-workflows"]
    TemporalConfig["@cona/temporal-config"]
    Agents["@cona/agents"]
    Support["@cona/pdf · emails<br/>observability · opentelemetry<br/>operational-config"]

    WebApp -->|1550| UI
    WebApp -->|621| Types
    WebApp -->|507| Database
    WebApp -->|343| Core
    WebApp -->|92| Utils
    WebApp -->|48| TemporalConfig
    WebApp -->|11| Workflows
    WebApp -->|10| Agents
    WebApp -->|23| Support

    Portal -->|11| UI
    Portal -->|10| Core
    Portal -->|2| Utils
    Portal -->|9| Support

    Console -->|95| UI
    Console -->|4| Database
    Console -->|1| TemporalConfig
    Console -->|7| Support

    Workers -->|30| TemporalConfig
    Workers -->|20| Workflows
    Workers -->|2| Core
    Workers -->|1| Utils
    Workers -->|6| Support

    classDef boundary fill:#f8fafc,stroke:#94a3b8,color:#334155

    classDef app fill:#dbe2fb,stroke:#3B56C5,color:#111827
    classDef pkg fill:#e8eafd,stroke:#4967E6,color:#111827
    classDef data fill:#fde8e8,stroke:#c53b3b,color:#111827
    classDef async fill:#e3f7ea,stroke:#2f9e5c,color:#111827

    class WebApp,Portal,Console,Docs app
    class UI,Core,Types,Utils,Agents,Support pkg
    class Database data
    class Workers,Workflows,TemporalConfig async
    class Apps boundary
```

## Packages → packages

```mermaid theme={null}
flowchart TB
    Workflows["@cona/temporal-workflows"]
    Core["@cona/core"]
    Pdf["@cona/pdf"]
    Types["@cona/types"]
    Utils["@cona/utils"]
    Database["@cona/database"]
    TemporalConfig["@cona/temporal-config"]
    Observability["@cona/observability"]
    OpenTelemetry["@cona/opentelemetry"]
    Agents["@cona/agents"]
    Emails["@cona/emails"]

    Workflows -->|292| Core
    Workflows -->|84| Database
    Workflows -->|63| Utils
    Workflows -->|52| Types
    Workflows -->|3| Observability
    Workflows -->|3| Agents
    Workflows -->|2| TemporalConfig
    Workflows -->|2| Pdf
    Workflows -->|1| Emails

    Core -->|401| Database
    Core -->|243| Types
    Core -->|57| Utils

    Pdf -->|14| Types
    Pdf -->|5| Utils
    Pdf -->|2| Core
    Pdf -->|2| Database

    Types -->|11| Database
    Utils -->|7| Types
    Database -->|2| TemporalConfig
    OpenTelemetry -->|2| Observability

    classDef pkg fill:#e8eafd,stroke:#4967E6,color:#111827
    classDef data fill:#fde8e8,stroke:#c53b3b,color:#111827
    classDef async fill:#e3f7ea,stroke:#2f9e5c,color:#111827

    class Core,Pdf,Types,Utils,Observability,OpenTelemetry,Agents,Emails pkg
    class Database data
    class Workflows,TemporalConfig async
```

**Leaf packages** — import no other `@cona/*`: `ui`, `agents`, `emails`, `observability`,
`operational-config`, `temporal-config`, plus `eslint-config`, `typescript-config`, and
`tailwind-config` (build-time only, omitted above).

## Do the layering rules hold?

`CODEBASE_MAP.md:95-109` states three rules. Two hold; one does not.

<Check>
  **"Core never imports an app"** — 0 violations. No import from `packages/core/**` targets an app.
</Check>

<Check>
  **"Activities wrap core"** — holds structurally. `@cona/temporal-workflows` imports `@cona/core`
  292 times.
</Check>

<Warning>
  **"Webapp never imports Prisma directly"** — **false as written.**

  `@prisma/client` is genuinely never imported by webapp. Repo-wide the only `@prisma/*`
  import is `@prisma/instrumentation` at `packages/opentelemetry/src/dependencies.ts:10`.

  But `@cona/database`'s root export re-exports the live client
  (`packages/database/src/client.ts:177`), and **40 production webapp files import it** —
  including 9 mutations.
</Warning>

Webapp's 507 `@cona/database` imports by entry point:

| Specifier                    | Type-only | Value | Meaning                                         |
| ---------------------------- | --------: | ----: | ----------------------------------------------- |
| `@cona/database`             |       185 |   123 | root export — includes the live `prisma` client |
| `@cona/database/tracked`     |         0 |   185 | `withTrackedTransaction` — the sanctioned path  |
| `@cona/database/enums`       |         2 |     7 |                                                 |
| `@cona/database/seed-data`   |         0 |     4 |                                                 |
| `@cona/database/seed-eu-vat` |         0 |     1 |                                                 |

The accurate rule is: **webapp reaches the database through `@cona/core` or
`@cona/database/tracked`, with 40 files still bypassing both.**

## Console is a different architecture

Console does not use `@cona/core` at all — it reads and writes through `@cona/database`
directly. This is intentional given its superadmin scope, but it means the layering rules
above simply do not apply to it. See [Console](/architecture/console-architecture).

## Notes

**`@cona/core` has no usable barrel.** All 674 consumer imports go through subpaths —
541 via `@cona/core/domains/*` across 53 domains, 133 via named subpaths like
`/redis` and `/logger`. The `.` export (`src/index.ts`) is imported by **nothing**. Draw
core as 53 addressable modules, not one block. See
[Core Domain Map](/architecture/core-domain-map).

**One inverted edge.** `@cona/database` imports `@cona/temporal-config`
(`src/direct-client.ts:1`) — the data layer depending on Temporal configuration.

**Three runtime deps are declared as devDependencies** in `apps/webapp/package.json`:
`@cona/core` (343 imports), `@cona/types` (621), `@cona/temporal-config` (48). Next.js
bundles them so it works, but it misrepresents the graph to tooling.

**Two directories look like packages but are not.** `packages/temporal-core` and
`apps/sse-server` contain only `node_modules`/build output, are untracked, and have no
`package.json`. They are excluded everywhere in this section.
