# arcsin1/oh-my-ppt architecture

> Architecture diagram of the GitHub repository arcsin1/oh-my-ppt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arcsin1/oh-my-ppt
- Repository: https://github.com/arcsin1/oh-my-ppt

## Overview

#### Purpose and Entry Points
Oh My PPT is a local-first Electron desktop application for AI-assisted creation, editing, import, presentation, and export of HTML-backed slide decks. It supports editable PPTX import/export, document-driven generation, AI image generation, templates, styles, animations, and local session assets. Electron bootstraps from `src/main/index.ts`; the React renderer begins at `src/renderer/src/main.tsx` and routes through `src/renderer/src/App.tsx`; the constrained renderer-to-main API is exposed by `src/preload/index.ts`.

#### Desktop Process and IPC Boundary
The main process owns windows, lifecycle, menus/tray, persistent files, model credentials, and privileged operations. The renderer must request those capabilities through IPC rather than accessing local resources directly. IPC composition and runtime session/event contracts live in `src/main/ipc/index.ts`, `src/main/ipc/runtime/event-contract.ts`, and `src/renderer/src/lib/ipc.ts`. This is the principal security and process-isolation boundary.

#### Session-Centered Presentation Domain
A session is the durable unit for a deck, its pages, masters, local assets, metadata, and revisions. Main-process services mutate pages, merge content, manage masters, build page HTML, and save/import sessions; renderer stores project the active session and editing state. Core paths: `src/main/session/page-management-service.ts`, `src/main/session/master-service.ts`, `src/renderer/src/store/sessionDetailStore.ts`. SQLite/Drizzle persistence and schema evolution are centered in `src/main/db/database.ts`, `src/main/db/schema.ts`, and `src/main/db/patch/index.ts`; Git-backed history is implemented by `src/main/history/git-history-service.ts`.

#### HTML Presentation Representation and Editor
Pages are serialized HTML with a presentation contract, design contract, resource policy, fonts, and asset references. This representation is the shared boundary between AI generation, visual editing, preview, export, and persistence. Key implementation paths are `src/main/presentation/html/page-contract.ts`, `src/main/presentation/html/page-writer-core.ts`, and `src/main/presentation/design-contract.ts`. The renderer’s editing workspace and iframe-based preview are anchored by `src/renderer/src/components/session-detail/preview/PreviewStage.tsx`, `src/renderer/src/components/preview/PreviewIframe.tsx`, and `src/renderer/src/pages/session-detail.tsx`.

#### AI Runtime, Planning, and Generation Jobs
AI work is mediated by an agent runtime: model resolution, prompt composition, tool-backed agents, event bus, job coordination, and resource locking. Its public runtime begins at `src/main/agent-runtime/index.ts`; concurrency/control primitives are in `src/main/agent-runtime/job/coordinator.ts` and `src/main/agent-runtime/lock/resource-lock.ts`. Generation converts a user topic, documents, style/template choices, and slide settings into an outline/plan, then runs deck/page flows and finalization: `src/main/generation/deck-flow.ts`, `src/main/generation/agent-runner.ts`, `src/main/generation/finalization.ts`. Conversational “thinking” is a staged planning subsystem in `src/main/thinking/thinking-agent.ts`, `src/main/thinking/stage-manager.ts`, and `src/main/thinking/source-plan.ts`.

#### Model, Image, Style, and Skill Inputs
Text models are provider-configured and include OpenAI-compatible endpoints such as local Ollama; image generation is separately configured and dispatched to provider adapters. Relevant boundaries: `src/main/agent-runtime/model/resolve.ts`, `src/main/agent-runtime/provider/image/index.ts`, and `src/main/agent-runtime/provider/image/providers/openai-chat-completions.ts`. Built-in style packages and agent skills are packaged resources, initialized into runtime catalogs, and shape prompting/design constraints: `resources/styles/manifest.json`, `src/main/styles/style-runtime.ts`, and `src/main/product-skills/initializer.ts`.

#### Import, Export, and Runtime Packaging
I/O converts external documents and PPTX into the session/HTML model, and renders HTML pages to editable PPTX, PDF/PNG, MP4, thumbnails, or portable slide packages. PPTX import is isolated under `src/main/io/pptx-import/index.ts`; HTML-to-PPTX rendering/export under `src/main/io/html-pptx/renderer.ts`; video export under `src/main/io/html-video/exporter.ts`. Browser-side slide behavior and animation resources ship locally in `resources/index-runtime.js`, `resources/ppt-runtime.js`, and `resources/anime.v4.js`. Electron Vite builds the app, while `electron-builder.yml` defines distributable desktop packaging.

