# chiazor-daniel/olac architecture

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

- Interactive diagram: https://gitdiagram.com/chiazor-daniel/olac
- Repository: https://github.com/chiazor-daniel/olac

## Overview

#### Purpose and deployable surfaces
OLAC is a mobile AI executive assistant for conversational calendar, email, contacts, briefings, and voice interaction. Its primary product path is a FastAPI backend plus Expo/React Native client:
- Backend server: `backend/run.py`, `backend/app/main.py`
- Mobile bootstrap: `frontend/index.js`, `frontend/App.js`
- A separate, much broader PocketPaw agent platform is vendored/colocated under `backend/pocketpaw/`, with its own CLI/API surface: `backend/pocketpaw/__main__.py`, `backend/pocketpaw/api/serve.py`.

#### Mobile client and dynamic UI
The Expo client owns authentication, navigation, screen state, and rendering of backend-provided structured UI blocks. App flows center on Home/dashboard, chat, voice, settings, and sign-in:
- Navigation/screens: `frontend/src/navigation/AppNavigator.js`, `frontend/src/screens/ChatScreen.js`, `frontend/src/screens/HomeScreen.js`
- Shared state: `frontend/src/context/AuthContext.js`, `frontend/src/context/ChatContext.js`, `frontend/src/context/VoiceContext.js`
- Dynamic block boundary: `frontend/src/components/DynamicScreen.js`, `frontend/src/components/BlockRegistry.js`, `frontend/src/utils/blockSanitizer.js`

Client requests are centralized in `frontend/src/utils/api.js`. Backend response blocks must remain compatible with the registry and sanitizer; this is the principal API/UI contract.

#### OLAC HTTP, auth, and realtime boundary
FastAPI composes API routers for chat, dashboard, reminders, voice, and realtime. Google OAuth establishes user identity and authorizes Google Workspace access:
- Application/API entry: `backend/app/main.py`, `backend/app/api/chat.py`, `backend/app/api/voice.py`
- OAuth: `backend/app/auth/router.py`, `backend/app/auth/oauth.py`
- WebSocket/realtime delivery: `backend/app/api/realtime.py`, `backend/app/api/voice_ws.py`, `backend/app/realtime/hub.py`

Request handling should enforce security and validation before invoking LLM or external side effects: `backend/app/core/security.py`, `backend/app/core/validation.py`.

#### Assistant orchestration and conversation flow
Chat begins at the chat router, enters an assistant/intent-routing layer, then selects tools or workspace execution. The engine maintains context, commitments, attention, relationships, and formatted responses. It produces natural text plus actions and structured blocks for the mobile renderer:
- LLM orchestration: `backend/app/llm/assistant.py`, `backend/app/llm/intent_router.py`, `backend/app/llm/client.py`
- OLAC domain engine: `backend/app/engine/olac_engine.py`, `backend/app/engine/context_manager.py`, `backend/app/engine/response_formatter.py`
- UI composition: `backend/app/core/screen_composer.py`, `backend/app/core/block_builder.py`

Confirmation boundaries are architecturally important for write actions; preserve the distinction between planning/read-only retrieval and externally visible mutations.

#### Persistence, memory, and productivity services
SQLAlchemy-style models represent users, conversations, commitments, and relationships; services encapsulate provider access and short-lived caching:
- Database/models: `backend/app/db/database.py`, `backend/app/models/conversation.py`, `backend/app/models/commitment.py`
- Conversation and briefing services: `backend/app/services/chat_memory_service.py`, `backend/app/services/briefing_service.py`
- Google-facing services: `backend/app/services/google_client.py`, `backend/app/services/calendar_service.py`, `backend/app/services/gmail_service.py`

Material infrastructure is PostgreSQL or SQLite, optionally Redis, and Google OAuth/API credentials. External AI/media services are Groq-compatible LLM APIs, Whisper STT, Cartesia TTS, and fallback edge TTS: `backend/app/services/cartesia_service.py`, `backend/app/services/voice_service.py`.

#### PocketPaw agent platform
`backend/pocketpaw/` is a second substantial runtime: a multi-provider, multi-agent automation platform with REST APIs, dashboard, messaging channels, tool registry, memory, scheduling, and mission execution. It is not the OLAC FastAPI path, but shared deployment or integration work must treat it as a separate subsystem:
- Agent routing/delegation: `backend/pocketpaw/agents/router.py`, `backend/pocketpaw/agents/delegation.py`, `backend/pocketpaw/agents/model_router.py`
- Provider abstraction: `backend/pocketpaw/llm/router.py`, `backend/pocketpaw/llm/providers/registry.py`
- Tools and MCP: `backend/pocketpaw/tools/registry.py`, `backend/pocketpaw/mcp/manager.py`
- Async/proactive work: `backend/pocketpaw/daemon/executor.py`, `backend/pocketpaw/mission_control/executor.py`

