This directory contains a comprehensive analysis of the Mail Server Factory Kotlin codebase. The analysis covers OS detection, installation architecture, configuration systems, remote execution, and deployment orchestration.
Complete technical reference with code examples
Detailed documentation of all major components:
- Section 1: OS Detection and Support (Host vs Remote)
- Section 2: Installation Architecture (Recipe system)
- Section 3: Configuration System (JSON hierarchy)
- Section 4: Remote Execution (SSH, package managers)
- Section 5: Deployment Flow Orchestration
- Section 6: Mail Server Configuration
- Section 7: Complete Deployment Sequence
- Section 8: Key Architectural Patterns
- Section 9: File Locations Summary
- Section 10: Known Issues and Observations
Use when: You need detailed code examples, exact file paths, and deep understanding of any component.
Key sections:
OperatingSystem.ktimplementation detailsPlatformenum and fallback chainsFilesystemDefinitionProviderOS-specific filtering- Installation step type mappings
- Complete execution flow diagrams
Executive summary of key findings
High-level overview for quick understanding:
- Two-tier OS detection system (Host vs Remote)
- Platform support hierarchy (18 distribution variants)
- Recipe-based installation architecture
- Configuration hierarchy and resolution
- Remote execution via SSH
- Deployment orchestration flows
- Mail server specific features
- Key design patterns
- Notable bugs/issues
Use when: You want a quick understanding without diving into code details.
Key insights:
- How OS detection works at both levels
- Installation step selection process
- Configuration resolution logic
- SSH connection pooling
- Package manager abstraction
- Platform fallback chains
Quick reference guide with diagrams
Practical reference for common tasks:
- OS detection flowcharts
- Installation step selection process
- Configuration file flow
- Installation recipe structure
- SSH connection lifecycle
- File locations table (30+ key files)
- Step-by-step deployment sequence
- Common questions and answers
- Architecture diagrams
Use when: You need quick answers or want to trace a specific flow.
Quick lookup tables:
- Complete file location reference
- Step-by-step deployment sequence
- Common architecture queries with answers
- ASCII diagrams of key flows
| Topic | Start Here |
|---|---|
| Host OS detection | QUICK_ARCHITECTURE_REFERENCE.md → COMPREHENSIVE_CODEBASE_ANALYSIS.md Section 1.1 |
| Remote OS detection | ANALYSIS_SUMMARY.md Section 1 → COMPREHENSIVE_CODEBASE_ANALYSIS.md Section 1.2 |
| Installation recipes | QUICK_ARCHITECTURE_REFERENCE.md → COMPREHENSIVE_CODEBASE_ANALYSIS.md Section 3.4 |
| Configuration flow | QUICK_ARCHITECTURE_REFERENCE.md → COMPREHENSIVE_CODEBASE_ANALYSIS.md Section 3 |
| OS-specific commands | ANALYSIS_SUMMARY.md Section 5 → COMPREHENSIVE_CODEBASE_ANALYSIS.md Section 4.3 |
| Deployment sequence | QUICK_ARCHITECTURE_REFERENCE.md → COMPREHENSIVE_CODEBASE_ANALYSIS.md Section 7 |
| Package managers | COMPREHENSIVE_CODEBASE_ANALYSIS.md Section 4.3 |
| Mail account creation | COMPREHENSIVE_CODEBASE_ANALYSIS.md Section 6 |
| A specific file | QUICK_ARCHITECTURE_REFERENCE.md "File Locations" table |
| How the system works end-to-end | ANALYSIS_SUMMARY.md → QUICK_ARCHITECTURE_REFERENCE.md Step-by-step |
For Quick Understanding (30 minutes):
- Read ANALYSIS_SUMMARY.md completely
- Skim QUICK_ARCHITECTURE_REFERENCE.md diagrams
- Reference specific code as needed
For Implementation (2-3 hours):
- Read ANALYSIS_SUMMARY.md
- Read QUICK_ARCHITECTURE_REFERENCE.md
- Reference COMPREHENSIVE_CODEBASE_ANALYSIS.md Section corresponding to your component
- Read actual source files
For Deep Understanding (4-6 hours):
- Read ANALYSIS_SUMMARY.md
- Read COMPREHENSIVE_CODEBASE_ANALYSIS.md completely
- Read QUICK_ARCHITECTURE_REFERENCE.md
- Study actual source code with file locations as guide
- Trace execution flows end-to-end
For Specific Component (varies):
- Use QUICK_ARCHITECTURE_REFERENCE.md file locations table
- Read corresponding section in COMPREHENSIVE_CODEBASE_ANALYSIS.md
- Read actual source file
- Cross-reference with related components
- Host OS: Where Java application runs (macOS, Linux, Windows)
- Remote OS: Target server being configured (CentOS, Ubuntu, Debian, Fedora, etc.)
- Both use different detection mechanisms
- Both influence behavior throughout deployment
- Recipe-based: JSON definitions specify installation steps
- OS-specific: Each recipe has CentOS, Fedora, Ubuntu variants
- Step types: packages, commands, groups, conditions, reboots, databases, deployments
- Dynamic selection: Detected OS determines which recipe variant to use
- Hierarchical includes: Example config includes Common, which includes multiple sub-configs
- Definition loading: Software definitions loaded based on detected OS
- Variable substitution:
{{CONTEXT.KEY}}replaced with values - Fallback chains: If exact platform not found, falls back to more general platforms
- SSH connection pooling: Connections cached by remote address
- Platform detection: Determined via SSH commands and output parsing
- Package manager abstraction: Yum for RPM, Apt for Debian, etc.
- OS-specific commands: Generated based on detected platform
- Sequential flows: InitializationFlow → InstallationFlow → DockerFlow → DatabaseFlow → MailFlow
- Flow-based execution: Each flow runs its contained steps
- Condition handling: Some steps conditionally skip based on checks
- Error handling: Failures stop execution, success callbacks trigger next flow
Project Root/
├── CODEBASE_ANALYSIS_INDEX.md (this file)
├── COMPREHENSIVE_CODEBASE_ANALYSIS.md (full reference)
├── ANALYSIS_SUMMARY.md (quick overview)
├── QUICK_ARCHITECTURE_REFERENCE.md (practical guide)
│
├── Application/src/
│ ├── main/kotlin/net/milosvasic/factory/mail/application/main.kt
│ └── os/{macos,default}/kotlin/.../OSInit.kt
│
├── Core/Framework/src/main/kotlin/
│ ├── net/milosvasic/factory/platform/
│ │ ├── OperatingSystem.kt
│ │ ├── Platform.kt
│ │ └── Architecture.kt
│ ├── net/milosvasic/factory/component/installer/
│ ├── net/milosvasic/factory/configuration/
│ └── net/milosvasic/factory/remote/ssh/SSH.kt
│
├── Factory/src/main/kotlin/net/milosvasic/factory/mail/
│ ├── application/server_factory/MailServerFactory.kt
│ └── configuration/MailServerConfigurationFactory.kt
│
├── Examples/
│ ├── Centos_8.json
│ ├── Ubuntu_22.json
│ └── Includes/Common.json
│
└── Definitions/main/
├── software/docker/1.0.0/
│ ├── Definition.json
│ ├── Centos/Docker.json
│ ├── Fedora/Docker.json
│ └── Ubuntu/Docker.json
└── docker/*/1.0.0/
└── (container definitions)
-
Host OS Detection Bug (OperatingSystem.kt lines 37, 40)
- All three platform detection methods check for "mac"
- Should check "linux" and "win" as well
-
Remote OS Architecture
- Initialized as UNKNOWN, properly populated during parseAndSetSystemInfo()
-
Variable Substitution Limitations
- Limited support for nested references
- Currently
${CONTEXT.KEY}only
Also see in project root:
- CLAUDE.md - Project instructions and guidelines
- README.md - Project overview
- TESTING.md - Testing documentation
- PRODUCTION.md - Production deployment guide
- Analysis Date: October 24, 2025
- Codebase Status: Production
- Languages: Kotlin 2.0.21, JSON, Bash
- Build System: Gradle 8.14.3
- Java Target: Java 17
- Module Structure: Multi-module (Application, Factory, Core/Framework, Logger)
- Test Coverage: 47 tests, 100% pass rate
To update these documents:
- Make changes to the source code
- Re-run analysis tools
- Update corresponding sections
- Ensure consistency across all three documents
- Update this index if structure changes
Last Updated: October 24, 2025 Analysis Completeness: Comprehensive (all major components covered) Code Examples: Included File Locations: Complete reference table Diagrams: Included in reference guide