# mraad/arcpi architecture

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

- Interactive diagram: https://gitdiagram.com/mraad/arcpi
- Repository: https://github.com/mraad/arcpi

## Overview

arcpi is a local GIS agent workspace: a user asks questions in Pi, where codemode composes ArcGIS REST calls and map operations, then returns a concise answer while mappi presents spatial results in a separate browser map. Its main stages are agent guidance, workflow composition, REST access, geometry-by-reference, and map presentation. The excerpts show the extension, REST/geometry helpers, and mappi server; unsampled skill and map-page behavior is included only where the README documents it.

Main entry points: [`arcgis-rest/dev.pi/extensions/arcgis/arcgis.ts`](https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/arcgis.ts) (REST request core), [`mappi/server.ts`](https://github.com/mraad/arcpi/blob/main/mappi/server.ts) (Mappi MCP server), [`arcpi`](https://github.com/mraad/arcpi/blob/main/arcpi) (Pi terminal), [`arcgis-rest/dev.pi/extensions/arcgis/index.ts`](https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/index.ts) (Pi extension)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Agent workflow"]
  node_pi["Pi terminal"]
  node_skills["GIS skills"]
  node_codemode["Codemode script"]
  node_openshell["OpenShell policy<br/>[openshell.md]"]
end

subgraph group_arcgis["ArcGIS access"]
  node_extension["Pi extension<br/>[index.ts]"]
  node_rest["REST request core<br/>[arcgis.ts]"]
  node_mcp_config["MCP registration<br/>[mcp.ts]"]
end

subgraph group_map["Map presentation"]
  node_mappi["Mappi MCP server<br/>[server.ts]"]
  node_map_runtime["Map code runtime<br/>[server.ts]"]
  node_browser_map["Browser map<br/>[index.html]"]
  node_map_artifact_api["Artifact delivery<br/>[server.ts]"]
end

subgraph group_state["Local artifacts"]
  node_geometry["Geometry references<br/>[geometry.ts]"]
  node_artifacts[("Geometry artifacts<br/>[geometry.ts]")]
end

node_user(("GIS user"))
node_arcgis_services{{"ArcGIS REST services"}}

node_user -->|"asks GIS questions"| node_pi
node_pi -->|"runs scripts"| node_codemode
node_skills -->|"guides calls"| node_codemode
node_codemode -->|"calls REST tool"| node_extension
node_extension -->|"executes request"| node_rest
node_rest -->|"sends HTTP requests"| node_arcgis_services
node_arcgis_services -->|"returns responses"| node_rest
node_rest -->|"externalizes and resolves shapes"| node_geometry
node_geometry -->|"writes and reads files"| node_artifacts
node_extension -->|"loads MCP servers"| node_mcp_config
node_codemode -->|"calls map tool"| node_mappi
node_mappi -->|"dispatches code"| node_map_runtime
node_map_runtime -->|"executes on page"| node_browser_map
node_browser_map -->|"returns results"| node_mappi
node_mappi -->|"reads shared auth"| node_rest
node_browser_map -->|"loads map files"| node_map_artifact_api
node_map_artifact_api -->|"serves local files"| node_artifacts
node_codemode -->|"returns summaries"| node_pi
node_openshell -->|"restricts runtime access"| node_pi

click node_pi "https://github.com/mraad/arcpi/blob/main/arcpi"
click node_skills "https://github.com/mraad/arcpi/tree/main/arcgis-rest/skills"
click node_extension "https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/index.ts"
click node_rest "https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/arcgis.ts"
click node_geometry "https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/geometry.ts"
click node_mcp_config "https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/mcp.ts"
click node_mappi "https://github.com/mraad/arcpi/blob/main/mappi/server.ts"
click node_map_runtime "https://github.com/mraad/arcpi/blob/main/mappi/server.ts"
click node_browser_map "https://github.com/mraad/arcpi/blob/main/mappi/index.html"
click node_artifacts "https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/geometry.ts"
click node_map_artifact_api "https://github.com/mraad/arcpi/blob/main/mappi/server.ts"
click node_openshell "https://github.com/mraad/arcpi/blob/main/docs/openshell.md"

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_pi,node_skills,node_codemode,node_openshell,node_user toneBlue
class node_extension,node_rest,node_mcp_config toneAmber
class node_mappi,node_map_runtime,node_browser_map,node_map_artifact_api toneMint
class node_geometry,node_artifacts toneRose
class node_arcgis_services toneIndigo
```

## Components

### Agent workflow

- [Pi terminal](https://github.com/mraad/arcpi/blob/main/arcpi): `arcpi`
- [GIS skills](https://github.com/mraad/arcpi/tree/main/arcgis-rest/skills): `arcgis-rest/skills`
- **Codemode script**
- [OpenShell policy](https://github.com/mraad/arcpi/blob/main/docs/openshell.md): `docs/openshell.md`

### ArcGIS access

- [Pi extension](https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/index.ts): `arcgis-rest/dev.pi/extensions/arcgis/index.ts`
- [REST request core](https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/arcgis.ts): `arcgis-rest/dev.pi/extensions/arcgis/arcgis.ts`
- [MCP registration](https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/mcp.ts): `arcgis-rest/dev.pi/extensions/arcgis/mcp.ts`

### Map presentation

- [Mappi MCP server](https://github.com/mraad/arcpi/blob/main/mappi/server.ts): `mappi/server.ts`
- [Map code runtime](https://github.com/mraad/arcpi/blob/main/mappi/server.ts): `mappi/server.ts`
- [Browser map](https://github.com/mraad/arcpi/blob/main/mappi/index.html): `mappi/index.html`
- [Artifact delivery](https://github.com/mraad/arcpi/blob/main/mappi/server.ts): `mappi/server.ts`

### Local artifacts

- [Geometry references](https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/geometry.ts): `arcgis-rest/dev.pi/extensions/arcgis/geometry.ts`
- [Geometry artifacts](https://github.com/mraad/arcpi/blob/main/arcgis-rest/dev.pi/extensions/arcgis/geometry.ts): `arcgis-rest/dev.pi/extensions/arcgis/geometry.ts`

### Other components

- **GIS user**
- **ArcGIS REST services**

## Connections

- GIS user → Pi terminal: asks GIS questions (evidence: `README.md`)
- Pi terminal → Codemode script: runs scripts (evidence: `README.md`)
- GIS skills → Codemode script: guides calls (evidence: `README.md`)
- Codemode script → Pi extension: calls REST tool (evidence: `README.md`)
- Pi extension → REST request core: executes request (evidence: `arcgis-rest/dev.pi/extensions/arcgis/index.ts`)
- REST request core → ArcGIS REST services: sends HTTP requests (evidence: `README.md`)
- ArcGIS REST services → REST request core: returns responses (evidence: `README.md`)
- REST request core → Geometry references: externalizes and resolves shapes (evidence: `arcgis-rest/dev.pi/extensions/arcgis/arcgis.ts`)
- Geometry references → Geometry artifacts: writes and reads files (evidence: `arcgis-rest/dev.pi/extensions/arcgis/geometry.ts`)
- Pi extension → MCP registration: loads MCP servers (evidence: `arcgis-rest/dev.pi/extensions/arcgis/index.ts`)
- Codemode script → Mappi MCP server: calls map tool (evidence: `README.md`)
- Mappi MCP server → Map code runtime: dispatches code (evidence: `mappi/server.ts`)
- Map code runtime → Browser map: executes on page (evidence: `mappi/server.ts`)
- Browser map → Mappi MCP server: returns results (evidence: `mappi/server.ts`)
- Mappi MCP server → REST request core: reads shared auth (evidence: `mappi/server.ts`)
- Browser map → Artifact delivery: loads map files (evidence: `README.md`)
- Artifact delivery → Geometry artifacts: serves local files (evidence: `mappi/server.ts`)
- Codemode script → Pi terminal: returns summaries (evidence: `README.md`)
- OpenShell policy → Pi terminal: restricts runtime access (evidence: `README.md`)
