# sarverott/p-jol-roll architecture

> Architecture diagram of the GitHub repository sarverott/p-jol-roll, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sarverott/p-jol-roll
- Repository: https://github.com/sarverott/p-jol-roll

## Overview

P_JOL_ROLL gathers Polish legal publications and related Sejm and court data, preserves raw files and tables, verifies and transforms them, then exposes the resulting law through readers, search, an API, a website, and MCP tools. The main data path is gathering → checksum sealing → compilation and text conversion → reading and search; users enter through several interfaces. The README also documents resource synchronization and durable, approval-based daily runs. Edges are limited to README statements and source-index references; unsampled wiring is not inferred.

Main entry points: [`src/openapi/routes.ts`](https://github.com/sarverott/p-jol-roll/blob/master/src/openapi/routes.ts) (HTTP API), [`src/core/resources/store.ts`](https://github.com/sarverott/p-jol-roll/blob/master/src/core/resources/store.ts) (Resource store), [`src/core/methods/seal.ts`](https://github.com/sarverott/p-jol-roll/blob/master/src/core/methods/seal.ts) (Checksum sealing), [`src/core/methods/compile.ts`](https://github.com/sarverott/p-jol-roll/blob/master/src/core/methods/compile.ts) (Table compilation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection and processing"]
  node_gathering["Data gathering<br/>[gather.ts]"]
  node_source_handlers["Source handlers"]
  node_sealing["Checksum sealing<br/>[seal.ts]"]
  node_compilation["Table compilation<br/>[compile.ts]"]
  node_text_parsing["Text conversion<br/>[text.ts]"]
end

subgraph group_data["Law data services"]
  node_resource_store[("Resource store<br/>[store.ts]")]
  node_remote_reader["Remote resource cache<br/>[remote.ts]"]
  node_dataset_reader["Dataset reader<br/>[dataset.ts]"]
  node_law_library["Law library and maps<br/>[library.ts]"]
  node_debates_reader["Debate records<br/>[debates.ts]"]
  node_embeddings["Meaning search<br/>[embeddings.ts]"]
  node_typesense["Full-text search<br/>[typesense.ts]"]
end

subgraph group_interfaces["Reader interfaces"]
  node_api["HTTP API<br/>[routes.ts]"]
  node_website["Browser viewer<br/>[index.vue]"]
  node_mcp["MCP tools<br/>[server.ts]"]
  node_desktop["Desktop app<br/>[main.js]"]
end

subgraph group_operations["Operations and analysis"]
  node_workflow["Daily workflows<br/>[daily.ts]"]
  node_mastermind["Legal analysis assistant<br/>[main.ts]"]
  node_almanac["Act analysis and rulings<br/>[main.ts]"]
  node_resource_sync["Resource synchronization<br/>[hub.ts]"]
end

node_operator(("Operator"))
node_agent(("AI agent"))
node_external_sources(("Government sources"))

node_operator -->|"starts gathering"| node_gathering
node_external_sources -->|"provides publications"| node_gathering
node_gathering -.->|"fetches records"| node_source_handlers
node_operator -->|"starts processing"| node_sealing
node_sealing -->|"precedes compilation"| node_compilation
node_compilation -->|"precedes conversion"| node_text_parsing
node_sealing -.->|"stores records"| node_resource_store
node_compilation -.->|"stores tables"| node_resource_store
node_text_parsing -.->|"stores markdown"| node_resource_store
node_remote_reader -->|"caches files"| node_resource_store
node_dataset_reader -->|"reads local data"| node_resource_store
node_dataset_reader -->|"fetches missing data"| node_remote_reader
node_law_library -->|"loads remote data"| node_remote_reader
node_law_library -->|"reads resources"| node_resource_store
node_agent -->|"requests law tools"| node_mcp
node_api -->|"serves dataset routes"| node_dataset_reader
node_api -->|"serves map routes"| node_law_library
node_api -->|"serves debate routes"| node_debates_reader
node_api -->|"serves search routes"| node_typesense
node_api -.->|"serves meaning search"| node_embeddings
node_website -.->|"browses through"| node_api
node_desktop -->|"starts local API"| node_api
node_operator -->|"approves daily runs"| node_workflow
node_operator -->|"syncs resources"| node_resource_sync
node_operator -.->|"asks legal questions"| node_mastermind
node_operator -.->|"reviews acts"| node_almanac

click node_gathering "https://github.com/sarverott/p-jol-roll/blob/master/src/core/methods/gather.ts"
click node_source_handlers "https://github.com/sarverott/p-jol-roll/tree/master/src/core/apihandlers"
click node_sealing "https://github.com/sarverott/p-jol-roll/blob/master/src/core/methods/seal.ts"
click node_compilation "https://github.com/sarverott/p-jol-roll/blob/master/src/core/methods/compile.ts"
click node_text_parsing "https://github.com/sarverott/p-jol-roll/blob/master/src/core/parsing/text.ts"
click node_resource_store "https://github.com/sarverott/p-jol-roll/blob/master/src/core/resources/store.ts"
click node_remote_reader "https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/remote.ts"
click node_dataset_reader "https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/dataset.ts"
click node_law_library "https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/library.ts"
click node_debates_reader "https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/debates.ts"
click node_embeddings "https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/embeddings.ts"
click node_typesense "https://github.com/sarverott/p-jol-roll/blob/master/src/core/search/typesense.ts"
click node_api "https://github.com/sarverott/p-jol-roll/blob/master/src/openapi/routes.ts"
click node_website "https://github.com/sarverott/p-jol-roll/blob/master/src/gui/index.vue"
click node_mcp "https://github.com/sarverott/p-jol-roll/blob/master/src/mcp/server.ts"
click node_desktop "https://github.com/sarverott/p-jol-roll/blob/master/src/desktop/main.js"
click node_workflow "https://github.com/sarverott/p-jol-roll/blob/master/src/workflows/flows/daily.ts"
click node_mastermind "https://github.com/sarverott/p-jol-roll/blob/master/src/mastermind/main.ts"
click node_almanac "https://github.com/sarverott/p-jol-roll/blob/master/src/almanac/main.ts"
click node_resource_sync "https://github.com/sarverott/p-jol-roll/blob/master/src/core/resources/hub.ts"

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_gathering,node_source_handlers,node_sealing,node_compilation,node_text_parsing toneBlue
class node_resource_store,node_remote_reader,node_dataset_reader,node_law_library,node_debates_reader,node_embeddings,node_typesense toneAmber
class node_api,node_website,node_mcp,node_desktop toneMint
class node_workflow,node_mastermind,node_almanac,node_resource_sync toneRose
class node_operator,node_agent,node_external_sources toneIndigo
```

## Components

### Collection and processing

- [Data gathering](https://github.com/sarverott/p-jol-roll/blob/master/src/core/methods/gather.ts): `src/core/methods/gather.ts`
- [Source handlers](https://github.com/sarverott/p-jol-roll/tree/master/src/core/apihandlers): `src/core/apihandlers`
- [Checksum sealing](https://github.com/sarverott/p-jol-roll/blob/master/src/core/methods/seal.ts): `src/core/methods/seal.ts`
- [Table compilation](https://github.com/sarverott/p-jol-roll/blob/master/src/core/methods/compile.ts): `src/core/methods/compile.ts`
- [Text conversion](https://github.com/sarverott/p-jol-roll/blob/master/src/core/parsing/text.ts): `src/core/parsing/text.ts`

### Law data services

- [Resource store](https://github.com/sarverott/p-jol-roll/blob/master/src/core/resources/store.ts): `src/core/resources/store.ts`
- [Remote resource cache](https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/remote.ts): `src/core/reading/remote.ts`
- [Dataset reader](https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/dataset.ts): `src/core/reading/dataset.ts`
- [Law library and maps](https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/library.ts): `src/core/reading/library.ts`
- [Debate records](https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/debates.ts): `src/core/reading/debates.ts`
- [Meaning search](https://github.com/sarverott/p-jol-roll/blob/master/src/core/reading/embeddings.ts): `src/core/reading/embeddings.ts`
- [Full-text search](https://github.com/sarverott/p-jol-roll/blob/master/src/core/search/typesense.ts): `src/core/search/typesense.ts`

### Reader interfaces

- [HTTP API](https://github.com/sarverott/p-jol-roll/blob/master/src/openapi/routes.ts): `src/openapi/routes.ts`
- [Browser viewer](https://github.com/sarverott/p-jol-roll/blob/master/src/gui/index.vue): `src/gui/index.vue`
- [MCP tools](https://github.com/sarverott/p-jol-roll/blob/master/src/mcp/server.ts): `src/mcp/server.ts`
- [Desktop app](https://github.com/sarverott/p-jol-roll/blob/master/src/desktop/main.js): `src/desktop/main.js`

### Operations and analysis

- [Daily workflows](https://github.com/sarverott/p-jol-roll/blob/master/src/workflows/flows/daily.ts): `src/workflows/flows/daily.ts`
- [Legal analysis assistant](https://github.com/sarverott/p-jol-roll/blob/master/src/mastermind/main.ts): `src/mastermind/main.ts`
- [Act analysis and rulings](https://github.com/sarverott/p-jol-roll/blob/master/src/almanac/main.ts): `src/almanac/main.ts`
- [Resource synchronization](https://github.com/sarverott/p-jol-roll/blob/master/src/core/resources/hub.ts): `src/core/resources/hub.ts`

### Other components

- **Operator**
- **AI agent**
- **Government sources**

## Connections

- Operator → Data gathering: starts gathering (evidence: `README.md`)
- Government sources → Data gathering: provides publications (evidence: `README.md`)
- Data gathering → Source handlers: fetches records
- Operator → Checksum sealing: starts processing (evidence: `README.md`)
- Checksum sealing → Table compilation: precedes compilation (evidence: `README.md`)
- Table compilation → Text conversion: precedes conversion (evidence: `README.md`)
- Checksum sealing → Resource store: stores records
- Table compilation → Resource store: stores tables
- Text conversion → Resource store: stores markdown
- Remote resource cache → Resource store: caches files (evidence: `src/core/reading/remote.ts`)
- Dataset reader → Resource store: reads local data (evidence: `src/core/reading/dataset.ts`)
- Dataset reader → Remote resource cache: fetches missing data (evidence: `src/core/reading/dataset.ts`)
- Law library and maps → Remote resource cache: loads remote data (evidence: `src/core/reading/library.ts`)
- Law library and maps → Resource store: reads resources (evidence: `src/core/reading/library.ts`)
- AI agent → MCP tools: requests law tools (evidence: `src/mcp/server.ts`)
- HTTP API → Dataset reader: serves dataset routes (evidence: `src/openapi/routes.ts`)
- HTTP API → Law library and maps: serves map routes (evidence: `src/openapi/routes.ts`)
- HTTP API → Debate records: serves debate routes (evidence: `src/openapi/routes.ts`)
- HTTP API → Full-text search: serves search routes (evidence: `src/openapi/routes.ts`)
- HTTP API → Meaning search: serves meaning search
- Browser viewer → HTTP API: browses through
- Desktop app → HTTP API: starts local API (evidence: `src/desktop/main.js`)
- Operator → Daily workflows: approves daily runs (evidence: `README.md`)
- Operator → Resource synchronization: syncs resources (evidence: `README.md`)
- Operator → Legal analysis assistant: asks legal questions
- Operator → Act analysis and rulings: reviews acts
