Package Dependencies Diagram
This document visualizes the dependency relationships between DocBuilder packages, showing how different layers interact and the import rules that must be followed.
Last Updated: January 4, 2026 - Reflects current package structure.
Dependency Graph
Layer Dependencies (Must Respect)
Legend:
- ✓ = Allowed to import
- ✗ = NOT allowed to import
Import Rules
✅ Allowed Imports
Command Layer (cmd/docbuilder/commands/):
- ✅
internal/build/- Build service orchestration - ✅
internal/daemon/- Daemon service - ✅
internal/config/- Configuration loading - ✅
internal/foundation/errors- Error handling
Service Layer (internal/build/, internal/daemon/):
- ✅
internal/hugo/- Hugo site generation - ✅
internal/docs/- Documentation discovery - ✅
internal/git/- Git operations - ✅
internal/config/- Configuration access - ✅
internal/state/- State management - ✅
internal/foundation/errors- Error handling
Domain Layer (internal/hugo/, internal/docs/, internal/forge/):
- ✅
internal/config/- Configuration reading - ✅
internal/docs/- Document models - ✅
internal/foundation/errors- Error handling - ✅
internal/hugo/pipeline/- Transform pipeline (hugo package only)
Pipeline (internal/hugo/pipeline/):
- ✅
internal/config/- Configuration reading - ✅
internal/foundation/errors- Error handling - ✅ No imports from
internal/hugo/(except via interfaces)
Infrastructure Layer (internal/git/, internal/workspace/, internal/forge/):
- ✅
internal/config/- Configuration reading - ✅
internal/foundation/errors- Error handling
Foundation Layer (internal/foundation/):
- ✅ Standard library only
- ❌ No internal/ package imports
❌ Forbidden Imports
Configuration (internal/config/):
- ❌ Cannot import
internal/build/ - ❌ Cannot import
internal/hugo/ - ❌ Cannot import
internal/git/ - Reason: Config is a leaf domain package
Git (internal/git/):
- ❌ Cannot import
internal/build/ - ❌ Cannot import
internal/hugo/ - ❌ Cannot import
internal/daemon/ - Reason: Infrastructure packages shouldn’t know about application services
Foundation (internal/foundation/):
- ❌ Cannot import any
internal/packages - Reason: Foundation is the base layer - no upward dependencies
Pipeline (internal/hugo/pipeline/):
- ❌ Cannot import parent
internal/hugo/(except through interfaces) - Reason: Avoid circular dependencies
Package Purposes
Command Layer
cmd/docbuilder/commands/
Purpose: CLI command implementations
Key Files:
build.go- Build command (main entry point)daemon.go- Daemon/watch modepreview.go- Live preview serverdiscover.go- Documentation discovery analysislint.go- Documentation linting
Imports: build, daemon, config
Service Layer
internal/build/
Purpose: Build pipeline orchestration
Key Components:
BuildServiceinterface - Contract for build executionDefaultBuildService- Standard pipeline implementation- Stage execution and error handling
- Build result aggregation
Imports: hugo, docs, git, config, state, forge
internal/daemon/
Purpose: Watch mode and HTTP server
Key Components:
DaemonService- Watch and rebuild on changes- HTTP server for preview
- LiveReload integration
- Build queue management
Imports: build, config, state, git
Domain Layer
internal/config/
Purpose: Configuration models and validation
Key Types:
Config- Root configurationRepository- Repository definitionHugoConfig- Hugo-specific settingsDaemonConfig- Daemon-specific settings
Imports: foundation/errors only
internal/hugo/
Purpose: Hugo site generation
Key Components:
Generator- Main site generator- Stage implementations (prepare, config, copy, indexes, render)
BuildState- Mutable state during pipelineBuildReport- Build metrics and outcomes
Imports: config, docs, pipeline, forge, git, workspace
internal/hugo/pipeline/
Purpose: Content transformation pipeline
Key Types:
Processor- Pipeline coordinatorDocument- Intermediate document representationFileTransform- Transform function typeFileGenerator- Generator function type
12 Transform Functions:
parseFrontMatternormalizeIndexFilesbuildBaseFrontMatterextractIndexTitlestripHeadingescapeShortcodesInCodeBlocksrewriteRelativeLinksrewriteImageLinksgenerateFromKeywordsaddRepositoryMetadataaddEditLinkserializeDocument
Imports: config, foundation/errors
internal/docs/
Purpose: Documentation discovery and file management
Key Types:
DocFile- Documentation file modelDiscovery- File discovery service
Key Functions:
DiscoverDocs()- Find markdown filesGetHugoPath()- Convert source path to Hugo path
Imports: config, foundation/errors
internal/forge/
Purpose: Forge platform integration (GitHub, GitLab, Forgejo)
Key Interfaces:
Forge- Platform abstraction- Platform-specific implementations
Key Operations:
- Repository metadata fetching
- Edit link generation
- API authentication
Imports: config, foundation/errors
internal/state/
Purpose: Build state persistence and management
Key Types:
GitState- Repository cloning stateDocsState- Documentation discovery statePipelineState- Execution metadata
Imports: config, foundation/errors
Infrastructure Layer
internal/git/
Purpose: Git repository operations
Key Components:
Client- Git operations client- Authentication handling (SSH, token, basic)
- Clone, update, and fetch operations
- Change detection
Imports: config, workspace, foundation/errors
internal/workspace/
Purpose: Temporary workspace management
Key Operations:
- Create temporary directories
- Cleanup after builds
- Path resolution
Imports: foundation/errors
internal/forge/ (infrastructure aspects)
Purpose: HTTP clients for forge APIs
Imports: config, foundation/errors
Foundation Layer
internal/foundation/errors
Purpose: Unified error handling
Key Types:
ClassifiedError- Error with category and contextErrorCategory- Type-safe error categories
Categories:
- Config, Validation, Auth, NotFound
- Network, Git, Forge
- Build, Hugo, FileSystem
- Runtime, Daemon, Internal
Imports: Standard library only
internal/logfields/
Purpose: Structured logging field constants
Imports: Standard library only
internal/metrics/
Purpose: Metrics collection (currently NoopRecorder)
Imports: Standard library only
Dependency Patterns
Service Composition
Configuration Flow
Error Propagation
Circular Dependency Prevention
Problem: Package A imports B, B imports A (circular)
Prevention Strategies:
-
Dependency Inversion: Use interfaces
-
Shared Package: Extract common types to lower layer
-
Event-Based: Use event store for loose coupling
References
permalink[package-dependencies-diagram](https://docs.home.luguber.info/_uid/a12d6319-3e23-4e1f-a276-920b402b50d6/)