# nq-solution/ctbuh architecture

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

- Interactive diagram: https://gitdiagram.com/nq-solution/ctbuh
- Repository: https://github.com/nq-solution/ctbuh

## Overview

#### 목적과 범위
입체도시건축학회(구 CTBUH Korea) 홈페이지 개편 저장소다. 현재 최상위 README의 명시적 1단계 산출물은 프레임워크 없는 HTML/CSS 메인 페이지 시안 5종이며, 별도로 IJHRB 학술지 운영을 위한 OJS·SSO·워크플로우 커스터마이징과 자체 호스팅 CMS(Instatic) 코드베이스를 포함한다. 핵심 진입점은 `mockups/index.html`, `ojs/docker-compose.yml`, `instatic/src/admin/main.tsx`, `instatic/server/index.ts`이다.

#### 디자인 시안 단계
정적 목업은 동일 IA/콘텐츠를 서로 다른 시각 체계로 비교하는 독립 페이지들이다. 브라우저 또는 `python3 -m http.server`로 제공되며, CMS나 OJS 런타임과 직접 결합된 구조는 트리상 확인되지 않는다.
- `mockups/index.html`
- `mockups/a-structural.html`
- `mockups/e-monument.html`

#### Instatic CMS: 관리자와 도메인 모델
`instatic/`은 React 관리자와 Bun/TypeScript 서버를 함께 가진 시각적 사이트 빌더/CMS다. 관리자는 사이트 캔버스, 콘텐츠, 데이터 테이블, 미디어, 플러그인, 사용자 및 AI 기능을 작업공간 단위로 제공한다. 사이트 문서/page-tree, 스타일 규칙, 모듈, 템플릿, visual component가 편집의 중심 데이터 모델이다.
- `instatic/src/admin/AdminEntry.tsx`
- `instatic/src/admin/pages/site/SitePage.tsx`
- `instatic/src/core/page-tree/siteDocument.ts`

#### CMS 서버, 보안, 영속성 경계
HTTP 라우터가 CMS 핸들러를 노출하고, 인증·역할·capability·MFA/step-up 정책이 관리자 및 API 접근을 통제한다. 저장소 계층은 비즈니스 핸들러와 DB 구현을 분리하며 SQLite와 PostgreSQL의 마이그레이션/방언을 지원한다. 미디어는 별도 저장소 어댑터와 업로드 경로를 통해 다뤄진다.
- `instatic/server/http.ts`
- `instatic/server/handlers/cms/index.ts`
- `instatic/server/db/index.ts`
- `instatic/server/auth/authz.ts`

#### 편집에서 공개 발행까지
관리자 변경은 CMS persistence API를 거쳐 사이트 문서·콘텐츠·미디어·데이터 저장소에 저장된다. 발행 계층은 페이지 트리와 모듈을 HTML/CSS/런타임 자산으로 렌더·번들링하고, 정적 산출물·캐시·동적 hole/loop 런타임을 통해 공개 라우터에서 제공한다. 폼 제출은 공개 런타임에서 별도 핸들러와 rate limit/challenge 경계를 가진다.
- `instatic/src/admin/pages/site/hooks/usePersistence.ts`
- `instatic/server/handlers/cms/publish.ts`
- `instatic/server/publish/publishSite.ts`
- `instatic/server/publish/publicRouter.ts`

#### 확장성과 AI 경계
플러그인은 SDK/manifest를 통해 관리자 UI, 모듈, 훅, 스케줄, 미디어 및 서버 기능을 확장하지만, 서버 측 QuickJS worker sandbox와 RPC/capability 경계를 통과해야 한다. AI는 Anthropic, OpenAI 호환, OpenRouter, Ollama 드라이버를 지원하며, 대화·자격증명·감사 로그를 저장하고 도구 호출 및 MCP 커넥터를 capability-gate한다.
- `instatic/server/plugins/runtime.ts`
- `instatic/server/plugins/quickjs/vm.ts`
- `instatic/server/ai/drivers/index.ts`
- `instatic/server/ai/mcp/server.ts`

