How eightman999/ourin works
Project Type and Purpose
• This is a macOS‐native desktop application (“Ourin”) written primarily in Swift with mixed C/C++ components.
• It provides a “baseware” runtime for Ukagaka‐style virtual characters (“ghosts”), supporting modules such as balloon rendering, Shiori scripting, plugin hosting, NAR package installation, event dispatch, SSTP/HTTP servers, and an embedded script engine (YAYA Core).
High-Level Architectural Layers
A. UI Layer
• OurinApp, SwiftUI Views (ContentView, AboutView, DevToolsView, GhostView, BalloonView, NarInstallView, etc.)
• Asset catalogs (Assets.xcassets)
B. Application Services Layer
• AnimationEngine, GhostManager, Balloon subsystem (DescriptorLoader, ImageLoader, ICO), HeadlineHost, NarInstaller, LogStore
• Property system (PropertyManager + Provider plugins for System, Ghost, Plugin, Resource)
• ResourceBridge (bridging macOS resources into the app)
C. Protocol / Event Layer
• SHIORIEvents (EventBridge, various Observers)
• SSTP (TCP/HTTP/XPC servers and parsers: SstpTcpServer, SstpHttpServer, SstpRouter, SSTPDispatcher)
• PluginEventDispatcher / PluginHost (PluginRegistry, PluginProtocol)
• WebHandler & WebNarInstaller for the Web API
D. Native Bridge & Embedded Engine Layer
• FMO bridge (FmoBridge.c/h, shared memory, mutex) for inter-process memory exchange
• Ourin-Bridging-Header linking Swift to C/C++
• YayaAdapter + integrated YAYA Core (yaya_core subproject containing Lexer, Parser, VM)
E. Persistence / Utilities Layer
• LogModels, LogStore, ProcessKiller, SyncCenter, Utils/Log
• Unit tests (OurinTests) and UI tests (OurinUITests)
Component Relationships and Data Flow
• UI → Services: UI components invoke Application Services (e.g., GhostManager, Balloon, NarInstall) to render and manage ghosts.
• Services → Protocol/Event: Services publish/subscribe to system events via SHIORIEvents and dispatch user commands.
• Protocol/Event → PluginHost: Incoming SSTP, XPC, HTTP, or plugin events are routed to plugin modules via PluginEventDispatcher.
• Services → FMO & YAYA Core: Some components delegate script execution to YAYA Core or share data with other processes via FMO.
• Persistence: Logs and metrics are stored via LogStore and ServerMetrics.
Architectural Patterns and Design Principles
• Layered architecture separating UI, business logic, protocol interfaces, and native bridges.
• Plugin architecture: dynamic discovery/registry of plugins and property providers.
• Event-driven design: central EventBridge dispatches macOS events (network, power, session) to SHIORI modules.
• Embedded script engine: decouples the core script evaluation (YAYA VM) from the Swift application.
• C/Swift bridging: uses a Bridging-Header to interoperate with C/C++ modules (FMO, YAYA).