How edwardathomson/novelwriter works
Project Type and Purpose
• Full‐stack standalone Python desktop application with a GUI (Tkinter)
• Purpose: guide authors through multi‐stage novel creation (parameters → lore → structure → scenes → chapters), leveraging LLMs
File Structure
• Top level:
– main.py (app entry, launches GUI)
– ai_helper.py, rag_helper.py, helper_fns.py, logger_config.py (shared utilities/helpers)
– parameters.py, lore.py, story_structure.py, scene_plan.py, chapter_writing.py (core pipeline modules)
– Generators/ (genre‐specific generator classes and JSON profiles)
– genre_configs/ (genre parameter configurations)
– combine.py (post‐processing script to assemble chapters)
• Supporting docs under docs/ and screenshots/ for user/developer guidance
README for Architecture Insights
• Modular architecture:
– Genre Handlers
– Configuration System
– Character & Faction Generators
– Story Integration (structure + scenes)
• Workflow stages mapped to GUI tabs
Main Components & Their Interactions
a. User Interface Layer (Tkinter GUI – main.py)
• Captures user selections: genre, model, story structure, etc.
• Presents each stage as a tab (Parameters, Lore, Structure, Scenes, Write)
→ Calls core pipeline modules
b. Core Pipeline Modules
1) Parameters Manager (parameters.py + genre_configs/)
2) Lore Generation (lore.py + Generators/ + ai_helper.py + rag_helper.py)
3) Story Structure (story_structure.py)
4) Scene Planning (scene_plan.py)
5) Chapter Writing (chapter_writing.py)
6) Combine Script (combine.py) – optional CLI utility
c. Helpers & Utilities
• ai_helper.py: abstracts LLM API calls (OpenAI, Gemini, Claude)
• rag_helper.py: retrieval‐augmented generation support
• helper_fns.py: shared data transformations
• logger_config.py: centralized logging setup
d. Configuration & Data
• .env (API keys)
• JSON profiles in Generators/
• genre_configs/*.py for parameter defaults
• Generated outputs in current_work/ (chapters, intermediate files)
e. External Services
• LLM endpoints (OpenAI, Google Gemini, Anthropic Claude)
Architectural Patterns & Design Principles
• Modular, stage‐based pipeline
• Genre‐driven strategy pattern (Genre Handlers + configs)
• Separation of concerns: UI vs. core logic vs. helpers vs. data
• Externalized configurations (JSON + Python modules)
• Clear single responsibility for each script/module
Essential Elements
• Clear labels (module name + purpose)