# jinjutroy/paos architecture

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

- Interactive diagram: https://gitdiagram.com/jinjutroy/paos
- Repository: https://github.com/jinjutroy/paos

## Overview

#### Purpose and Runtime Shape
PAOS is a local-first TypeScript/Node 24 personal operating system. OpenClaw owns conversational orchestration and invokes PAOS through MCP; PAOS owns durable workflows, local state, APIs, and adapters. Primary executable entry points are the HTTP API, stdio MCP server, and scheduled-job worker: `apps/api/src/index.ts`, `apps/mcp/src/index.ts`, `apps/worker/src/index.ts`.

#### Edge Adapters and Control Boundaries
The API server exposes domain workflows over HTTP, while the MCP process maps OpenClaw/client tool calls into the same service layer. The worker independently consumes scheduled jobs; it is not an HTTP/MCP execution path. Adapter wiring is concentrated in `apps/api/src/server.ts`, `apps/mcp/src/tools.ts`, and `apps/worker/src/worker.ts`. OpenClaw registration/configuration lives outside application code in `openclaw/mcp-server.paos.json` and `openclaw/openclaw.paos.example.json5`.

#### Shared Platform Layer
Cross-cutting packages define configuration, redacted structured logging, domain errors, database access/migrations, and queue abstractions. This isolates modules from process environment and infrastructure implementation: `packages/config/src/index.ts`, `packages/logging/src/index.ts`, `packages/core/src/errors.ts`, `packages/db/src/client.ts`, `packages/db/src/migrations.ts`.

#### Durable Storage and Async Execution
PostgreSQL is the default durable repository backend for todos, projects, and calendar state; schema evolution is explicit in `packages/db/migrations/001_initial.sql` through `packages/db/migrations/004_google_calendar_writes.sql`. Redis is the default queue backend, supporting scheduled jobs, leases, retries, and dead-letter state; memory implementations provide short-lived/test alternatives. Key boundaries are `packages/queue/src/redis-queue.ts`, `packages/queue/src/memory-queue.ts`, and `apps/worker/src/queue-worker.ts`. Docker Compose provides PostgreSQL, Redis, and PAOS services: `docker-compose.yml`.

#### Personal Workflow Modules
Domain modules expose domain/service interfaces while selectively supply PostgreSQL runtime repositories:
- Todos and projects provide the core actionable-work records: `packages/modules/todos/src/service.ts`, `packages/modules/todos/src/postgres-repository.ts`, `packages/modules/projects/src/service.ts`, `packages/modules/projects/src/postgres-repository.ts`.
- Reminders schedule work through the queue: `packages/modules/reminders/src/service.ts`.
- Filesystem memory confines Markdown data to a configured root; journal and planning build personal notes and daily-plan workflows on that local boundary: `packages/filesystem-memory/src/store.ts`, `packages/modules/journal/src/service.ts`, `packages/modules/planning/src/service.ts`.

#### Planning and Calendar Flow
Planning reads project/todo work and daily-plan inputs to generate plans, calendar block proposals, and read-only adaptive intelligence such as capacity, workload, schedules, and conflicts. Its calendar handoff is proposal-oriented: `packages/modules/planning/src/intelligence.ts`, `packages/modules/planning/src/plan-calendar.ts`, `packages/modules/calendar/src/service.ts`. Calendar maintains a local event cache, normalizes/imports provider events, and supports agenda/free-time operations via `packages/modules/calendar/src/postgres-repository.ts` and `packages/modules/calendar/src/google-sync.ts`.

#### External-Action Safety Boundary
Google Calendar writes are deliberately split from external execution. PAOS prepares approval-gated write proposals and persists write records only after explicit confirmation plus a trusted connector result; it does not embed provider execution. This boundary is implemented in `packages/modules/calendar/src/google-write.ts` and `packages/modules/calendar/src/google-write-repository.ts`. Google Calendar, OpenClaw, and allowlisted Telegram are material external integrations; the verified deployment remains local-stack/live-owner verified rather than production-ready.

