# myicor/mypka architecture

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

- Interactive diagram: https://gitdiagram.com/myicor/mypka
- Repository: https://github.com/myicor/mypka

## Overview

#### Purpose and Operating Model
myPKA is a local-first, LLM-agnostic personal knowledge-assistance scaffold. Plain Markdown files are canonical; YAML frontmatter supplies structured fields and wikilinks connect entities. The repository combines an AI-team operating model, a knowledge-folder schema, and an optional local Cockpit UI. Root bootstrap and behavior contracts are `ADAPTER-PROMPT.md`, `AGENTS.md`, and `Team/agent-index.md`.

#### Human/LLM Entry Points
Users point an LLM at the repository and begin with `ADAPTER-PROMPT.md`; the root `AGENTS.md` governs shared behavior. Larry is the routing/orchestration boundary rather than an implementation runtime: `Team/Larry - Orchestrator/AGENTS.md`. Specialist contracts reside under `Team/`, while atomic procedures, multi-agent workstreams, and durable conventions are under `Team Knowledge/SOPs/`, `Team Knowledge/Workstreams/`, and `Team Knowledge/Guidelines/`.

#### Knowledge and Work-State Layer
`PKM/` is the canonical personal knowledge store: structured life entities, CRM, documents, images, and dated journals. Templates define entity shape in `Team Knowledge/Templates/`; frontmatter conventions are centralized in `Team Knowledge/Guidelines/GL-002-frontmatter-conventions.md`. Raw intake enters `Team Inbox/`, gets normalized and filed into PKM, and research or multi-specialist artifacts go to `Deliverables/`. Wikilinks form the cross-document graph rather than folder hierarchy.

#### Multi-Agent Continuity Workflow
Larry accepts and routes requests to six role-specific agents; their contracts and durable journals are colocated in paths such as `Team/Pax - Researcher/AGENTS.md` and `Team/Silas - Database Architect/AGENTS.md`. Work spanning sessions is represented as Markdown task files progressing through `Team Knowledge/tasks/open/`, `Team Knowledge/tasks/in-progress/`, and archived outcomes. Session logs preserve operational history in `Team Knowledge/session-logs/`. This is a filesystem workflow, so an LLM performs transitions and follows SOPs rather than invoking a central workflow engine.

#### Cockpit Local Application
The bundled expansion at `Expansions/mypka-cockpit/` is a local dashboard over the scaffold and SQLite mirror. Its Node server entry point is `Expansions/mypka-cockpit/server/server.js`; request composition and Cockpit data access are centered on `server/cockpit.js` and `server/queries.js`. The Vite/React TypeScript client starts at `web/src/main.tsx` and `web/src/App.tsx`, routing to views for dashboard, planner, documents, journal, graph/connections, workbench, and domain modules. Authentication is local PIN/session-oriented via `server/auth.js` and `web/src/components/AuthGate.tsx`.

#### Storage, Planner, and Content Boundaries
Markdown remains authoritative. SQLite is a regenerable read/lookup layer defined by `Expansions/mypka-cockpit/sqlite-extension/schema/` and populated by `scripts/regen-mypka-db.py`; Cockpit database migrations live in `server/migrations/`. The planner is a distinct persisted subsystem with API/database boundaries at `server/plannerRoutes.js` and `server/plannerDb.js`, consumed by planner UI/API logic under `web/src/lib/plannerApi.ts` and `web/src/views/PlannerView.tsx`. File-backed Markdown operations, document views, journal feeds, graph extraction, and workbench editing are exposed through dedicated server modules such as `server/documentsApi.js`, `server/journalFeed.js`, `server/graph.js`, and `server/workbench.js`.

#### Integrations and Extensibility
Expansion packs are installed alongside the Cockpit under `Expansions/`, governed by `Expansions/docs/expansion-spec.md` and `Team Knowledge/Workstreams/WS-003-install-an-expansion.md`. Cockpit connectors isolate external task/calendar/mail providers through `server/connectors/registry.js`, with implementations for ClickUp, Todoist, iCal, and IMAP. Credential/environment handling is separated in `server/connectors/env.js`; external embed retrieval is implemented by `scripts/fetch-embed.mjs`. The primary runtime stack is local Node.js for server/scripts, React/Vite/TypeScript for the UI, Python for migration/generation utilities, and SQLite for the optional mirror and Cockpit state.

