This document captures the results of our event storming session for the book building system, providing a foundation for our Elixir migration. The analysis maps the current system's behavior through domain events, commands, actors, aggregates, policies, and identified pain points.
Domain Events (Orange)
Domain events represent significant occurrences in the system that domain experts care about.
Metadata Phase
- MetadataLoaded: Book metadata loaded from meta.yaml and config.yaml
- MetadataValidated: Metadata validated for completeness and correctness
- MetadataEnriched: Additional metadata derived or added
- MetadataApplied: Metadata applied to output formats
Directory Setup Phase
- DirectoryStructureCreated: Project directory hierarchy established
- AssetsImported: External assets imported into project structure
- TemplatesSetup: Book templates initialized
- PreviousVersionsBackedUp: Previous build outputs backed up
Build Phase
- BuildStarted: Book building process initiated
- TexSourceLoaded: LaTeX source files loaded for processing
- PDFGenerated: PDF format successfully created
- HTMLGenerated: HTML format successfully created from LaTeX
- EPUBGenerated: EPUB format successfully created
- MOBIGenerated: MOBI format successfully created from HTML
- KPFGenerated: KPF (Kindle Package Format) successfully created
- KFXGenerated: KFX (Kindle Format X) successfully created
- MarkdownGenerated: Markdown format successfully created
- WikiJSGenerated: WikiJS-compatible markdown successfully created
Quality Check Phase
- EPUBCheckStarted: EPUB validation initiated
- EPUBCheckCompleted: EPUB validation completed
- ACECheckStarted: Accessibility check initiated
- ACECheckCompleted: Accessibility check completed
- PDFDiffStarted: PDF comparison initiated
- PDFDiffCompleted: PDF comparison completed
- QualityChecksFailed: One or more quality checks failed
- QualityChecksCompleted: All quality checks passed
Commands (Blue)
Commands represent actions that trigger domain events.
- LoadMetadata: Load metadata from configuration files
- ValidateMetadata: Check metadata for completeness and correctness
- SetupDirectories: Create project directory structure
- BackupPreviousVersions: Back up existing output files
- StartBuild: Begin book generation process
- BuildPDF: Generate PDF from LaTeX source
- BuildHTML: Generate HTML from LaTeX source
- BuildEPUB: Generate EPUB format
- BuildMOBI: Generate MOBI format using Calibre
- BuildKindle: Generate Kindle formats (KPF, KFX)
- BuildMarkdown: Generate Markdown format
- BuildWikiJS: Generate WikiJS-compatible content
- RunQualityChecks: Execute validation and quality checks
- CheckEPUB: Validate EPUB structure and content
- RunACE: Check EPUB accessibility
- CreatePDFDiff: Compare with previous PDF version
Actors (Yellow)
Actors represent users or systems that initiate commands.
- BookBuilderOrchestrator: Main orchestrator of the build process
- MetadataHandler: System component that manages metadata
- FileStructureSetup: System component that manages directories
- PDFBuilder: Component for PDF generation
- EbookBuilder: Component for ebook format generation
- MarkdownBuilder: Component for markdown generation
- WikiJSBuilder: Component for WikiJS content generation
- QualityChecker: Component for validation and quality checks
Aggregates (Green)
Aggregates represent clusters of domain objects that are treated as a unit.
- Book: Core entity representing the book being processed
- Metadata
- Content
- Output Formats
- Quality Reports
- BuildOptions: Configuration options for the build process
- Directory: File system structure management
- Format: Output format generation (PDF, EPUB, MOBI, etc.)
- QualityReport: Validation results and quality checks
Pain Points (Red)
Pain points represent areas of friction or difficulty in the current system.
- ExternalToolDependencies: Reliance on multiple external tools (epubcheck, ACE, diff-pdf)
- FormatSpecificQuirks: Each format has unique requirements and conversion paths
- QualityCheckRecovery: Handling and recovery from failed quality checks
- DirectoryManagement: Complex directory structure and file management
- MetadataConsistency: Maintaining metadata consistency across formats
Policies (Purple)
Policies represent business rules that react to events and may trigger new commands.
- WhenBuildStarted_LoadMetadata: When build starts, load and validate metadata
- WhenPDFBuilt_GenerateOtherFormats: When PDF is built, proceed with other formats
- WhenFormatGenerated_RunQualityChecks: When formats are generated, run quality checks
- WhenQualityChecksFail_NotifyUser: When quality checks fail, notify the user
- WhenBuildComplete_BackupOutputs: When build completes, backup output files
Elixir Architecture Mapping
Based on this event storming, here's how we map to an Elixir architecture:
Supervision Tree
Codexis.Supervisor
├── BookBuilderOrchestrator
├── MetadataHandler
├── FileStructureSetup
├── BuildManager
│ ├── PDFBuilder
│ ├── EbookBuilder
│ │ ├── EPUBBuilder
│ │ ├── MOBIBuilder
│ │ └── KindleBuilder
│ ├── MarkdownBuilder
│ └── WikiJSBuilder
└── QualityChecker
├── EPUBCheck
├── ACECheck
└── PDFDiff
Core Modules
Codexis.BookBuilderOrchestrator- Main orchestrator GenServerCodexis.MetadataHandler- Metadata managementCodexis.FileStructureSetup- Directory structure managementCodexis.BuildManager- Build process coordinationCodexis.Builder.*- Format-specific buildersCodexis.QualityChecker- Quality check coordination
Event System
Implementation using Phoenix.PubSub:
defmodule Codexis.Events do
@moduledoc """
Event bus for the book building system
"""
def publish(event_name, payload) do
Phoenix.PubSub.broadcast(Codexis.PubSub, event_name, {event_name, payload})
end
def subscribe(event_name) do
Phoenix.PubSub.subscribe(Codexis.PubSub, event_name)
end
end
Next Steps
- Implement core GenServers and supervision tree
- Develop format-specific builders
- Integrate quality checking tools
- Create comprehensive testing strategy
- Document tool dependencies and setup requirements