Main entry points: [`apps/api/src/server.ts`](https://github.com/jinjutroy/paos/blob/master/apps/api/src/server.ts) (Adapter wiring), [`packages/modules/planning/src/service.ts`](https://github.com/jinjutroy/paos/blob/master/packages/modules/planning/src/service.ts) (Journal and planning), [`packages/db/src/client.ts`](https://github.com/jinjutroy/paos/blob/master/packages/db/src/client.ts) (PostgreSQL), [`packages/modules/calendar/src/service.ts`](https://github.com/jinjutroy/paos/blob/master/packages/modules/calendar/src/service.ts) (Calendar)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["Process adapters"]
  node_api["HTTP API<br/>Node entry point<br/>[index.ts]"]
  node_mcp["stdio MCP server<br/>Node entry point<br/>[index.ts]"]
  node_worker["Scheduled-job worker<br/>Node entry point<br/>[index.ts]"]
  node_adapter_wiring["Adapter wiring<br/>server and tools<br/>[server.ts]"]
  node_queue_consumer["Queue consumer<br/>worker loop<br/>[queue-worker.ts]"]
end

subgraph group_platform["Platform"]
  node_config_logging_errors["Runtime foundations<br/>config, logging, errors<br/>[index.ts]"]
  node_postgres[("PostgreSQL<br/>durable repository<br/>[client.ts]")]
  node_migrations["Database migrations<br/>schema evolution<br/>[migrations.ts]"]
  node_redis_queue["Redis queue<br/>async backend<br/>[redis-queue.ts]"]
  node_local_stack["Local stack<br/>Docker Compose<br/>[docker-compose.yml]"]
end

subgraph group_workflows["Personal workflows"]
  node_work_records["Todos and projects<br/>domain services<br/>[service.ts]"]
  node_reminders["Reminders<br/>domain service<br/>[service.ts]"]
  node_filesystem_memory["Filesystem memory<br/>Markdown store<br/>[store.ts]"]
  node_journal_planning["Journal and planning<br/>workflow services<br/>[service.ts]"]
  node_planning_intelligence["Planning intelligence<br/>read-only analysis<br/>[intelligence.ts]"]
  node_calendar["Calendar<br/>domain service<br/>[service.ts]"]
  node_calendar_cache_sync["Calendar cache and sync<br/>PostgreSQL and import<br/>[google-sync.ts]"]
end

subgraph group_integrations["External integrations"]
  node_openclaw{{"OpenClaw<br/>conversation orchestrator"}}
  node_openclaw_config["OpenClaw registration<br/>MCP config"]
  node_approval_writes["Approval-gated writes<br/>write proposal boundary<br/>[google-write.ts]"]
  node_google_calendar{{"Google Calendar<br/>external provider"}}
end

node_openclaw_config -->|"registers PAOS MCP"| node_openclaw
node_openclaw -->|"tool calls"| node_mcp
node_api -->|"HTTP requests"| node_adapter_wiring
node_mcp -->|"MCP tools"| node_adapter_wiring
node_adapter_wiring -->|"invokes"| node_work_records
node_adapter_wiring -->|"invokes"| node_reminders
node_adapter_wiring -->|"invokes"| node_journal_planning
node_worker -->|"runs"| node_queue_consumer
node_queue_consumer -->|"consumes jobs"| node_redis_queue
node_reminders -->|"schedules jobs"| node_redis_queue
node_work_records -->|"persists"| node_postgres
node_journal_planning -->|"reads work"| node_work_records
node_journal_planning -->|"reads daily inputs"| node_filesystem_memory
node_journal_planning -->|"uses"| node_planning_intelligence
node_journal_planning -->|"submits proposals"| node_calendar
node_calendar -->|"uses"| node_calendar_cache_sync
node_calendar_cache_sync -->|"caches events"| node_postgres
node_calendar_cache_sync -->|"imports events"| node_google_calendar
node_calendar -->|"prepares confirmed writes"| node_approval_writes
node_approval_writes -.->|"trusted connector result"| node_google_calendar
node_migrations -->|"evolves schema"| node_postgres
node_local_stack -->|"runs"| node_postgres
node_local_stack -->|"runs"| node_redis_queue
node_config_logging_errors -.->|"cross-cutting support"| node_adapter_wiring

click node_openclaw_config "https://github.com/jinjutroy/paos/blob/master/openclaw/mcp-server.paos.json"
click node_api "https://github.com/jinjutroy/paos/blob/master/apps/api/src/index.ts"
click node_mcp "https://github.com/jinjutroy/paos/blob/master/apps/mcp/src/index.ts"
click node_worker "https://github.com/jinjutroy/paos/blob/master/apps/worker/src/index.ts"
click node_adapter_wiring "https://github.com/jinjutroy/paos/blob/master/apps/api/src/server.ts"
click node_config_logging_errors "https://github.com/jinjutroy/paos/blob/master/packages/config/src/index.ts"
click node_postgres "https://github.com/jinjutroy/paos/blob/master/packages/db/src/client.ts"
click node_migrations "https://github.com/jinjutroy/paos/blob/master/packages/db/src/migrations.ts"
click node_redis_queue "https://github.com/jinjutroy/paos/blob/master/packages/queue/src/redis-queue.ts"
click node_queue_consumer "https://github.com/jinjutroy/paos/blob/master/apps/worker/src/queue-worker.ts"
click node_work_records "https://github.com/jinjutroy/paos/blob/master/packages/modules/todos/src/service.ts"
click node_reminders "https://github.com/jinjutroy/paos/blob/master/packages/modules/reminders/src/service.ts"
click node_filesystem_memory "https://github.com/jinjutroy/paos/blob/master/packages/filesystem-memory/src/store.ts"
click node_journal_planning "https://github.com/jinjutroy/paos/blob/master/packages/modules/planning/src/service.ts"
click node_planning_intelligence "https://github.com/jinjutroy/paos/blob/master/packages/modules/planning/src/intelligence.ts"
click node_calendar "https://github.com/jinjutroy/paos/blob/master/packages/modules/calendar/src/service.ts"
click node_calendar_cache_sync "https://github.com/jinjutroy/paos/blob/master/packages/modules/calendar/src/google-sync.ts"
click node_approval_writes "https://github.com/jinjutroy/paos/blob/master/packages/modules/calendar/src/google-write.ts"
click node_local_stack "https://github.com/jinjutroy/paos/blob/master/docker-compose.yml"

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_api,node_mcp,node_worker,node_adapter_wiring,node_queue_consumer toneBlue
class node_config_logging_errors,node_postgres,node_migrations,node_redis_queue,node_local_stack toneAmber
class node_work_records,node_reminders,node_filesystem_memory,node_journal_planning,node_planning_intelligence,node_calendar,node_calendar_cache_sync toneMint
class node_openclaw,node_openclaw_config,node_approval_writes,node_google_calendar toneRose
```

## Components

### Process adapters

Independent HTTP, MCP, and worker runtimes.

- [HTTP API](https://github.com/jinjutroy/paos/blob/master/apps/api/src/index.ts): Node entry point · `apps/api/src/index.ts`
- [stdio MCP server](https://github.com/jinjutroy/paos/blob/master/apps/mcp/src/index.ts): Node entry point · `apps/mcp/src/index.ts`
- [Scheduled-job worker](https://github.com/jinjutroy/paos/blob/master/apps/worker/src/index.ts): Node entry point · Consumes queue jobs independently of request adapters. · `apps/worker/src/index.ts`
- [Adapter wiring](https://github.com/jinjutroy/paos/blob/master/apps/api/src/server.ts): server and tools · Maps HTTP and MCP calls to shared services. · `apps/api/src/server.ts`
- [Queue consumer](https://github.com/jinjutroy/paos/blob/master/apps/worker/src/queue-worker.ts): worker loop · `apps/worker/src/queue-worker.ts`

### Platform

Shared infrastructure boundaries.

- [Runtime foundations](https://github.com/jinjutroy/paos/blob/master/packages/config/src/index.ts): config, logging, errors · Environment isolation, redacted logs, and domain errors. · `packages/config/src/index.ts`
- [PostgreSQL](https://github.com/jinjutroy/paos/blob/master/packages/db/src/client.ts): durable repository · Default state for work records and calendar cache. · `packages/db/src/client.ts`
- [Database migrations](https://github.com/jinjutroy/paos/blob/master/packages/db/src/migrations.ts): schema evolution · Explicit schema changes through Google Calendar writes. · `packages/db/src/migrations.ts`
- [Redis queue](https://github.com/jinjutroy/paos/blob/master/packages/queue/src/redis-queue.ts): async backend · Schedules jobs with leases, retries, and dead-letter state. · `packages/queue/src/redis-queue.ts`
- [Local stack](https://github.com/jinjutroy/paos/blob/master/docker-compose.yml): Docker Compose · Runs PostgreSQL, Redis, and PAOS services. · `docker-compose.yml`

### Personal workflows

Durable domain services and planning.

- [Todos and projects](https://github.com/jinjutroy/paos/blob/master/packages/modules/todos/src/service.ts): domain services · Core actionable-work records. · `packages/modules/todos/src/service.ts`
- [Reminders](https://github.com/jinjutroy/paos/blob/master/packages/modules/reminders/src/service.ts): domain service · Schedules reminder work through the queue. · `packages/modules/reminders/src/service.ts`
- [Filesystem memory](https://github.com/jinjutroy/paos/blob/master/packages/filesystem-memory/src/store.ts): Markdown store · Confines local notes to a configured root. · `packages/filesystem-memory/src/store.ts`
- [Journal and planning](https://github.com/jinjutroy/paos/blob/master/packages/modules/planning/src/service.ts): workflow services · Builds notes, daily plans, and calendar proposals. · `packages/modules/planning/src/service.ts`
- [Planning intelligence](https://github.com/jinjutroy/paos/blob/master/packages/modules/planning/src/intelligence.ts): read-only analysis · Computes capacity, workload, schedules, and conflicts. · `packages/modules/planning/src/intelligence.ts`
- [Calendar](https://github.com/jinjutroy/paos/blob/master/packages/modules/calendar/src/service.ts): domain service · Agenda and free-time operations over local event state. · `packages/modules/calendar/src/service.ts`
- [Calendar cache and sync](https://github.com/jinjutroy/paos/blob/master/packages/modules/calendar/src/google-sync.ts): PostgreSQL and import · Normalizes and imports provider events into local state. · `packages/modules/calendar/src/google-sync.ts`

### External integrations

Approval and provider boundaries.

- **OpenClaw**: conversation orchestrator · Invokes PAOS tools through MCP.
- [OpenClaw registration](https://github.com/jinjutroy/paos/blob/master/openclaw/mcp-server.paos.json): MCP config · Registers the PAOS MCP server outside application code. · `openclaw/mcp-server.paos.json`
- [Approval-gated writes](https://github.com/jinjutroy/paos/blob/master/packages/modules/calendar/src/google-write.ts): write proposal boundary · Persists writes only after explicit confirmation and trusted results. · `packages/modules/calendar/src/google-write.ts`
- **Google Calendar**: external provider

## Connections

- OpenClaw registration → OpenClaw: registers PAOS MCP
- OpenClaw → stdio MCP server: tool calls
- HTTP API → Adapter wiring: HTTP requests
- stdio MCP server → Adapter wiring: MCP tools
- Adapter wiring → Todos and projects: invokes
- Adapter wiring → Reminders: invokes
- Adapter wiring → Journal and planning: invokes
- Scheduled-job worker → Queue consumer: runs
- Queue consumer → Redis queue: consumes jobs
- Reminders → Redis queue: schedules jobs
- Todos and projects → PostgreSQL: persists
- Journal and planning → Todos and projects: reads work
- Journal and planning → Filesystem memory: reads daily inputs
- Journal and planning → Planning intelligence: uses
- Journal and planning → Calendar: submits proposals
- Calendar → Calendar cache and sync: uses
- Calendar cache and sync → PostgreSQL: caches events
- Calendar cache and sync → Google Calendar: imports events
- Calendar → Approval-gated writes: prepares confirmed writes
- Approval-gated writes → Google Calendar: trusted connector result
- Database migrations → PostgreSQL: evolves schema
- Local stack → PostgreSQL: runs
- Local stack → Redis queue: runs
- Runtime foundations → Adapter wiring: cross-cutting support
