# loop0loop/luie architecture

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

- Interactive diagram: https://gitdiagram.com/loop0loop/luie
- Repository: https://github.com/loop0loop/luie

## Overview

Luie is an Electron desktop workspace for long-form fiction: writers manage manuscripts and world-building materials within a project, protect work with autosave and recovery, then preview and export it. The graph highlights documented product capabilities and sampled implementation links. Several renderer-to-main and unsampled subsystem connections are not shown because the excerpts do not establish their wiring.

Main entry points: [`src/renderer/src/app/App.tsx`](https://github.com/loop0loop/luie/blob/main/src/renderer/src/app/App.tsx) (Workspace UI), [`src/main/handler/core/ipcRegistrar.ts`](https://github.com/loop0loop/luie/blob/main/src/main/handler/core/ipcRegistrar.ts) (IPC Registrar), [`src/main/utility/rag/ragQaWorker.ts`](https://github.com/loop0loop/luie/blob/main/src/main/utility/rag/ragQaWorker.ts) (RAG QA Worker), [`src/main/services/core/project/projectExportEngine.ts`](https://github.com/loop0loop/luie/blob/main/src/main/services/core/project/projectExportEngine.ts) (Project Export)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Writing Workspace"]
  node_renderer["Workspace UI<br/>[App.tsx]"]
end

subgraph group_boundary["Application Boundary"]
  node_preload["IPC Preload<br/>[index.ts]"]
  node_registrar["IPC Registrar<br/>[ipcRegistrar.ts]"]
  node_project_handlers["Project Handlers"]
  node_world_handlers["World Handlers"]
end

subgraph group_project["Project Operations"]
  node_manuscript["Manuscript Services"]
  node_world["World Management"]
  node_exporter["Project Export"]
  node_package_writer["Luie Container"]
  node_sync["Project Sync"]
  node_plugins["Graph Plugins"]
end

subgraph group_assist["Search and AI"]
  node_search["Search Services"]
  node_rag_handler["RAG IPC Handler"]
  node_rag_worker["RAG QA Worker<br/>[ragQaWorker.ts]"]
  node_rag_context["Context Assembly"]
  node_memory_query["Narrative Memory"]
  node_llm_runtime["Model Runtime"]
end

subgraph group_storage["Persistence and Recovery"]
  node_autosave["Autosave"]
  node_snapshots["Snapshot Recovery"]
  node_database[("SQLite Database<br/>[databaseService.ts]")]
  node_schema["Database Schema<br/>[index.ts]"]
end

node_writer(("Writer"))

node_writer -->|"writes and organizes"| node_renderer
node_preload -.->|"bridges IPC"| node_registrar
node_registrar -.->|"registers handlers"| node_project_handlers
node_registrar -.->|"registers handlers"| node_world_handlers
node_project_handlers -.->|"handles writing"| node_manuscript
node_world_handlers -.->|"handles world data"| node_world
node_renderer -.->|"autosaves work"| node_autosave
node_autosave -.->|"supports recovery"| node_snapshots
node_renderer -.->|"restores snapshots"| node_snapshots
node_database -->|"uses schema"| node_schema
node_exporter -->|"writes package"| node_package_writer
node_exporter -.->|"includes canonical memory"| node_memory_query
node_renderer -.->|"previews and exports"| node_exporter
node_rag_handler -->|"registers with"| node_registrar
node_rag_worker -->|"assembles context"| node_rag_context
node_rag_worker -->|"resolves runtime"| node_llm_runtime
node_rag_worker -.->|"uses narrative memory"| node_memory_query
node_renderer -.->|"syncs projects"| node_sync
node_renderer -.->|"manages plugins"| node_plugins

click node_renderer "https://github.com/loop0loop/luie/blob/main/src/renderer/src/app/App.tsx"
click node_preload "https://github.com/loop0loop/luie/blob/main/src/preload/index.ts"
click node_registrar "https://github.com/loop0loop/luie/blob/main/src/main/handler/core/ipcRegistrar.ts"
click node_project_handlers "https://github.com/loop0loop/luie/tree/main/src/main/handler/project"
click node_world_handlers "https://github.com/loop0loop/luie/tree/main/src/main/handler/world"
click node_manuscript "https://github.com/loop0loop/luie/tree/main/src/main/services/features/manuscript"
click node_world "https://github.com/loop0loop/luie/tree/main/src/main/domains/world"
click node_exporter "https://github.com/loop0loop/luie/blob/main/src/main/services/core/project/projectExportEngine.ts"
click node_package_writer "https://github.com/loop0loop/luie/tree/main/src/main/services/io"
click node_autosave "https://github.com/loop0loop/luie/tree/main/src/main/manager/autoSave"
click node_snapshots "https://github.com/loop0loop/luie/tree/main/src/main/services/features/snapshot"
click node_database "https://github.com/loop0loop/luie/blob/main/src/main/database/main/databaseService.ts"
click node_schema "https://github.com/loop0loop/luie/blob/main/src/main/database/schema/index.ts"
click node_search "https://github.com/loop0loop/luie/tree/main/src/main/services/features/search"
click node_rag_handler "https://github.com/loop0loop/luie/blob/main/src/main/handler/analysis/ipcRagQaHandlers.ts"
click node_rag_worker "https://github.com/loop0loop/luie/blob/main/src/main/utility/rag/ragQaWorker.ts"
click node_rag_context "https://github.com/loop0loop/luie/blob/main/src/main/services/features/rag/contextAssembler.ts"
click node_memory_query "https://github.com/loop0loop/luie/blob/main/src/main/services/features/memory/query/narrativeMemoryQueryService.ts"
click node_llm_runtime "https://github.com/loop0loop/luie/blob/main/src/main/utility/llm/runtimeMaterializer.ts"
click node_sync "https://github.com/loop0loop/luie/tree/main/src/main/services/features/sync"
click node_plugins "https://github.com/loop0loop/luie/tree/main/src/main/services/features/graphPlugin"

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_renderer toneBlue
class node_preload,node_registrar,node_project_handlers,node_world_handlers toneAmber
class node_manuscript,node_world,node_exporter,node_package_writer,node_sync,node_plugins toneMint
class node_search,node_rag_handler,node_rag_worker,node_rag_context,node_memory_query,node_llm_runtime toneRose
class node_autosave,node_snapshots,node_database,node_schema,node_writer toneIndigo
```

## Components

### Writing Workspace

- [Workspace UI](https://github.com/loop0loop/luie/blob/main/src/renderer/src/app/App.tsx): `src/renderer/src/app/App.tsx`

### Application Boundary

- [IPC Preload](https://github.com/loop0loop/luie/blob/main/src/preload/index.ts): `src/preload/index.ts`
- [IPC Registrar](https://github.com/loop0loop/luie/blob/main/src/main/handler/core/ipcRegistrar.ts): `src/main/handler/core/ipcRegistrar.ts`
- [Project Handlers](https://github.com/loop0loop/luie/tree/main/src/main/handler/project): `src/main/handler/project`
- [World Handlers](https://github.com/loop0loop/luie/tree/main/src/main/handler/world): `src/main/handler/world`

### Project Operations

- [Manuscript Services](https://github.com/loop0loop/luie/tree/main/src/main/services/features/manuscript): `src/main/services/features/manuscript`
- [World Management](https://github.com/loop0loop/luie/tree/main/src/main/domains/world): `src/main/domains/world`
- [Project Export](https://github.com/loop0loop/luie/blob/main/src/main/services/core/project/projectExportEngine.ts): `src/main/services/core/project/projectExportEngine.ts`
- [Luie Container](https://github.com/loop0loop/luie/tree/main/src/main/services/io): `src/main/services/io`
- [Project Sync](https://github.com/loop0loop/luie/tree/main/src/main/services/features/sync): `src/main/services/features/sync`
- [Graph Plugins](https://github.com/loop0loop/luie/tree/main/src/main/services/features/graphPlugin): `src/main/services/features/graphPlugin`

### Search and AI

- [Search Services](https://github.com/loop0loop/luie/tree/main/src/main/services/features/search): `src/main/services/features/search`
- [RAG IPC Handler](https://github.com/loop0loop/luie/blob/main/src/main/handler/analysis/ipcRagQaHandlers.ts): `src/main/handler/analysis/ipcRagQaHandlers.ts`
- [RAG QA Worker](https://github.com/loop0loop/luie/blob/main/src/main/utility/rag/ragQaWorker.ts): `src/main/utility/rag/ragQaWorker.ts`
- [Context Assembly](https://github.com/loop0loop/luie/blob/main/src/main/services/features/rag/contextAssembler.ts): `src/main/services/features/rag/contextAssembler.ts`
- [Narrative Memory](https://github.com/loop0loop/luie/blob/main/src/main/services/features/memory/query/narrativeMemoryQueryService.ts): `src/main/services/features/memory/query/narrativeMemoryQueryService.ts`
- [Model Runtime](https://github.com/loop0loop/luie/blob/main/src/main/utility/llm/runtimeMaterializer.ts): `src/main/utility/llm/runtimeMaterializer.ts`

### Persistence and Recovery

- [Autosave](https://github.com/loop0loop/luie/tree/main/src/main/manager/autoSave): `src/main/manager/autoSave`
- [Snapshot Recovery](https://github.com/loop0loop/luie/tree/main/src/main/services/features/snapshot): `src/main/services/features/snapshot`
- [SQLite Database](https://github.com/loop0loop/luie/blob/main/src/main/database/main/databaseService.ts): `src/main/database/main/databaseService.ts`
- [Database Schema](https://github.com/loop0loop/luie/blob/main/src/main/database/schema/index.ts): `src/main/database/schema/index.ts`

### Other components

- **Writer**

## Connections

- Writer → Workspace UI: writes and organizes (evidence: `README.md`)
- IPC Preload → IPC Registrar: bridges IPC
- IPC Registrar → Project Handlers: registers handlers
- IPC Registrar → World Handlers: registers handlers (evidence: `src/main/handler/world/ipcWorldStorageHandlers.ts`)
- Project Handlers → Manuscript Services: handles writing
- World Handlers → World Management: handles world data
- Workspace UI → Autosave: autosaves work
- Autosave → Snapshot Recovery: supports recovery (evidence: `README.md`)
- Workspace UI → Snapshot Recovery: restores snapshots (evidence: `README.md`)
- SQLite Database → Database Schema: uses schema (evidence: `src/main/database/main/databaseService.ts`)
- Project Export → Luie Container: writes package (evidence: `src/main/services/core/project/projectExportEngine.ts`)
- Project Export → Narrative Memory: includes canonical memory
- Workspace UI → Project Export: previews and exports (evidence: `README.md`)
- RAG IPC Handler → IPC Registrar: registers with (evidence: `src/main/handler/analysis/ipcRagQaHandlers.ts`)
- RAG QA Worker → Context Assembly: assembles context (evidence: `src/main/utility/rag/ragQaWorker.ts`)
- RAG QA Worker → Model Runtime: resolves runtime (evidence: `src/main/utility/rag/ragQaWorker.ts`)
- RAG QA Worker → Narrative Memory: uses narrative memory
- Workspace UI → Project Sync: syncs projects (evidence: `README.md`)
- Workspace UI → Graph Plugins: manages plugins (evidence: `README.md`)