Main entry points: [`src/main/ipc/index.ts`](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/ipc/index.ts) (IPC composition), [`src/main/session/page-management-service.ts`](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/session/page-management-service.ts) (Session services), [`src/main/presentation/html/page-contract.ts`](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/presentation/html/page-contract.ts) (HTML page contract), [`src/renderer/src/store/sessionDetailStore.ts`](https://github.com/arcsin1/oh-my-ppt/blob/main/src/renderer/src/store/sessionDetailStore.ts) (Active session store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop boundary"]
  node_main["Electron main<br/>process entry<br/>[index.ts]"]
  node_preload["Preload API<br/>security bridge<br/>[index.ts]"]
  node_ipc{{"IPC composition<br/>IPC boundary<br/>[index.ts]"}}
  node_renderer["React renderer<br/>renderer entry<br/>[main.tsx]"]
  node_app["Application routes<br/>renderer shell<br/>[App.tsx]"]
end

subgraph group_session["Session and presentation"]
  node_session_services["Session services<br/>domain service"]
  node_master_service["Master management<br/>domain service<br/>[master-service.ts]"]
  node_session_store["Active session store<br/>renderer state"]
  node_html_contract["HTML page contract<br/>shared representation<br/>[page-contract.ts]"]
  node_page_writer["Page HTML writer<br/>presentation service"]
  node_preview["Preview workspace<br/>iframe editor<br/>[PreviewStage.tsx]"]
  node_database[("SQLite session database<br/>persistence<br/>[database.ts]")]
  node_history["Git revision history<br/>history service"]
end

subgraph group_ai["AI generation"]
  node_agent_runtime{{"Agent runtime<br/>AI orchestration<br/>[index.ts]"}}
  node_generation["Deck generation flow<br/>generation pipeline<br/>[deck-flow.ts]"]
  node_thinking["Thinking planner<br/>planning subsystem<br/>[thinking-agent.ts]"]
  node_styles["Style runtime<br/>resource catalog<br/>[style-runtime.ts]"]
end

subgraph group_io["Import, export and packaging"]
  node_pptx_import["PPTX import<br/>import adapter<br/>[index.ts]"]
  node_pptx_export["HTML-to-PPTX export<br/>export renderer<br/>[renderer.ts]"]
  node_video_export["Video export<br/>export adapter<br/>[exporter.ts]"]
  node_slide_runtime["Bundled slide runtime<br/>browser runtime<br/>[index-runtime.js]"]
end

node_main -->|"loads"| node_preload
node_preload -->|"invokes"| node_ipc
node_renderer -->|"boots"| node_app
node_app -->|"uses"| node_session_store
node_session_store -->|"requests session operations"| node_ipc
node_ipc -->|"dispatches"| node_session_services
node_session_services -->|"manages"| node_master_service
node_session_services -->|"writes pages"| node_page_writer
node_page_writer -->|"conforms to"| node_html_contract
node_session_services -->|"persists metadata"| node_database
node_session_services -->|"records revisions"| node_history
node_session_store -->|"drives editing"| node_preview
node_preview -->|"edits and previews"| node_html_contract
node_ipc -->|"starts jobs"| node_agent_runtime
node_agent_runtime -->|"runs planning"| node_thinking
node_agent_runtime -->|"coordinates"| node_generation
node_styles -->|"constrains design"| node_generation
node_generation -->|"creates slide HTML"| node_page_writer
node_ipc -->|"dispatches import"| node_pptx_import
node_pptx_import -->|"creates session content"| node_session_services
node_ipc -->|"dispatches export"| node_pptx_export
node_html_contract -->|"renders from"| node_pptx_export
node_html_contract -->|"renders from"| node_video_export
node_preview -->|"loads locally"| node_slide_runtime

click node_main "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/index.ts"
click node_preload "https://github.com/arcsin1/oh-my-ppt/blob/main/src/preload/index.ts"
click node_ipc "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/ipc/index.ts"
click node_renderer "https://github.com/arcsin1/oh-my-ppt/blob/main/src/renderer/src/main.tsx"
click node_app "https://github.com/arcsin1/oh-my-ppt/blob/main/src/renderer/src/App.tsx"
click node_session_services "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/session/page-management-service.ts"
click node_master_service "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/session/master-service.ts"
click node_session_store "https://github.com/arcsin1/oh-my-ppt/blob/main/src/renderer/src/store/sessionDetailStore.ts"
click node_html_contract "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/presentation/html/page-contract.ts"
click node_page_writer "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/presentation/html/page-writer-core.ts"
click node_preview "https://github.com/arcsin1/oh-my-ppt/blob/main/src/renderer/src/components/session-detail/preview/PreviewStage.tsx"
click node_database "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/db/database.ts"
click node_history "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/history/git-history-service.ts"
click node_agent_runtime "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/agent-runtime/index.ts"
click node_generation "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/generation/deck-flow.ts"
click node_thinking "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/thinking/thinking-agent.ts"
click node_styles "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/styles/style-runtime.ts"
click node_pptx_import "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/io/pptx-import/index.ts"
click node_pptx_export "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/io/html-pptx/renderer.ts"
click node_video_export "https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/io/html-video/exporter.ts"
click node_slide_runtime "https://github.com/arcsin1/oh-my-ppt/blob/main/resources/index-runtime.js"

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_main,node_preload,node_ipc,node_renderer,node_app toneBlue
class node_session_services,node_master_service,node_session_store,node_html_contract,node_page_writer,node_preview,node_database,node_history toneAmber
class node_agent_runtime,node_generation,node_thinking,node_styles toneMint
class node_pptx_import,node_pptx_export,node_video_export,node_slide_runtime toneRose
```

## Components

### Desktop boundary

Electron process separation and IPC.

- [Electron main](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/index.ts): process entry · Owns privileged desktop lifecycle and local capabilities. · `src/main/index.ts`
- [Preload API](https://github.com/arcsin1/oh-my-ppt/blob/main/src/preload/index.ts): security bridge · Constrained renderer-to-main API. · `src/preload/index.ts`
- [IPC composition](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/ipc/index.ts): IPC boundary · Registers privileged request handlers and runtime events. · `src/main/ipc/index.ts`
- [React renderer](https://github.com/arcsin1/oh-my-ppt/blob/main/src/renderer/src/main.tsx): renderer entry · `src/renderer/src/main.tsx`
- [Application routes](https://github.com/arcsin1/oh-my-ppt/blob/main/src/renderer/src/App.tsx): renderer shell · `src/renderer/src/App.tsx`

### Session and presentation

Durable deck model and HTML editing representation.

- [Session services](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/session/page-management-service.ts): domain service · Mutates pages, content, assets, masters, and session files. · `src/main/session/page-management-service.ts`
- [Master management](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/session/master-service.ts): domain service · Maintains deck master layouts. · `src/main/session/master-service.ts`
- [Active session store](https://github.com/arcsin1/oh-my-ppt/blob/main/src/renderer/src/store/sessionDetailStore.ts): renderer state · Holds active session and editing state. · `src/renderer/src/store/sessionDetailStore.ts`
- [HTML page contract](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/presentation/html/page-contract.ts): shared representation · Serialized page format shared by generation, editing, preview, export, and persistence. · `src/main/presentation/html/page-contract.ts`
- [Page HTML writer](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/presentation/html/page-writer-core.ts): presentation service · Builds contract-compliant slide HTML. · `src/main/presentation/html/page-writer-core.ts`
- [Preview workspace](https://github.com/arcsin1/oh-my-ppt/blob/main/src/renderer/src/components/session-detail/preview/PreviewStage.tsx): iframe editor · Interactive editing stage and iframe slide preview. · `src/renderer/src/components/session-detail/preview/PreviewStage.tsx`
- [SQLite session database](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/db/database.ts): persistence · Drizzle-backed session metadata and schema storage. · `src/main/db/database.ts`
- [Git revision history](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/history/git-history-service.ts): history service · `src/main/history/git-history-service.ts`

### AI generation

Runtime-managed planning and deck generation.

- [Agent runtime](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/agent-runtime/index.ts): AI orchestration · Resolves models, tools, events, jobs, and resource locks. · `src/main/agent-runtime/index.ts`
- [Deck generation flow](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/generation/deck-flow.ts): generation pipeline · Runs outline, page/deck generation, and finalization. · `src/main/generation/deck-flow.ts`
- [Thinking planner](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/thinking/thinking-agent.ts): planning subsystem · Stages conversational source and slide planning. · `src/main/thinking/thinking-agent.ts`
- [Style runtime](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/styles/style-runtime.ts): resource catalog · Loads packaged styles into generation constraints. · `src/main/styles/style-runtime.ts`

### Import, export and packaging

External format conversion and bundled runtime assets.

- [PPTX import](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/io/pptx-import/index.ts): import adapter · Converts editable PPTX into the session HTML model. · `src/main/io/pptx-import/index.ts`
- [HTML-to-PPTX export](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/io/html-pptx/renderer.ts): export renderer · Renders HTML slides as editable PPTX. · `src/main/io/html-pptx/renderer.ts`
- [Video export](https://github.com/arcsin1/oh-my-ppt/blob/main/src/main/io/html-video/exporter.ts): export adapter · Renders slide output to MP4. · `src/main/io/html-video/exporter.ts`
- [Bundled slide runtime](https://github.com/arcsin1/oh-my-ppt/blob/main/resources/index-runtime.js): browser runtime · Local slide behavior and animation resources. · `resources/index-runtime.js`

## Connections

- Electron main → Preload API: loads
- Preload API → IPC composition: invokes · Renderer requests privileged operations through this boundary.
- React renderer → Application routes: boots
- Application routes → Active session store: uses
- Active session store → IPC composition: requests session operations
- IPC composition → Session services: dispatches
- Session services → Master management: manages
- Session services → Page HTML writer: writes pages
- Page HTML writer → HTML page contract: conforms to
- Session services → SQLite session database: persists metadata
- Session services → Git revision history: records revisions
- Active session store → Preview workspace: drives editing
- Preview workspace → HTML page contract: edits and previews
- IPC composition → Agent runtime: starts jobs
- Agent runtime → Thinking planner: runs planning
- Agent runtime → Deck generation flow: coordinates
- Style runtime → Deck generation flow: constrains design
- Deck generation flow → Page HTML writer: creates slide HTML
- IPC composition → PPTX import: dispatches import
- PPTX import → Session services: creates session content
- IPC composition → HTML-to-PPTX export: dispatches export
- HTML page contract → HTML-to-PPTX export: renders from
- HTML page contract → Video export: renders from
- Preview workspace → Bundled slide runtime: loads locally
