# kierankinnaird/internal-tools architecture

> Architecture diagram of the GitHub repository kierankinnaird/internal-tools, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kierankinnaird/internal-tools
- Repository: https://github.com/kierankinnaird/internal-tools

## Overview

This repository is a local Flask suite of construction and cost engineering tools, loaded as independently mountable modules. Users can search construction norms, manage jobcards and workpack task estimates, or manage workpacks and fill certification forms from templates. The graph shows the host/module lifecycle and the principal jobcard and certification workflows, plus norms lookup. Several workpack subsystems are supported by the SOURCE INDEX but their internal calls were not excerpted; only documented/import-visible relationships are drawn. Interfaces and data flow are represented where evidenced.

Main entry points: [`modules/workpacks/web.py`](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/web.py) (Workpack routes), [`modules/workpacks/fill.py`](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/fill.py) (Fill service), [`modules/jobcards/web.py`](https://github.com/kierankinnaird/internal-tools/blob/master/modules/jobcards/web.py) (Jobcard routes), [`core/modules.py`](https://github.com/kierankinnaird/internal-tools/blob/master/core/modules.py) (Module mounting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host platform"]
  node_standalone["Standalone host<br/>[standalone.py]"]
  node_context["Host context<br/>[context.py]"]
  node_module_mount["Module mounting<br/>[modules.py]"]
  node_audit[("Audit log<br/>[context.py]")]
end

subgraph group_jobcards["Jobcards"]
  node_jc_web["Jobcard routes<br/>[web.py]"]
  node_jc_repo[("Jobcard records<br/>[repo.py]")]
  node_jc_calc["Hours and warnings<br/>[calc.py]"]
  node_jc_ui["Jobcard screens<br/>[jobcards.js]"]
end

subgraph group_norms["Norm lookup"]
  node_norm_web["Norm routes<br/>[web.py]"]
  node_norm_service["Norm search<br/>[service.py]"]
  node_norm_db[("Norms database<br/>[norms.sqlite]")]
end

subgraph group_workpacks["Workpack certificates"]
  node_wp_web["Workpack routes<br/>[web.py]"]
  node_wp_repo[("Project and certificates<br/>[repo.py]")]
  node_wp_fields["Form and row schema<br/>[fields.py]"]
  node_wp_rows["Certificate row tables<br/>[rowtables.py]"]
  node_wp_import["Workbook import<br/>[importer.py]"]
  node_wp_store["Template storage<br/>[store.py]"]
  node_wp_sheet["Input workbook<br/>[sheet.py]"]
  node_wp_fill["Fill service<br/>[fill.py]"]
  node_wp_engine["Document filling engine<br/>[fill_workpack.py]"]
  node_wp_runs["Saved fill runs<br/>[runs.py]"]
  node_wp_forms["Fill form settings<br/>[forms.py]"]
  node_wp_certfields["Certificate fields<br/>[certfields.py]"]
end

node_engineer(("Engineer"))

node_engineer -->|"uses tools"| node_standalone
node_standalone -->|"creates context"| node_context
node_standalone -->|"mounts modules"| node_module_mount
node_module_mount -->|"supplies context"| node_context
node_context -->|"writes events"| node_audit
node_module_mount -->|"registers routes"| node_jc_web
node_module_mount -->|"registers routes"| node_norm_web
node_module_mount -->|"registers routes"| node_wp_web
node_engineer -->|"manages cards"| node_jc_web
node_jc_web -->|"reads and saves"| node_jc_repo
node_jc_repo -->|"calculates totals"| node_jc_calc
node_jc_web -->|"calculates rollups"| node_jc_calc
node_jc_web -.->|"serves interface"| node_jc_ui
node_jc_web -->|"requests suggestions"| node_norm_service
node_engineer -->|"looks up norms"| node_norm_web
node_norm_web -->|"searches norms"| node_norm_service
node_norm_service -->|"queries database"| node_norm_db
node_engineer -->|"manages certificates"| node_wp_web
node_wp_web -->|"reads and saves"| node_wp_repo
node_wp_web -->|"uses form schema"| node_wp_fields
node_wp_web -->|"parses row input"| node_wp_rows
node_wp_web -->|"imports workbooks"| node_wp_import
node_wp_web -->|"checks templates"| node_wp_store
node_wp_web -->|"runs form filling"| node_wp_fill
node_wp_web -->|"stores run records"| node_wp_runs
node_wp_web -->|"configures fills"| node_wp_forms
node_wp_web -->|"builds field sections"| node_wp_certfields
node_wp_fill -->|"loads project data"| node_wp_repo
node_wp_fill -->|"checks templates"| node_wp_store
node_wp_fill -->|"writes workbook"| node_wp_sheet
node_wp_fill -->|"runs engine"| node_wp_engine
node_wp_fill -->|"selects row kinds"| node_wp_fields
node_wp_import -->|"uses schema"| node_wp_fields
node_wp_import -->|"saves imported data"| node_wp_repo
node_wp_import -->|"parses tables"| node_wp_rows
node_wp_import -->|"reads workbook format"| node_wp_engine
node_wp_rows -->|"uses row kinds"| node_wp_fields

click node_standalone "https://github.com/kierankinnaird/internal-tools/blob/master/hosts/standalone.py"
click node_context "https://github.com/kierankinnaird/internal-tools/blob/master/core/context.py"
click node_module_mount "https://github.com/kierankinnaird/internal-tools/blob/master/core/modules.py"
click node_audit "https://github.com/kierankinnaird/internal-tools/blob/master/core/context.py"
click node_jc_web "https://github.com/kierankinnaird/internal-tools/blob/master/modules/jobcards/web.py"
click node_jc_repo "https://github.com/kierankinnaird/internal-tools/blob/master/modules/jobcards/repo.py"
click node_jc_calc "https://github.com/kierankinnaird/internal-tools/blob/master/modules/jobcards/calc.py"
click node_jc_ui "https://github.com/kierankinnaird/internal-tools/blob/master/modules/jobcards/static/jobcards.js"
click node_norm_web "https://github.com/kierankinnaird/internal-tools/blob/master/modules/norms/web.py"
click node_norm_service "https://github.com/kierankinnaird/internal-tools/blob/master/modules/norms/service.py"
click node_norm_db "https://github.com/kierankinnaird/internal-tools/blob/master/modules/norms/data/norms.sqlite"
click node_wp_web "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/web.py"
click node_wp_repo "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/repo.py"
click node_wp_fields "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/fields.py"
click node_wp_rows "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/rowtables.py"
click node_wp_import "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/importer.py"
click node_wp_store "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/store.py"
click node_wp_sheet "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/sheet.py"
click node_wp_fill "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/fill.py"
click node_wp_engine "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/engine/fill_workpack.py"
click node_wp_runs "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/runs.py"
click node_wp_forms "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/forms.py"
click node_wp_certfields "https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/certfields.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_standalone,node_context,node_module_mount,node_audit toneBlue
class node_jc_web,node_jc_repo,node_jc_calc,node_jc_ui toneAmber
class node_norm_web,node_norm_service,node_norm_db toneMint
class node_wp_web,node_wp_repo,node_wp_fields,node_wp_rows,node_wp_import,node_wp_store,node_wp_sheet,node_wp_fill,node_wp_engine,node_wp_runs,node_wp_forms,node_wp_certfields toneRose
class node_engineer toneIndigo
```

## Components

### Host platform

- [Standalone host](https://github.com/kierankinnaird/internal-tools/blob/master/hosts/standalone.py): `hosts/standalone.py`
- [Host context](https://github.com/kierankinnaird/internal-tools/blob/master/core/context.py): `core/context.py`
- [Module mounting](https://github.com/kierankinnaird/internal-tools/blob/master/core/modules.py): `core/modules.py`
- [Audit log](https://github.com/kierankinnaird/internal-tools/blob/master/core/context.py): `core/context.py`

### Jobcards

- [Jobcard routes](https://github.com/kierankinnaird/internal-tools/blob/master/modules/jobcards/web.py): `modules/jobcards/web.py`
- [Jobcard records](https://github.com/kierankinnaird/internal-tools/blob/master/modules/jobcards/repo.py): `modules/jobcards/repo.py`
- [Hours and warnings](https://github.com/kierankinnaird/internal-tools/blob/master/modules/jobcards/calc.py): `modules/jobcards/calc.py`
- [Jobcard screens](https://github.com/kierankinnaird/internal-tools/blob/master/modules/jobcards/static/jobcards.js): `modules/jobcards/static/jobcards.js`

### Norm lookup

- [Norm routes](https://github.com/kierankinnaird/internal-tools/blob/master/modules/norms/web.py): `modules/norms/web.py`
- [Norm search](https://github.com/kierankinnaird/internal-tools/blob/master/modules/norms/service.py): `modules/norms/service.py`
- [Norms database](https://github.com/kierankinnaird/internal-tools/blob/master/modules/norms/data/norms.sqlite): `modules/norms/data/norms.sqlite`

### Workpack certificates

- [Workpack routes](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/web.py): `modules/workpacks/web.py`
- [Project and certificates](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/repo.py): `modules/workpacks/repo.py`
- [Form and row schema](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/fields.py): `modules/workpacks/fields.py`
- [Certificate row tables](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/rowtables.py): `modules/workpacks/rowtables.py`
- [Workbook import](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/importer.py): `modules/workpacks/importer.py`
- [Template storage](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/store.py): `modules/workpacks/store.py`
- [Input workbook](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/sheet.py): `modules/workpacks/sheet.py`
- [Fill service](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/fill.py): `modules/workpacks/fill.py`
- [Document filling engine](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/engine/fill_workpack.py): `modules/workpacks/engine/fill_workpack.py`
- [Saved fill runs](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/runs.py): `modules/workpacks/runs.py`
- [Fill form settings](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/forms.py): `modules/workpacks/forms.py`
- [Certificate fields](https://github.com/kierankinnaird/internal-tools/blob/master/modules/workpacks/certfields.py): `modules/workpacks/certfields.py`

### Other components

- **Engineer**

## Connections

- Engineer → Standalone host: uses tools (evidence: `README.md`)
- Standalone host → Host context: creates context (evidence: `hosts/standalone.py`)
- Standalone host → Module mounting: mounts modules (evidence: `hosts/standalone.py`)
- Module mounting → Host context: supplies context (evidence: `core/modules.py`)
- Host context → Audit log: writes events (evidence: `core/context.py`)
- Module mounting → Jobcard routes: registers routes (evidence: `modules/jobcards/manifest.py`)
- Module mounting → Norm routes: registers routes (evidence: `modules/norms/manifest.py`)
- Module mounting → Workpack routes: registers routes (evidence: `modules/workpacks/manifest.py`)
- Engineer → Jobcard routes: manages cards (evidence: `modules/jobcards/web.py`)
- Jobcard routes → Jobcard records: reads and saves (evidence: `modules/jobcards/web.py`)
- Jobcard records → Hours and warnings: calculates totals (evidence: `modules/jobcards/repo.py`)
- Jobcard routes → Hours and warnings: calculates rollups (evidence: `modules/jobcards/web.py`)
- Jobcard routes → Jobcard screens: serves interface
- Jobcard routes → Norm search: requests suggestions (evidence: `modules/jobcards/web.py`)
- Engineer → Norm routes: looks up norms (evidence: `modules/norms/web.py`)
- Norm routes → Norm search: searches norms (evidence: `modules/norms/web.py`)
- Norm search → Norms database: queries database (evidence: `modules/norms/service.py`)
- Engineer → Workpack routes: manages certificates (evidence: `modules/workpacks/web.py`)
- Workpack routes → Project and certificates: reads and saves (evidence: `modules/workpacks/web.py`)
- Workpack routes → Form and row schema: uses form schema (evidence: `modules/workpacks/web.py`)
- Workpack routes → Certificate row tables: parses row input (evidence: `modules/workpacks/web.py`)
- Workpack routes → Workbook import: imports workbooks (evidence: `modules/workpacks/web.py`)
- Workpack routes → Template storage: checks templates (evidence: `modules/workpacks/web.py`)
- Workpack routes → Fill service: runs form filling (evidence: `modules/workpacks/web.py`)
- Workpack routes → Saved fill runs: stores run records (evidence: `modules/workpacks/web.py`)
- Workpack routes → Fill form settings: configures fills (evidence: `modules/workpacks/web.py`)
- Workpack routes → Certificate fields: builds field sections (evidence: `modules/workpacks/web.py`)
- Fill service → Project and certificates: loads project data (evidence: `modules/workpacks/fill.py`)
- Fill service → Template storage: checks templates (evidence: `modules/workpacks/fill.py`)
- Fill service → Input workbook: writes workbook (evidence: `modules/workpacks/fill.py`)
- Fill service → Document filling engine: runs engine (evidence: `modules/workpacks/fill.py`)
- Fill service → Form and row schema: selects row kinds (evidence: `modules/workpacks/fill.py`)
- Workbook import → Form and row schema: uses schema (evidence: `modules/workpacks/importer.py`)
- Workbook import → Project and certificates: saves imported data (evidence: `modules/workpacks/importer.py`)
- Workbook import → Certificate row tables: parses tables (evidence: `modules/workpacks/importer.py`)
- Workbook import → Document filling engine: reads workbook format (evidence: `modules/workpacks/importer.py`)
- Certificate row tables → Form and row schema: uses row kinds (evidence: `modules/workpacks/rowtables.py`)