It supports OpenAI-compatible, Anthropic, Gemini, Ollama, and OpenRouter providers; external channels include Slack, Discord, Telegram, WhatsApp, Teams, and webhooks through `backend/pocketpaw/bus/adapters/`.

#### Google Workspace MCP service
`google_workspace_mcp/` is an independently runnable MCP server exposing authenticated Google Workspace tools. It provides a cleaner tool-protocol boundary for Gmail, Calendar, Drive, Docs, Sheets, and related APIs:
- Server entrypoints: `google_workspace_mcp/main.py`, `google_workspace_mcp/fastmcp_server.py`, `google_workspace_mcp/core/server.py`
- OAuth/credential storage: `google_workspace_mcp/auth/google_auth.py`, `google_workspace_mcp/auth/credential_store.py`
- Tool registration and examples: `google_workspace_mcp/core/tool_registry.py`, `google_workspace_mcp/gmail/gmail_tools.py`, `google_workspace_mcp/gcalendar/calendar_tools.py`

It can be containerized and deployed separately, including Kubernetes via `google_workspace_mcp/helm-chart/workspace-mcp/`.

Main entry points: [`backend/app/main.py`](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/main.py) (FastAPI application), [`backend/app/engine/olac_engine.py`](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/engine/olac_engine.py) (OLAC domain engine), [`frontend/src/navigation/AppNavigator.js`](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/src/navigation/AppNavigator.js) (App navigation & screens), [`backend/app/llm/assistant.py`](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/llm/assistant.py) (Assistant & intent routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Expo Mobile Client"]
  node_mobile_bootstrap["Expo app bootstrap<br/>React Native entry<br/>[App.js]"]
  node_mobile_navigation["App navigation &amp; screens<br/>[AppNavigator.js]"]
  node_mobile_state["Auth, chat &amp; voice state<br/>React contexts<br/>[ChatContext.js]"]
  node_mobile_api["API client<br/>HTTP client<br/>[api.js]"]
  node_dynamic_ui["Dynamic block renderer<br/>UI contract<br/>[DynamicScreen.js]"]
end

subgraph group_olac["OLAC Backend"]
  node_olac_api["FastAPI application<br/>HTTP and WebSocket API<br/>[main.py]"]
  node_auth["Google OAuth<br/>identity boundary<br/>[router.py]"]
  node_security["Security &amp; validation<br/>request guard<br/>[security.py]"]
  node_chat_router["Chat router<br/>chat endpoint<br/>[chat.py]"]
  node_assistant["Assistant &amp; intent routing<br/>LLM orchestration<br/>[assistant.py]"]
  node_olac_engine["OLAC domain engine<br/>conversation engine<br/>[olac_engine.py]"]
  node_response_ui["Response &amp; block composer<br/>response composition<br/>[screen_composer.py]"]
  node_confirmation{{"Write confirmation boundary<br/>mutation control<br/>[validation.py]"}}
  node_realtime["Realtime &amp; voice delivery<br/>WebSocket API<br/>[realtime.py]"]
  node_memory_services["Memory &amp; briefing services<br/>application services"]
  node_workspace_services["Google productivity services<br/>provider services<br/>[google_client.py]"]
  node_olac_store[("OLAC database<br/>PostgreSQL or SQLite<br/>[database.py]")]
end

subgraph group_pocketpaw["PocketPaw Platform"]
  node_pocketpaw_api["PocketPaw CLI &amp; API<br/>separate runtime<br/>[serve.py]"]
  node_pocketpaw_agents["Agent routing &amp; delegation<br/>multi-agent orchestration<br/>[router.py]"]
  node_pocketpaw_tools["Tools, MCP &amp; providers<br/>automation integration layer<br/>[registry.py]"]
  node_pocketpaw_async["Daemon &amp; mission execution<br/>async automation<br/>[executor.py]"]
end

subgraph group_workspace["Google Workspace MCP"]
  node_mcp_server["Workspace MCP server<br/>MCP service<br/>[main.py]"]
  node_mcp_auth["Google credentials<br/>OAuth credential store<br/>[google_auth.py]"]
  node_mcp_tools["Workspace tool registry<br/>MCP tools<br/>[tool_registry.py]"]
end

node_ai_voice{{"AI &amp; voice providers<br/>external services<br/>[voice_service.py]"}}
node_google_workspace{{"Google Workspace APIs<br/>external platform"}}

node_mobile_bootstrap -->|"starts"| node_mobile_navigation
node_mobile_navigation -->|"uses state"| node_mobile_state
node_mobile_navigation -->|"requests"| node_mobile_api
node_mobile_api -->|"HTTP"| node_olac_api
node_olac_api -->|"authenticates"| node_auth
node_olac_api -->|"guards"| node_security
node_security -->|"validated chat"| node_chat_router
node_chat_router -->|"conversation input"| node_assistant
node_assistant -->|"intent and execution"| node_olac_engine
node_assistant -->|"model calls"| node_ai_voice
node_olac_engine -->|"loads and stores context"| node_memory_services
node_memory_services -->|"persists"| node_olac_store
node_olac_engine -->|"plans reads/actions"| node_workspace_services
node_workspace_services -->|"write actions"| node_confirmation
node_confirmation -->|"confirmed mutations"| node_google_workspace
node_workspace_services -->|"read access"| node_google_workspace
node_olac_engine -->|"response data"| node_response_ui
node_response_ui -->|"structured blocks"| node_dynamic_ui
node_olac_api -->|"realtime routes"| node_realtime
node_realtime -->|"WebSocket events"| node_mobile_state
node_pocketpaw_api -->|"agent requests"| node_pocketpaw_agents
node_pocketpaw_agents -->|"delegates tools/models"| node_pocketpaw_tools
node_pocketpaw_async -->|"executes missions"| node_pocketpaw_agents
node_pocketpaw_tools -.->|"MCP integration"| node_mcp_server
node_mcp_server -->|"authorizes"| node_mcp_auth
node_mcp_server -->|"registers"| node_mcp_tools
node_mcp_tools -->|"tool calls"| node_google_workspace
node_auth -->|"OAuth consent"| node_google_workspace

click node_mobile_bootstrap "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/App.js"
click node_mobile_navigation "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/src/navigation/AppNavigator.js"
click node_mobile_state "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/src/context/ChatContext.js"
click node_mobile_api "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/src/utils/api.js"
click node_dynamic_ui "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/src/components/DynamicScreen.js"
click node_olac_api "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/main.py"
click node_auth "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/auth/router.py"
click node_security "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/core/security.py"
click node_chat_router "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/api/chat.py"
click node_assistant "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/llm/assistant.py"
click node_olac_engine "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/engine/olac_engine.py"
click node_response_ui "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/core/screen_composer.py"
click node_confirmation "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/core/validation.py"
click node_realtime "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/api/realtime.py"
click node_memory_services "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/services/chat_memory_service.py"
click node_workspace_services "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/services/google_client.py"
click node_olac_store "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/db/database.py"
click node_ai_voice "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/services/voice_service.py"
click node_pocketpaw_api "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/pocketpaw/api/serve.py"
click node_pocketpaw_agents "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/pocketpaw/agents/router.py"
click node_pocketpaw_tools "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/pocketpaw/tools/registry.py"
click node_pocketpaw_async "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/pocketpaw/daemon/executor.py"
click node_mcp_server "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/google_workspace_mcp/main.py"
click node_mcp_auth "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/google_workspace_mcp/auth/google_auth.py"
click node_mcp_tools "https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/google_workspace_mcp/core/tool_registry.py"

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_mobile_bootstrap,node_mobile_navigation,node_mobile_state,node_mobile_api,node_dynamic_ui toneBlue
class node_olac_api,node_auth,node_security,node_chat_router,node_assistant,node_olac_engine,node_response_ui,node_confirmation,node_realtime,node_memory_services,node_workspace_services,node_olac_store toneAmber
class node_pocketpaw_api,node_pocketpaw_agents,node_pocketpaw_tools,node_pocketpaw_async toneMint
class node_mcp_server,node_mcp_auth,node_mcp_tools toneRose
class node_ai_voice,node_google_workspace toneNeutral
```

## Components

### Expo Mobile Client

- [Expo app bootstrap](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/App.js): React Native entry · `frontend/App.js`
- [App navigation & screens](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/src/navigation/AppNavigator.js): navigation · Home, chat, voice, settings, and sign-in flows. · `frontend/src/navigation/AppNavigator.js`
- [Auth, chat & voice state](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/src/context/ChatContext.js): React contexts · `frontend/src/context/ChatContext.js`
- [API client](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/src/utils/api.js): HTTP client · `frontend/src/utils/api.js`
- [Dynamic block renderer](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/frontend/src/components/DynamicScreen.js): UI contract · Sanitizes and renders backend-provided blocks. · `frontend/src/components/DynamicScreen.js`

### OLAC Backend

- [FastAPI application](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/main.py): HTTP and WebSocket API · Composes chat, dashboard, reminders, voice, and realtime routes. · `backend/app/main.py`
- [Google OAuth](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/auth/router.py): identity boundary · Establishes users and Workspace authorization. · `backend/app/auth/router.py`
- [Security & validation](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/core/security.py): request guard · Guards requests before model calls or side effects. · `backend/app/core/security.py`
- [Chat router](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/api/chat.py): chat endpoint · `backend/app/api/chat.py`
- [Assistant & intent routing](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/llm/assistant.py): LLM orchestration · Chooses intent, tools, or Workspace execution. · `backend/app/llm/assistant.py`
- [OLAC domain engine](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/engine/olac_engine.py): conversation engine · Maintains context, commitments, attention, and relationships. · `backend/app/engine/olac_engine.py`
- [Response & block composer](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/core/screen_composer.py): response composition · Produces text, actions, and mobile UI blocks. · `backend/app/core/screen_composer.py`
- [Write confirmation boundary](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/core/validation.py): mutation control · Separates plans and reads from externally visible writes. · `backend/app/core/validation.py`
- [Realtime & voice delivery](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/api/realtime.py): WebSocket API · `backend/app/api/realtime.py`
- [Memory & briefing services](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/services/chat_memory_service.py): application services · `backend/app/services/chat_memory_service.py`
- [Google productivity services](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/services/google_client.py): provider services · Calendar and Gmail access for OLAC actions. · `backend/app/services/google_client.py`
- [OLAC database](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/db/database.py): PostgreSQL or SQLite · Users, conversations, commitments, and relationships. · `backend/app/db/database.py`

### PocketPaw Platform

Separate agent-platform runtime.

- [PocketPaw CLI & API](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/pocketpaw/api/serve.py): separate runtime · Broad automation platform API surface. · `backend/pocketpaw/api/serve.py`
- [Agent routing & delegation](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/pocketpaw/agents/router.py): multi-agent orchestration · `backend/pocketpaw/agents/router.py`
- [Tools, MCP & providers](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/pocketpaw/tools/registry.py): automation integration layer · Routes multi-provider models and registered tools. · `backend/pocketpaw/tools/registry.py`
- [Daemon & mission execution](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/pocketpaw/daemon/executor.py): async automation · Runs proactive and scheduled work. · `backend/pocketpaw/daemon/executor.py`

### Google Workspace MCP

Independently deployable MCP server.

- [Workspace MCP server](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/google_workspace_mcp/main.py): MCP service · Authenticated Google Workspace tool protocol endpoint. · `google_workspace_mcp/main.py`
- [Google credentials](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/google_workspace_mcp/auth/google_auth.py): OAuth credential store · `google_workspace_mcp/auth/google_auth.py`
- [Workspace tool registry](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/google_workspace_mcp/core/tool_registry.py): MCP tools · Gmail, Calendar, Drive, Docs, and Sheets tools. · `google_workspace_mcp/core/tool_registry.py`

### Other components

- [AI & voice providers](https://github.com/chiazor-daniel/olac/blob/ui/ux-polish-pass/backend/app/services/voice_service.py): external services · Groq-compatible LLM, Whisper STT, Cartesia TTS, and edge TTS. · `backend/app/services/voice_service.py`
- **Google Workspace APIs**: external platform

## Connections

- Expo app bootstrap → App navigation & screens: starts
- App navigation & screens → Auth, chat & voice state: uses state
- App navigation & screens → API client: requests
- API client → FastAPI application: HTTP
- FastAPI application → Google OAuth: authenticates
- FastAPI application → Security & validation: guards
- Security & validation → Chat router: validated chat
- Chat router → Assistant & intent routing: conversation input
- Assistant & intent routing → OLAC domain engine: intent and execution
- Assistant & intent routing → AI & voice providers: model calls
- OLAC domain engine → Memory & briefing services: loads and stores context
- Memory & briefing services → OLAC database: persists
- OLAC domain engine → Google productivity services: plans reads/actions
- Google productivity services → Write confirmation boundary: write actions
- Write confirmation boundary → Google Workspace APIs: confirmed mutations
- Google productivity services → Google Workspace APIs: read access
- OLAC domain engine → Response & block composer: response data
- Response & block composer → Dynamic block renderer: structured blocks · Principal backend/mobile UI contract.
- FastAPI application → Realtime & voice delivery: realtime routes
- Realtime & voice delivery → Auth, chat & voice state: WebSocket events
- PocketPaw CLI & API → Agent routing & delegation: agent requests
- Agent routing & delegation → Tools, MCP & providers: delegates tools/models
- Daemon & mission execution → Agent routing & delegation: executes missions
- Tools, MCP & providers → Workspace MCP server: MCP integration
- Workspace MCP server → Google credentials: authorizes
- Workspace MCP server → Workspace tool registry: registers
- Workspace tool registry → Google Workspace APIs: tool calls
- Google OAuth → Google Workspace APIs: OAuth consent
