# zznidar/colony-counter architecture

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

- Interactive diagram: https://gitdiagram.com/zznidar/colony-counter
- Repository: https://github.com/zznidar/colony-counter

## Overview

Colony Counter is a browser prototype that estimates bacterial colony counts from a Petri-dish photo. The documented workflow is to choose a photo, optionally tune dish and colony-detection settings, then inspect the annotated image and count. The analysis is implemented in one large JavaScript file, so its distinct responsibilities share that path. The service worker provides an offline-capable delivery path using a file list in `cc-offline.js`. Source excerpts are partial; relationships not shown in them are included only where the README documents the workflow.

Main entry points: [`sw.js`](https://github.com/zznidar/colony-counter/blob/main/sw.js) (Offline service worker), [`index.js`](https://github.com/zznidar/colony-counter/blob/main/index.js) (Dish detection), [`index.html`](https://github.com/zznidar/colony-counter/blob/main/index.html) (App page), [`cc-offline.js`](https://github.com/zznidar/colony-counter/blob/main/cc-offline.js) (Offline file list)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_page["App page<br/>[index.html]"]
  node_photo["Photo selection<br/>[index.js]"]
  node_settings["Detection settings<br/>[index.js]"]
  node_result["Count result<br/>[index.js]"]
end

subgraph group_analysis["Image analysis"]
  node_dish["Dish detection<br/>[index.js]"]
  node_colour["Colour analysis<br/>[index.js]"]
  node_counting["Colony counting<br/>[index.js]"]
  node_annotations["Image annotations<br/>[index.js]"]
end

subgraph group_offline["Offline support"]
  node_worker["Offline service worker<br/>[sw.js]"]
  node_cache[("Offline cache")]
  node_offline_list["Offline file list<br/>[cc-offline.js]"]
end

node_user(("User"))

node_user -->|"opens"| node_page
node_page -->|"selects photo"| node_photo
node_photo -->|"analyses photo"| node_dish
node_settings -->|"adjusts detection"| node_dish
node_dish -->|"sets dish colours"| node_colour
node_colour -->|"classifies colonies"| node_counting
node_counting -->|"marks colonies"| node_annotations
node_annotations -->|"shows count"| node_result
node_worker -->|"loads file list"| node_offline_list
node_worker -->|"writes cached files"| node_cache
node_worker -->|"serves cached resources"| node_cache

click node_page "https://github.com/zznidar/colony-counter/blob/main/index.html"
click node_photo "https://github.com/zznidar/colony-counter/blob/main/index.js"
click node_settings "https://github.com/zznidar/colony-counter/blob/main/index.js"
click node_dish "https://github.com/zznidar/colony-counter/blob/main/index.js"
click node_colour "https://github.com/zznidar/colony-counter/blob/main/index.js"
click node_counting "https://github.com/zznidar/colony-counter/blob/main/index.js"
click node_annotations "https://github.com/zznidar/colony-counter/blob/main/index.js"
click node_result "https://github.com/zznidar/colony-counter/blob/main/index.js"
click node_worker "https://github.com/zznidar/colony-counter/blob/main/sw.js"
click node_offline_list "https://github.com/zznidar/colony-counter/blob/main/cc-offline.js"

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_page,node_photo,node_settings,node_result,node_user toneBlue
class node_dish,node_colour,node_counting,node_annotations toneAmber
class node_worker,node_cache,node_offline_list toneMint
```

## Components

### User interface

- [App page](https://github.com/zznidar/colony-counter/blob/main/index.html): `index.html`
- [Photo selection](https://github.com/zznidar/colony-counter/blob/main/index.js): `index.js`
- [Detection settings](https://github.com/zznidar/colony-counter/blob/main/index.js): `index.js`
- [Count result](https://github.com/zznidar/colony-counter/blob/main/index.js): `index.js`

### Image analysis

- [Dish detection](https://github.com/zznidar/colony-counter/blob/main/index.js): `index.js`
- [Colour analysis](https://github.com/zznidar/colony-counter/blob/main/index.js): `index.js`
- [Colony counting](https://github.com/zznidar/colony-counter/blob/main/index.js): `index.js`
- [Image annotations](https://github.com/zznidar/colony-counter/blob/main/index.js): `index.js`

### Offline support

- [Offline service worker](https://github.com/zznidar/colony-counter/blob/main/sw.js): `sw.js`
- **Offline cache**
- [Offline file list](https://github.com/zznidar/colony-counter/blob/main/cc-offline.js): `cc-offline.js`

### Other components

- **User**

## Connections

- User → App page: opens (evidence: `README.md`)
- App page → Photo selection: selects photo (evidence: `README.md`)
- Photo selection → Dish detection: analyses photo (evidence: `README.md`)
- Detection settings → Dish detection: adjusts detection (evidence: `README.md`)
- Dish detection → Colour analysis: sets dish colours (evidence: `index.js`)
- Colour analysis → Colony counting: classifies colonies (evidence: `README.md`)
- Colony counting → Image annotations: marks colonies (evidence: `README.md`)
- Image annotations → Count result: shows count (evidence: `README.md`)
- Offline service worker → Offline file list: loads file list (evidence: `sw.js`)
- Offline service worker → Offline cache: writes cached files (evidence: `sw.js`)
- Offline service worker → Offline cache: serves cached resources (evidence: `sw.js`)
