Architecture

The P31 stack is a sovereign, local-first AI infrastructure for neurodivergent families.

High-Level Overview

┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ p31 CLI │────▶│ p31-router │────▶│ DeepSeek │
│ (TUI) │ │ :4001 │ │ (OpenAI │
│ MCP agent │ │ (proxy) │ │ compatible) │
└──────────────┘ └──────────────┘ └──────────────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ phos-forge │ │ google- │
│ (MCP stdio) │ │ workspace │
│ 26 tools │ │ (MCP stdio) │
└──────────────┘ └──────────────┘

Components

p31 CLI (Go)

p31-router (Python)

PHOS Forge MCP (Node.js)

Google Workspace MCP (Node.js)

Data Flow

  1. User types a message in p31 chat
  2. Go CLI sends OpenAI-format request to localhost:4001/v1
  3. Router proxy forwards to DeepSeek (or falls back)
  4. If the AI requests a tool, the CLI executes the tool via MCP stdio
  5. Tool results are fed back to the AI for a final answer
  6. Response is displayed in the TUI

Security