# senaite/senaite.patient architecture

> Architecture diagram of the GitHub repository senaite/senaite.patient, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/senaite/senaite.patient
- Repository: https://github.com/senaite/senaite.patient

## Overview

##### Project type and purpose
- From the README and file tree, this is a Plone/Zope add-on (“senaite.patient”) that plugs into the SENAITE LIMS platform to provide patient handling.
- It consists of Python/ZCML backend components (content types, adapters, views, indexers, upgrade handlers) and a small set of frontend assets (JS/Coffee, SCSS, PT templates) built via webpack.

##### File structure
- Top-level files: buildout.cfg, setup.py/cfg, requirements.txt, CI workflows, docs/ for changelog, tests.
- src/senaite/patient: the core Python package implementing Plone content types (patient, sample, folder), ZCML config (configure.zcml scattered in adapters/, browser/, catalog/, jsonapi/, upgrade/), permissions, profiles (GenericSetup for install/uninstall), upgrade scripts, validators, vocabularies, i18n resources.
- webpack/: build pipeline for CoffeeScript components, SCSS, JS entry points, producing senaite.patient bundles consumed by the Plone resource registry.

##### README for additional insights
- Confirms the add-on nature (“adds Patient handling to SENAITE LIMS”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser(["Client Browser"]):::client

    %% Installation & Configuration
    subgraph "Installation & Configuration"
        Buildout["Buildout & setup.py"]:::infra
        GenericSetup["GenericSetup Profiles"]:::infra
        UpgradeHandlers["Upgrade Handlers & Migration Scripts"]:::infra
        SetupHandlers["Setup Handlers"]:::infra
        ZCMLRegistry["ZCML Registration"]:::infra
    end

    %% Runtime Backend
    subgraph "Runtime Backend (Plone/Zope + senaite.patient)"
        ContentTypes["Content Type Definitions & Schemas"]:::backend
        Adapters["Adapters & Behaviors"]:::backend
        BrowserViews["Browser Views & Control Panel"]:::backend
        PatientViews["Patient-specific Views"]:::backend
        Viewlets["Viewlets"]:::backend
        Widgets["Widgets"]:::backend
        Indexers["Catalog Indexers"]:::backend
        JSONAPI["JSON API Endpoints"]:::backend
        Permissions["Permissions Configuration"]:::backend
        I18n["Internationalization (i18n)"]:::backend
        Monkeys["Monkeys (Patches)"]:::backend
    end

    %% Runtime Frontend
    subgraph "Runtime Frontend"
        Webpack["Frontend Asset Pipeline (webpack)"]:::frontend
        Bundles["Static Bundles"]:::frontend
        ResourceRegistry["Plone Resource Registry"]:::frontend
    end

    %% Data Layer
    ZODB[(ZODB Datastore)]:::data

    %% Connections
    Browser -->|"HTTP Requests"| ResourceRegistry
    ResourceRegistry -->|"Serves JS/CSS"| Browser
    Browser -->|"HTTP Requests"| ZCMLRegistry
    ZCMLRegistry -->|"Dispatches to Views"| BrowserViews
    BrowserViews -->|"Uses Content Types & Adapters"| ContentTypes
    BrowserViews --> Adapters
    PatientViews --> ContentTypes
    Viewlets --> BrowserViews
    Widgets --> BrowserViews
    JSONAPI --> ContentTypes
    JSONAPI --> Indexers
    BrowserViews -->|"JSON API"| JSONAPI
    Webpack -->|"Builds Bundles"| Bundles
    Bundles --> ResourceRegistry
    Browser -->|"Loads Bundles"| Bundles
    ContentTypes -->|"Stores/Retrieves"| ZODB
    Adapters --> ZODB
    Indexers --> ZODB
    Monkeys --> ContentTypes
    Monkeys --> Adapters
    Permissions --> ZCMLRegistry
    I18n --> ZCMLRegistry
    GenericSetup --> ZCMLRegistry
    UpgradeHandlers --> GenericSetup
    Buildout --> SetupHandlers
    SetupHandlers --> GenericSetup

    %% Click Events
    click ContentTypes "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/content"
    click Adapters "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/adapters"
    click BrowserViews "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/browser"
    click PatientViews "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/browser/patient"
    click Viewlets "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/browser/viewlets"
    click Widgets "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/browser/widgets"
    click Indexers "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/catalog/indexer"
    click JSONAPI "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/jsonapi"
    click UpgradeHandlers "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/upgrade"
    click GenericSetup "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/profiles/default"
    click SetupHandlers "https://github.com/senaite/senaite.patient/blob/master/src/senaite/patient/setuphandlers.py"
    click Permissions "https://github.com/senaite/senaite.patient/blob/master/src/senaite/patient/permissions.zcml"
    click I18n "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/locales"
    click Monkeys "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/monkeys"
    click Webpack "https://github.com/senaite/senaite.patient/tree/master/webpack"
    click Bundles "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/browser/static/bundles"
    click ResourceRegistry "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/browser/static/bundles"
    click Themes "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/browser/theme"
    click Skins "https://github.com/senaite/senaite.patient/tree/master/src/senaite/patient/skins/templates/senaite_patient_widgets"

    %% Styles
    classDef client fill:#81C784,stroke:#388E3C,color:#000;
    classDef infra fill:#FFCC80,stroke:#EF6C00,color:#000;
    classDef backend fill:#90CAF9,stroke:#1E88E5,color:#000;
    classDef frontend fill:#F48FB1,stroke:#C2185B,color:#000;
    classDef data fill:#CE93D8,stroke:#8E24AA,color:#000;
```