Main entry points: [`PKM`](https://github.com/myicor/mypka/tree/main/PKM) (PKM Markdown Store), [`Team/Pax - Researcher/AGENTS.md`](https://github.com/myicor/mypka/blob/main/Team/Pax%20-%20Researcher/AGENTS.md) (Specialist Agents), [`Expansions/mypka-cockpit/server/server.js`](https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/server.js) (Cockpit Node Server), [`Team/Larry - Orchestrator/AGENTS.md`](https://github.com/myicor/mypka/blob/main/Team/Larry%20-%20Orchestrator/AGENTS.md) (Larry Orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operating["AI Team Operating Model"]
  node_adapter["Adapter Prompt<br/>LLM entry contract<br/>[ADAPTER-PROMPT.md]"]
  node_root_agents["Shared Agent Rules<br/>behavior contract<br/>[AGENTS.md]"]
  node_larry{{"Larry Orchestrator<br/>routing boundary<br/>[AGENTS.md]"}}
  node_specialists["Specialist Agents<br/>role contracts<br/>[AGENTS.md]"]
  node_team_practices["SOPs &amp; Workstreams<br/>team procedures"]
end

subgraph group_knowledge["Knowledge Workflow"]
  node_inbox["Team Inbox<br/>raw intake"]
  node_pkm[("PKM Markdown Store<br/>canonical knowledge")]
  node_templates["Entity Templates<br/>content schema"]
  node_frontmatter["Frontmatter Conventions<br/>metadata contract"]
  node_tasks["Task State Files<br/>work-state workflow"]
  node_session_logs["Session Logs<br/>operational history"]
  node_deliverables["Deliverables<br/>research artifacts"]
end

subgraph group_cockpit["Cockpit Application"]
  node_cockpit_server["Cockpit Node Server<br/>local HTTP server<br/>[server.js]"]
  node_cockpit_services["Cockpit Content APIs<br/>server modules<br/>[cockpit.js]"]
  node_auth["Local PIN Auth<br/>session auth<br/>[auth.js]"]
  node_web_client["React Cockpit UI<br/>Vite client<br/>[App.tsx]"]
end

subgraph group_storage["Storage &amp; Planner"]
  node_sqlite[("SQLite Mirror<br/>regenerable lookup store")]
  node_planner[("Persisted Planner<br/>planner API and database<br/>[plannerRoutes.js]")]
  node_planner_ui["Planner UI API<br/>planner client<br/>[plannerApi.ts]"]
end

subgraph group_extensions["Integrations &amp; Extensions"]
  node_connectors{{"Provider Connectors<br/>integration registry<br/>[registry.js]"}}
  node_expansion_spec["Expansion Specification<br/>extension contract<br/>[expansion-spec.md]"]
end

node_adapter -->|"loads"| node_root_agents
node_root_agents -->|"governs"| node_larry
node_larry -->|"routes work to"| node_specialists
node_specialists -->|"follow"| node_team_practices
node_larry -->|"advances"| node_tasks
node_specialists -->|"record sessions"| node_session_logs
node_inbox -->|"normalized and filed"| node_pkm
node_templates -.->|"defines entity shape"| node_pkm
node_frontmatter -.->|"standardizes metadata"| node_pkm
node_specialists -->|"produce"| node_deliverables
node_team_practices -.->|"guides transitions"| node_tasks
node_cockpit_server -->|"hosts"| node_cockpit_services
node_cockpit_server -->|"enforces"| node_auth
node_web_client -->|"local requests"| node_cockpit_server
node_cockpit_services -->|"reads and edits"| node_pkm
node_cockpit_services -->|"queries"| node_sqlite
node_pkm -.->|"regenerated into"| node_sqlite
node_planner_ui -->|"uses"| node_planner
node_web_client -->|"renders planner"| node_planner_ui
node_planner -->|"persists locally"| node_sqlite
node_cockpit_server -->|"loads"| node_connectors
node_expansion_spec -.->|"governs extension shape"| node_connectors

click node_adapter "https://github.com/myicor/mypka/blob/main/ADAPTER-PROMPT.md"
click node_root_agents "https://github.com/myicor/mypka/blob/main/AGENTS.md"
click node_larry "https://github.com/myicor/mypka/blob/main/Team/Larry%20-%20Orchestrator/AGENTS.md"
click node_specialists "https://github.com/myicor/mypka/blob/main/Team/Pax%20-%20Researcher/AGENTS.md"
click node_team_practices "https://github.com/myicor/mypka/tree/main/Team%20Knowledge/SOPs"
click node_inbox "https://github.com/myicor/mypka/tree/main/Team%20Inbox"
click node_pkm "https://github.com/myicor/mypka/tree/main/PKM"
click node_templates "https://github.com/myicor/mypka/tree/main/Team%20Knowledge/Templates"
click node_frontmatter "https://github.com/myicor/mypka/blob/main/Team%20Knowledge/Guidelines/GL-002-frontmatter-conventions.md"
click node_tasks "https://github.com/myicor/mypka/tree/main/Team%20Knowledge/tasks/open"
click node_session_logs "https://github.com/myicor/mypka/tree/main/Team%20Knowledge/session-logs"
click node_deliverables "https://github.com/myicor/mypka/tree/main/Deliverables"
click node_cockpit_server "https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/server.js"
click node_cockpit_services "https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/cockpit.js"
click node_auth "https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/auth.js"
click node_web_client "https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/web/src/App.tsx"
click node_sqlite "https://github.com/myicor/mypka/tree/main/Expansions/mypka-cockpit/sqlite-extension/schema"
click node_planner "https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/plannerRoutes.js"
click node_planner_ui "https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/web/src/lib/plannerApi.ts"
click node_connectors "https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/connectors/registry.js"
click node_expansion_spec "https://github.com/myicor/mypka/blob/main/Expansions/docs/expansion-spec.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_adapter,node_root_agents,node_larry,node_specialists,node_team_practices toneBlue
class node_inbox,node_pkm,node_templates,node_frontmatter,node_tasks,node_session_logs,node_deliverables toneAmber
class node_cockpit_server,node_cockpit_services,node_auth,node_web_client toneMint
class node_sqlite,node_planner,node_planner_ui toneRose
class node_connectors,node_expansion_spec toneIndigo
```

## Components

### AI Team Operating Model

Markdown contracts direct LLM-led work.

- [Adapter Prompt](https://github.com/myicor/mypka/blob/main/ADAPTER-PROMPT.md): LLM entry contract · Starting instructions for users and LLMs. · `ADAPTER-PROMPT.md`
- [Shared Agent Rules](https://github.com/myicor/mypka/blob/main/AGENTS.md): behavior contract · `AGENTS.md`
- [Larry Orchestrator](https://github.com/myicor/mypka/blob/main/Team/Larry%20-%20Orchestrator/AGENTS.md): routing boundary · Routes requests without being a runtime service. · `Team/Larry - Orchestrator/AGENTS.md`
- [Specialist Agents](https://github.com/myicor/mypka/blob/main/Team/Pax%20-%20Researcher/AGENTS.md): role contracts · Six role-specific agents with durable journals. · `Team/Pax - Researcher/AGENTS.md`
- [SOPs & Workstreams](https://github.com/myicor/mypka/tree/main/Team%20Knowledge/SOPs): team procedures · Atomic procedures, conventions, and multi-agent work. · `Team Knowledge/SOPs`

### Knowledge Workflow

Filesystem-based knowledge and work state.

- [Team Inbox](https://github.com/myicor/mypka/tree/main/Team%20Inbox): raw intake · `Team Inbox`
- [PKM Markdown Store](https://github.com/myicor/mypka/tree/main/PKM): canonical knowledge · Authoritative structured entities, documents, media, and journals. · `PKM`
- [Entity Templates](https://github.com/myicor/mypka/tree/main/Team%20Knowledge/Templates): content schema · `Team Knowledge/Templates`
- [Frontmatter Conventions](https://github.com/myicor/mypka/blob/main/Team%20Knowledge/Guidelines/GL-002-frontmatter-conventions.md): metadata contract · `Team Knowledge/Guidelines/GL-002-frontmatter-conventions.md`
- [Task State Files](https://github.com/myicor/mypka/tree/main/Team%20Knowledge/tasks/open): work-state workflow · Markdown tasks move from open through in-progress to archived outcomes. · `Team Knowledge/tasks/open`
- [Session Logs](https://github.com/myicor/mypka/tree/main/Team%20Knowledge/session-logs): operational history · `Team Knowledge/session-logs`
- [Deliverables](https://github.com/myicor/mypka/tree/main/Deliverables): research artifacts · `Deliverables`

### Cockpit Application

Optional local dashboard and APIs.

- [Cockpit Node Server](https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/server.js): local HTTP server · Local server entry point and request host. · `Expansions/mypka-cockpit/server/server.js`
- [Cockpit Content APIs](https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/cockpit.js): server modules · Document, journal, graph, and workbench filesystem operations. · `Expansions/mypka-cockpit/server/cockpit.js`
- [Local PIN Auth](https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/auth.js): session auth · `Expansions/mypka-cockpit/server/auth.js`
- [React Cockpit UI](https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/web/src/App.tsx): Vite client · Dashboard and domain views, including documents, journal, graph, and workbench. · `Expansions/mypka-cockpit/web/src/App.tsx`

### Storage & Planner

Canonical Markdown plus regenerable local state.

- [SQLite Mirror](https://github.com/myicor/mypka/tree/main/Expansions/mypka-cockpit/sqlite-extension/schema): regenerable lookup store · Derived Markdown mirror plus Cockpit state. · `Expansions/mypka-cockpit/sqlite-extension/schema`
- [Persisted Planner](https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/plannerRoutes.js): planner API and database · Separate planner persistence boundary. · `Expansions/mypka-cockpit/server/plannerRoutes.js`
- [Planner UI API](https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/web/src/lib/plannerApi.ts): planner client · `Expansions/mypka-cockpit/web/src/lib/plannerApi.ts`

### Integrations & Extensions

Optional packs and external-provider connectors.

- [Provider Connectors](https://github.com/myicor/mypka/blob/main/Expansions/mypka-cockpit/server/connectors/registry.js): integration registry · ClickUp, Todoist, iCal, and IMAP adapters. · `Expansions/mypka-cockpit/server/connectors/registry.js`
- [Expansion Specification](https://github.com/myicor/mypka/blob/main/Expansions/docs/expansion-spec.md): extension contract · `Expansions/docs/expansion-spec.md`

## Connections

- Adapter Prompt → Shared Agent Rules: loads
- Shared Agent Rules → Larry Orchestrator: governs
- Larry Orchestrator → Specialist Agents: routes work to
- Specialist Agents → SOPs & Workstreams: follow
- Larry Orchestrator → Task State Files: advances
- Specialist Agents → Session Logs: record sessions
- Team Inbox → PKM Markdown Store: normalized and filed
- Entity Templates → PKM Markdown Store: defines entity shape
- Frontmatter Conventions → PKM Markdown Store: standardizes metadata
- Specialist Agents → Deliverables: produce
- SOPs & Workstreams → Task State Files: guides transitions
- Cockpit Node Server → Cockpit Content APIs: hosts
- Cockpit Node Server → Local PIN Auth: enforces
- React Cockpit UI → Cockpit Node Server: local requests
- Cockpit Content APIs → PKM Markdown Store: reads and edits
- Cockpit Content APIs → SQLite Mirror: queries
- PKM Markdown Store → SQLite Mirror: regenerated into
- Planner UI API → Persisted Planner: uses
- React Cockpit UI → Planner UI API: renders planner
- Persisted Planner → SQLite Mirror: persists locally
- Cockpit Node Server → Provider Connectors: loads
- Expansion Specification → Provider Connectors: governs extension shape