#### IJHRB OJS와 SSO 운영
`ojs/`는 Docker 기반 PHP OJS 배포 패키지다. IJHRB 테마와 심사/대시보드 정책 플러그인을 OJS 볼륨으로 주입한다. Keycloak realm 정의와 OpenID 플러그인이 OJS 인증 연동을 구성하며, Cloudtype 매니페스트가 OJS와 Keycloak 배포 단위를 나타낸다. 최상위 Playwright E2E는 OJS 탐색·로케일·SSO 및 편집/심사/출판 흐름을 검증한다.
- `ojs/volumes/plugins/generic/ijhrbWorkflow/IjhrbWorkflowPlugin.php`
- `ojs/volumes/plugins/themes/ijhrb/IjhrbThemePlugin.php`
- `keycloak/import/ctbuh-realm.json`
- `.cloudtype/ojs.yaml`

Main entry points: [`ojs/docker-compose.yml`](https://github.com/nq-solution/ctbuh/blob/main/ojs/docker-compose.yml) (OJS deployment), [`instatic/src/admin/pages/site/SitePage.tsx`](https://github.com/nq-solution/ctbuh/blob/main/instatic/src/admin/pages/site/SitePage.tsx) (Site canvas editor), [`instatic/server/http.ts`](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/http.ts) (CMS HTTP router), [`instatic/server/handlers/cms/index.ts`](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/handlers/cms/index.ts) (CMS handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mockups["Design mockups"]
  node_mockup_index["Mockup index<br/>static HTML<br/>[index.html]"]
  node_mockup_structural["Structural direction<br/>static HTML<br/>[a-structural.html]"]
  node_mockup_monument["Monument direction<br/>static HTML<br/>[e-monument.html]"]
end

subgraph group_cms["Instatic CMS"]
  node_admin_entry["CMS admin workspace<br/>React admin<br/>[AdminEntry.tsx]"]
  node_site_editor["Site canvas editor<br/>admin page<br/>[SitePage.tsx]"]
  node_site_document["Site document model<br/>page-tree model<br/>[siteDocument.ts]"]
  node_persistence["Persistence API<br/>admin hook<br/>[usePersistence.ts]"]
  node_http_router["CMS HTTP router<br/>Bun HTTP<br/>[http.ts]"]
  node_cms_handlers["CMS handlers<br/>server handlers<br/>[index.ts]"]
  node_authorization["Access policy<br/>authz<br/>[authz.ts]"]
  node_data_store[("CMS data stores<br/>repository layer<br/>[index.ts]")]
  node_publish_handler["Publish API<br/>CMS handler<br/>[publish.ts]"]
  node_publisher["Static publisher<br/>publish pipeline<br/>[publishSite.ts]"]
  node_public_router["Public site runtime<br/>public router<br/>[publicRouter.ts]"]
  node_plugin_runtime["Plugin runtime<br/>extension host<br/>[runtime.ts]"]
  node_plugin_sandbox["QuickJS sandbox<br/>worker VM<br/>[vm.ts]"]
  node_ai_drivers["AI provider drivers<br/>AI integration<br/>[index.ts]"]
  node_mcp_server["MCP tool gateway<br/>AI capability gate<br/>[server.ts]"]
end

subgraph group_ojs["IJHRB journal platform"]
  node_ojs_deployment["OJS deployment<br/>Docker Compose<br/>[docker-compose.yml]"]
  node_workflow_plugin["Editorial workflow plugin<br/>OJS plugin"]
  node_journal_theme["IJHRB theme<br/>OJS theme"]
  node_keycloak_realm["Keycloak realm<br/>SSO configuration<br/>[ctbuh-realm.json]"]
  node_cloud_deployment["Cloudtype manifest<br/>deployment manifest<br/>[ojs.yaml]"]
end

node_mockup_index -->|"links to"| node_mockup_structural
node_mockup_index -->|"links to"| node_mockup_monument
node_admin_entry -->|"hosts"| node_site_editor
node_site_editor -->|"edits"| node_site_document
node_site_editor -->|"saves through"| node_persistence
node_persistence -->|"calls"| node_http_router
node_http_router -->|"enforces"| node_authorization
node_http_router -->|"routes to"| node_cms_handlers
node_cms_handlers -->|"persists content and media"| node_data_store
node_cms_handlers -->|"publishes via"| node_publish_handler
node_publish_handler -->|"invokes"| node_publisher
node_publisher -->|"reads site data"| node_data_store
node_publisher -->|"produces output for"| node_public_router
node_plugin_runtime -->|"executes in"| node_plugin_sandbox
node_plugin_sandbox -->|"uses capabilities"| node_authorization
node_ai_drivers -->|"enables tool calls through"| node_mcp_server
node_mcp_server -->|"capability-gated by"| node_authorization
node_ojs_deployment -->|"mounts"| node_workflow_plugin
node_ojs_deployment -->|"mounts"| node_journal_theme
node_ojs_deployment -->|"uses OpenID SSO"| node_keycloak_realm
node_cloud_deployment -->|"deploys"| node_ojs_deployment
node_cloud_deployment -->|"deploys"| node_keycloak_realm

click node_mockup_index "https://github.com/nq-solution/ctbuh/blob/main/mockups/index.html"
click node_mockup_structural "https://github.com/nq-solution/ctbuh/blob/main/mockups/a-structural.html"
click node_mockup_monument "https://github.com/nq-solution/ctbuh/blob/main/mockups/e-monument.html"
click node_admin_entry "https://github.com/nq-solution/ctbuh/blob/main/instatic/src/admin/AdminEntry.tsx"
click node_site_editor "https://github.com/nq-solution/ctbuh/blob/main/instatic/src/admin/pages/site/SitePage.tsx"
click node_site_document "https://github.com/nq-solution/ctbuh/blob/main/instatic/src/core/page-tree/siteDocument.ts"
click node_persistence "https://github.com/nq-solution/ctbuh/blob/main/instatic/src/admin/pages/site/hooks/usePersistence.ts"
click node_http_router "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/http.ts"
click node_cms_handlers "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/handlers/cms/index.ts"
click node_authorization "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/auth/authz.ts"
click node_data_store "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/db/index.ts"
click node_publish_handler "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/handlers/cms/publish.ts"
click node_publisher "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/publish/publishSite.ts"
click node_public_router "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/publish/publicRouter.ts"
click node_plugin_runtime "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/plugins/runtime.ts"
click node_plugin_sandbox "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/plugins/quickjs/vm.ts"
click node_ai_drivers "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/ai/drivers/index.ts"
click node_mcp_server "https://github.com/nq-solution/ctbuh/blob/main/instatic/server/ai/mcp/server.ts"
click node_ojs_deployment "https://github.com/nq-solution/ctbuh/blob/main/ojs/docker-compose.yml"
click node_workflow_plugin "https://github.com/nq-solution/ctbuh/blob/main/ojs/volumes/plugins/generic/ijhrbWorkflow/IjhrbWorkflowPlugin.php"
click node_journal_theme "https://github.com/nq-solution/ctbuh/blob/main/ojs/volumes/plugins/themes/ijhrb/IjhrbThemePlugin.php"
click node_keycloak_realm "https://github.com/nq-solution/ctbuh/blob/main/keycloak/import/ctbuh-realm.json"
click node_cloud_deployment "https://github.com/nq-solution/ctbuh/blob/main/.cloudtype/ojs.yaml"

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_mockup_index,node_mockup_structural,node_mockup_monument toneBlue
class node_admin_entry,node_site_editor,node_site_document,node_persistence,node_http_router,node_cms_handlers,node_authorization,node_data_store,node_publish_handler,node_publisher,node_public_router,node_plugin_runtime,node_plugin_sandbox,node_ai_drivers,node_mcp_server toneAmber
class node_ojs_deployment,node_workflow_plugin,node_journal_theme,node_keycloak_realm,node_cloud_deployment toneMint
```

## Components

### Design mockups

Five framework-free homepage visual directions.

- [Mockup index](https://github.com/nq-solution/ctbuh/blob/main/mockups/index.html): static HTML · `mockups/index.html`
- [Structural direction](https://github.com/nq-solution/ctbuh/blob/main/mockups/a-structural.html): static HTML · `mockups/a-structural.html`
- [Monument direction](https://github.com/nq-solution/ctbuh/blob/main/mockups/e-monument.html): static HTML · `mockups/e-monument.html`

### Instatic CMS

Visual site builder with React admin and Bun server.

- [CMS admin workspace](https://github.com/nq-solution/ctbuh/blob/main/instatic/src/admin/AdminEntry.tsx): React admin · Workspace UI for site, content, media, users, plugins, and AI. · `instatic/src/admin/AdminEntry.tsx`
- [Site canvas editor](https://github.com/nq-solution/ctbuh/blob/main/instatic/src/admin/pages/site/SitePage.tsx): admin page · `instatic/src/admin/pages/site/SitePage.tsx`
- [Site document model](https://github.com/nq-solution/ctbuh/blob/main/instatic/src/core/page-tree/siteDocument.ts): page-tree model · Pages, styles, modules, templates, and visual components. · `instatic/src/core/page-tree/siteDocument.ts`
- [Persistence API](https://github.com/nq-solution/ctbuh/blob/main/instatic/src/admin/pages/site/hooks/usePersistence.ts): admin hook · `instatic/src/admin/pages/site/hooks/usePersistence.ts`
- [CMS HTTP router](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/http.ts): Bun HTTP · `instatic/server/http.ts`
- [CMS handlers](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/handlers/cms/index.ts): server handlers · `instatic/server/handlers/cms/index.ts`
- [Access policy](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/auth/authz.ts): authz · Roles, capabilities, MFA, and step-up controls. · `instatic/server/auth/authz.ts`
- [CMS data stores](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/db/index.ts): repository layer · SQLite and PostgreSQL implementations and migrations. · `instatic/server/db/index.ts`
- [Publish API](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/handlers/cms/publish.ts): CMS handler · `instatic/server/handlers/cms/publish.ts`
- [Static publisher](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/publish/publishSite.ts): publish pipeline · Renders and bundles pages into public assets and runtime output. · `instatic/server/publish/publishSite.ts`
- [Public site runtime](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/publish/publicRouter.ts): public router · Serves static output, cache, dynamic holes, loops, and protected forms. · `instatic/server/publish/publicRouter.ts`
- [Plugin runtime](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/plugins/runtime.ts): extension host · Loads SDK and manifest extensions for UI and server capabilities. · `instatic/server/plugins/runtime.ts`
- [QuickJS sandbox](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/plugins/quickjs/vm.ts): worker VM · RPC and capability boundary for server-side plugins. · `instatic/server/plugins/quickjs/vm.ts`
- [AI provider drivers](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/ai/drivers/index.ts): AI integration · Provider abstraction for Anthropic, OpenAI-compatible, OpenRouter, and Ollama. · `instatic/server/ai/drivers/index.ts`
- [MCP tool gateway](https://github.com/nq-solution/ctbuh/blob/main/instatic/server/ai/mcp/server.ts): AI capability gate · `instatic/server/ai/mcp/server.ts`

### IJHRB journal platform

Docker-deployed OJS with SSO and journal customizations.

- [OJS deployment](https://github.com/nq-solution/ctbuh/blob/main/ojs/docker-compose.yml): Docker Compose · PHP OJS runtime with injected journal plugins and theme. · `ojs/docker-compose.yml`
- [Editorial workflow plugin](https://github.com/nq-solution/ctbuh/blob/main/ojs/volumes/plugins/generic/ijhrbWorkflow/IjhrbWorkflowPlugin.php): OJS plugin · Custom review and dashboard policy. · `ojs/volumes/plugins/generic/ijhrbWorkflow/IjhrbWorkflowPlugin.php`
- [IJHRB theme](https://github.com/nq-solution/ctbuh/blob/main/ojs/volumes/plugins/themes/ijhrb/IjhrbThemePlugin.php): OJS theme · `ojs/volumes/plugins/themes/ijhrb/IjhrbThemePlugin.php`
- [Keycloak realm](https://github.com/nq-solution/ctbuh/blob/main/keycloak/import/ctbuh-realm.json): SSO configuration · OpenID identity realm for OJS. · `keycloak/import/ctbuh-realm.json`
- [Cloudtype manifest](https://github.com/nq-solution/ctbuh/blob/main/.cloudtype/ojs.yaml): deployment manifest · Declares OJS and Keycloak deployment units. · `.cloudtype/ojs.yaml`

## Connections

- Mockup index → Structural direction: links to
- Mockup index → Monument direction: links to
- CMS admin workspace → Site canvas editor: hosts
- Site canvas editor → Site document model: edits
- Site canvas editor → Persistence API: saves through
- Persistence API → CMS HTTP router: calls
- CMS HTTP router → Access policy: enforces
- CMS HTTP router → CMS handlers: routes to
- CMS handlers → CMS data stores: persists content and media
- CMS handlers → Publish API: publishes via
- Publish API → Static publisher: invokes
- Static publisher → CMS data stores: reads site data
- Static publisher → Public site runtime: produces output for
- Plugin runtime → QuickJS sandbox: executes in
- QuickJS sandbox → Access policy: uses capabilities
- AI provider drivers → MCP tool gateway: enables tool calls through
- MCP tool gateway → Access policy: capability-gated by
- OJS deployment → Editorial workflow plugin: mounts
- OJS deployment → IJHRB theme: mounts
- OJS deployment → Keycloak realm: uses OpenID SSO
- Cloudtype manifest → OJS deployment: deploys
- Cloudtype manifest → Keycloak realm: deploys
