A desktop application for assessing, aggregating, and analysing policy coherence across multiple decision-makers.
Policy Coherence Kit allows researchers and policy professionals to:
- Build n×n policy interaction matrices for multiple decision-makers or experts
- Rate how policies influence each other using a structured 7-point linguistic scale
- Aggregate views across decision-makers using average, majority rule, or weighted methods
- Run a suite of analytical tools on the aggregated results
- Generate LLM-powered interpretations of the results using your preferred AI engine
- Manage multiple independent projects in a single session
- Export all results to Excel
| Rating | Score | Meaning |
|---|---|---|
| Indivisible | +3 | Policies are fully intertwined and inseparable |
| Reinforcing | +2 | Policies mutually strengthen each other |
| Enabling | +1 | One policy helps the other work better |
| Neutral | 0 | No meaningful interaction |
| Constraining | -1 | One policy limits the other's effectiveness |
| Counteracting | -2 | Policies work against each other |
| Cancelling | -3 | One policy completely negates the other |
- Create multiple independent projects in a single session
- Each project has its own decision-makers, matrices, and analysis results
- Enter policy names manually (one per line)
- Import full matrices from multi-sheet Excel workbooks — each sheet becomes one decision-maker
- Diagonal cells are permanently locked to Neutral
- Colour-coded dropdowns for rating each cell
- Average: arithmetic mean across decision-makers
- Median: ordinal median aggregation, with lower/upper choice when the number of decision-makers is even
- Majority Rule: most common rating at each cell
- Weighted: weighted aggregation using user-defined decision-maker weights
| Tab | Description |
|---|---|
| Aggregated Matrix | Numeric score matrix (-3 to +3), colour-coded |
| Coherence Scores | OI, II, WOI, WII — outgoing/incoming influence counts and sums |
| Range of Influence | Shannon entropy per policy — concentrated vs distributed influence |
| PCA | 2D scatter plot of policy influence profiles (PC1 + PC2), with entropy colouring option |
| Network Analysis | Directed weighted network with 4 layout options + betweenness/closeness centrality |
| LLM Interpretation | Structured AI-generated interpretation using your API key |
- Circular — equal spacing baseline
- Force-Directed (default) — Fruchterman-Reingold spring model
- Spectral — eigenvector-based clustering of similar policies
- Shell — high-betweenness policies in the centre ring
- Excel — one workbook per project with sheets for: all DM matrices, aggregated matrix, coherence scores, range of influence, and network centrality
- LLM interpretation — downloadable as
.txtor.pdf - PCA and Network plots — saveable as PNG (requires Pillow) or PostScript
The application is rebuilt as a web app in apps/: a FastAPI API in apps/api and a TanStack Start web app
in apps/web. Both run in Docker with just; the host needs only Docker (or podman) and
just. Install just with brew install just (macOS), sudo apt install just (Debian 13+/Ubuntu 24.04+) or the prebuilt binaries (Linux, any distribution), or winget install Casey.Just (Windows). The legacy Tk
desktop app below lives in tk-app/ and is kept as the reference.
just setup # create apps/api/.env and apps/web/.env from their .env.example files
just dev # start the API and the web app with hot reload
just check-api # API checks inside the dev container: Ruff format, Ruff lint, pytest
just prod # production: API and web, served by the VPS's shared HTTPS proxy
just # every recipe| Address | What |
|---|---|
http://localhost:50002/api/docs |
API docs (development) |
http://localhost:3001 |
Web app (development; API at http://localhost:50002) |
| Configured HTTPS hostname | Production on the VPS, through the shared proxy (/api/ goes to the API) |
The API is stateless: every request carries the whole project. AI provider keys are sent per request and never
stored, and travel only over HTTPS on the VPS. See apps/api/README.md and
AGENTS.md.
On the VPS, one shared Nginx serves this app and DEMATELab next to it, and owns ports 80 and 443. Its config and
the orchestration of both apps live in the DEMATELab repository's nginx/ folder: from the DEMATELab checkout run just proxy up-policycoherencekit, just proxy up-all, or just proxy
to list them (decision). Routes, body size and
timeouts for this app are in DEMATELab's nginx/templates/policycoherencekit.conf.template.
- Python 3.9 or higher
- Required packages:
openpyxlnumpyreportlab
- Optional package for PNG export:
Pillow
Install dependencies:
pip install openpyxl numpy reportlab Pillow- Clone or download this repository:
git clone https://github.com/atorkayesh/PolicyCoherenceKit.git- Navigate to the project root folder:
cd PolicyCoherenceKitThe legacy application files are in tk-app/.
- `main.py` - application launcher
- `app.py` - main GUI and workflow logic
- `aggregator.py` - aggregation methods
- `aggregation_dialog.py` - aggregation dialogs
- `aggregation_tab.py` - aggregated matrix view
- `coherence_scores_tab.py` - coherence scores module
- `range_of_influence_tab.py` - entropy / range of influence module
- `pca_tab.py` - PCA module
- `network_tab.py` - network analysis module
- `results_insights_tab.py` - consensus, disagreement, and summary insights
- `llm_tab.py` - LLM interpretation module
- `importer.py` - Excel import logic
- `dialogs.py` - reusable dialogs
- `models.py` - data models
- `matrix_widget.py` - matrix input widget
- `constants.py` - shared constants and labels
- `theme.py` - theme and UI styling
- `../data/examples/WEF Nexus Example.xlsx` - sample workbook for testing (repository root `data/examples/`)
- Run the app from
tk-app/:
cd tk-app
python main.pyThe LLM tab supports the following engines:
| Engine | Notes |
|---|---|
| Groq | Free tier available |
| OpenAI | Requires paid API key |
Privacy: API keys are used for a single request and cleared from memory immediately. They are never stored to disk.
The interpretation covers seven structured sections:
- Overall Coherence Assessment
- Key Synergies
- Key Conflicts
- Influential Policies
- Range of Influence
- Network Structure
- Strategic Recommendations
When importing a multi-sheet workbook, each sheet must follow this structure:
[blank] Climate Policy Energy Reform Urban Mobility
Climate Policy Neutral Reinforcing Enabling
Energy Reform Constraining Neutral Indivisible
Urban Mobility Cancelling Enabling Neutral
- Row 1, Col 1: ignored (corner cell)
- Row 1, Col 2+: full policy names (column headers)
- Col 1, Row 2+: full policy names (row headers, must match column headers exactly)
- Data cells: one of the 7 rating labels (case-insensitive)
- Sheet name: becomes the decision-maker name
A sample workbook is provided in the repository: data/examples/WEF Nexus Example.xlsx
The legacy Tk app (tk-app/) can also run in a container and be used from a browser (via noVNC), with no local Python or Tk setup.
Requirements: to run it locally, install Docker and Make:
- macOS: Docker Desktop (or OrbStack). Make comes with the Xcode Command Line Tools:
xcode-select --install. - Linux: Docker Engine with the Compose plugin, installed from Docker's own repository (distribution packages such as
docker.iocan be too old), andmake(for examplesudo apt install make). Add your user to thedockergroup rather than running withsudo. - Windows: Docker Desktop, plus Make in one of two ways: inside WSL (
sudo apt install make, then run the commands from WSL), or install it withwinget install ezwinports.makeorchoco install makeand run it from Git Bash (Git for Windows doesn't include Make). Without Make, use thedocker composecommands below.
Docker Engine 25 or newer and Docker Compose 2.24 or newer are required (current Docker Desktop includes both).
All commands run from the repository root with -C tk-app (or from inside tk-app/ without it):
make -C tk-app dev # build and start the dev setup, then print http://localhost:6090
make -C tk-app prod # build and start the prod setup (needs VNC_PASSWORD, see below)
make -C tk-app logs # follow the logs
make -C tk-app restart # restart the container
make -C tk-app status # show which setup is running
make -C tk-app shell # open a shell in the container
make -C tk-app down # stop and remove the containerOnly one setup runs at a time, because both use the same port: make dev stops prod first, and make prod stops dev. logs, restart, status, shell and down act on whichever one is running. To pick one explicitly, add MODE=dev or MODE=prod, for example make logs MODE=prod. Run make on its own to list the commands.
Dev (docker-compose-dev.yml) |
Prod (docker-compose-prod.yml) |
|
|---|---|---|
| Image | Dockerfile.dev (includes dev tools) |
Dockerfile.prod (runtime only) |
| Source | Mounted from the repository; the app restarts when a .py file changes |
Baked into the image; rebuild to update |
| Password | None by default | VNC_PASSWORD required in .env |
| Exports | tk-app/exports/ on the host |
policycoherencekit-exports Docker volume |
| Address | 127.0.0.1:${NOVNC_PORT:-6090} |
127.0.0.1:${NOVNC_PORT:-6090} (NOVNC_BIND to change the interface) |
Setup for production:
cp tk-app/.env.example tk-app/.env # then set VNC_PASSWORD
make -C tk-app prodWithout Make, use the plain docker compose commands from tk-app/ (these are what its make targets run):
docker compose -f docker-compose-dev.yml up -d --build --wait
docker compose -f docker-compose-dev.yml logs -f
docker compose -f docker-compose-dev.yml restart
docker compose -f docker-compose-dev.yml exec -u app policycoherencekit bash
docker compose -f docker-compose-dev.yml downFor prod, use docker-compose-prod.yml instead and stop dev first.
Notes:
- In the app's file dialogs, the example workbook is in
examples/(read-only) and exports should be saved toexports/. - Everyone who opens the URL shares the same app session, so the production setup suits one user at a time. noVNC traffic is not encrypted: before exposing it beyond
localhost, put it behind a TLS reverse proxy with its own login. VNC passwords are limited to 8 characters. - Without a
VNC_PASSWORD,make prodstops before starting. With plaindocker compose, the prod container logs the error once and waits instead of restarting, and after about 2 minutesdocker compose psreports it as unhealthy. - Dev and prod share
.env, so settingVNC_PASSWORDfor prod also adds a password to the dev session. - On Linux, the container runs the app as the owner of
exports/(normally you), so exported files are yours. Keep theexports/folder that comes with the repository: if it is missing, Docker creates it owned by root and the app then runs as root, so exported files are owned by root. With rootless Docker or Podman the app also runs as root inside the container, which is your own user on the host, so exports are still yours. - On Windows, dev reload works automatically with Docker Desktop's default WSL2 backend. If edits don't restart the app (for example with the Hyper-V backend), set
WATCHFILES_FORCE_POLLING=truein.env. - Dependencies are listed in
pyproject.toml(used for dependency management only; the app still runs withpython main.py) and locked inuv.lock. After changingpyproject.toml, runuv lockand rebuild.
MIT License — free to use, modify, and distribute with attribution.