SousChef Architecture Declaration#
Version: 2.0 Last Updated: 2026-03-06 Status: Approved & Enforced via SonarCloud
This document is the authoritative architectural declaration for SousChef. All code must adhere to the structure, dependencies, and boundaries defined here.
Quick Navigation#
- Architectural Vision
- Layered Architecture
- Container Definitions
- Dependency Matrix
- Module Placement Rules
- SonarCloud Enforcement
- Growth Guidelines
Architectural Vision#
SousChef is evolving from a Chef-to-Ansible converter into a multi-source, multi-target infrastructure-as-code transformation platform with enterprise features:
Transformation Capabilities (Current & Planned)#
- β Chef β Ansible (current)
- β Puppet β Ansible (current)
- π Salt β Ansible (planned)
- β Bash scripts β Ansible
- β PowerShell scripts β Ansible
- π Multi-target: Ansible, Terraform, CloudFormation (via IR)
Enterprise Features (Planned)#
- π REST API - Programmatic access to all capabilities
- π Authentication & RBAC - Role-based access control
- π Audit Logging - Compliance and change tracking
- π Team Collaboration - Multi-user workflows
- π Performance Benchmarking - Profiling and optimisation metrics
- π Integrations - GitHub, GitLab, AWX, Jira, Slack
- π UI Enhancements - Dark mode, accessibility, analytics, AI recommendations
Design Principles#
- Separation of Concerns - Each container handles one responsibility
- Dependency Discipline - Lower layers never depend on higher layers
- Plugin Architecture - Extensible parser/generator framework via IR
- API-First - All features accessible via REST API
- Security by Design - Auth, RBAC, and audit at the core
- Observable - Performance metrics, logging, and analytics throughout
Layered Architecture#
SousChef follows a strict layered architecture where dependencies only flow downward. Higher layers can depend on lower layers, but never the reverse.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 7: User Interfaces β
β cli/, ui/, server.py (MCP) β
β (Depends on: orchestrators, api) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 6: Orchestration β
β orchestrators/, assessment.py, deployment.py β
β (Depends on: parsers, converters, generators, integrations) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 5: Integration & API β
β api/, integrations/ β
β (Depends on: auth, audit, storage, orchestrators) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 4: Services β
β auth/, audit/, benchmarking/ β
β (Depends on: core, storage) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 3: Domain Logic β
β parsers/, converters/, generators/ β
β (Depends on: core, ir, storage, filesystem) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 2: Data & Infrastructure β
β storage/, filesystem/, ir/ β
β (Depends on: core) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 1: Foundation β
β core/ β
β (No dependencies - provides utilities, constants, errors) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Container Definitions#
Layer 1: Foundation#
core/ - Shared Utilities#
Purpose: Foundation layer providing reusable utilities, constants, and base classes.
Status: β
Exists
Dependencies: None (foundation layer)
Contains:
- constants.py - Application-wide constants
- errors.py - Custom exception classes
- path_utils.py - Path normalization and validation
- ruby_utils.py - Ruby value parsing utilities
- validation.py - Input validation helpers
- ansible_versions.py - Ansible version compatibility data
- metrics.py - Effort/timeline calculation utilities
- logging.py - Logging configuration
- caching.py - Caching mechanisms
Rules: - β NEVER import from any other souschef module - β Only import from Python stdlib and third-party libraries - β Keep logic minimal - utilities only, no business logic
Layer 2: Data & Infrastructure#
storage/ - Data Persistence#
Purpose: Database and blob storage abstractions.
Status: β
Exists (database.py, blob.py)
Dependencies: core/
Contains:
- database.py - PostgreSQL/SQLite database access
- blob.py - Object storage (MinIO/S3) access
- models.py - Data models and ORM definitions
Rules:
- β
Can import from: core/
- β Cannot import from: any other containers
filesystem/ - File Operations#
Purpose: Safe file system operations with validation.
Status: β
Exists
Dependencies: core/
Contains:
- operations.py - Directory/file operations with safety checks
Rules:
- β
Can import from: core/
- β Cannot import from: any other containers
ir/ - Intermediate Representation#
Purpose: Abstract, tool-agnostic representation of infrastructure configurations.
Status: β
Exists
Dependencies: core/
Contains:
- schema.py - IRGraph, IRNode, IRAction data structures
- versioning.py - Version management and schema evolution
- plugin.py - SourceParser/TargetGenerator plugin framework
Rules:
- β
Can import from: core/
- β Cannot import from: any other containers
- π― Key Design: Tool-agnostic - no Chef/Puppet/Ansible-specific code
Layer 3: Domain Logic#
parsers/ - Input Parsing#
Purpose: Extract structured data from source configuration management tools.
Status: β
Exists (Chef parsers, PowerShell parser, Bash parser, Puppet parser, Salt parser)
Dependencies: core/, ir/, filesystem/
Contains:
- recipe.py - Chef recipe parser
- metadata.py - Chef metadata parser
- attributes.py - Chef attributes parser
- template.py - ERB template parser
- habitat.py - Habitat plan parser
- inspec.py - InSpec profile parser
- ansible_inventory.py - Ansible inventory parser
- β
puppet.py - Puppet manifest parser (14 recognised resource types, 10 mapped to Ansible modules, unsupported construct detection)
- β
salt.py - Salt state parser
- β
bash.py - Bash script parser (13 operation categories, confidence scoring, sensitive data detection)
- β
powershell.py - PowerShell script parser
Rules:
- β
Can import from: core/, ir/, filesystem/
- β Cannot import from: converters/, generators/, orchestrators/, api/, ui/, cli/
- π― Key Design: Read-only - extract structure without transformation
converters/ - Transformation Logic#
Purpose: Transform parsed data into intermediate or target formats.
Status: β
Exists (ChefβAnsible, PowerShellβAnsible, BashβAnsible, PuppetβAnsible); π Planned (multi-target)
Dependencies: core/, parsers/, ir/
Contains:
- playbook.py - Recipe β Ansible playbook
- resource.py - Resource β Ansible task
- habitat.py - Habitat β Docker
- template.py - ERB β Jinja2
- conversion_rules.py - Transformation rules engine
- β
puppet_to_ansible.py - Puppet β Ansible (10 resource types fully mapped + AI-assisted conversion for complex constructs)
- π salt_to_ansible.py - Salt β Ansible (planned)
- β
powershell.py - PowerShell β Ansible (exists)
- β
bash_to_ansible.py - Bash β Ansible (exists)
Rules:
- β
Can import from: core/, parsers/, ir/
- β Cannot import from: generators/, orchestrators/, api/, ui/, cli/
- π― Key Design: Pure transformation - no I/O, no orchestration
generators/ - Output Generation#
Purpose: Generate target configuration files from IR or converter output.
Status: β
Exists (repo.py, powershell.py)
Dependencies: core/, converters/, ir/, filesystem/
Contains:
- repo.py - Ansible repository structure generation
- β
powershell.py - Windows inventory, group_vars, requirements.yml, role skeleton, AWX job template, fidelity report
- π terraform.py - Terraform module generation (planned)
- π cloudformation.py - CloudFormation template generation (planned)
Rules:
- β
Can import from: core/, converters/, ir/, filesystem/
- β Cannot import from: orchestrators/, api/, ui/, cli/
Layer 4: Services#
auth/ - Authentication & Authorization#
Purpose: User authentication, role-based access control (RBAC).
Status: π Planned
Dependencies: core/, storage/
Contains:
- authentication.py - User login/logout, session management
- rbac.py - Role and permission management
- tokens.py - JWT token generation and validation
- policies.py - Access policy definitions
Rules:
- β
Can import from: core/, storage/
- β Cannot import from: domain logic, orchestrators, integrations, UI
audit/ - Audit Logging#
Purpose: Compliance, change tracking, audit trail.
Status: π Planned
Dependencies: core/, storage/, auth/
Contains:
- logger.py - Audit event logging
- events.py - Audit event definitions
- compliance.py - Compliance report generation
Rules:
- β
Can import from: core/, storage/, auth/
- β Cannot import from: domain logic, orchestrators, integrations, UI
benchmarking/ - Performance Metrics#
Purpose: Performance profiling, benchmarking, optimisation metrics.
Status: β
Exists (profiling.py - needs migration)
Dependencies: core/, storage/
Contains:
- profiler.py - Code execution profiling
- metrics.py - Performance metric collection
- reports.py - Benchmark report generation
Rules:
- β
Can import from: core/, storage/
- β Cannot import from: domain logic, orchestrators, integrations, UI
Layer 5: Integration & API#
integrations/ - External Systems#
Purpose: Integration with GitHub, GitLab, AWX, Jira, Slack, etc.
Status: β
Partial (github/); π Planned (others)
Dependencies: core/, auth/, audit/, storage/
Contains:
- github/ - GitHub API client and workflows
- π gitlab.py - GitLab API integration (planned)
- π awx.py - AWX/Tower API client (planned)
- π jira.py - Jira issue tracking (planned)
- π slack.py - Slack notifications (planned)
Rules:
- β
Can import from: core/, auth/, audit/, storage/
- β Cannot import from: domain logic (parsers/converters), orchestrators, UI
api/ - REST API#
Purpose: RESTful API for programmatic access to all platform capabilities.
Status: π Planned
Dependencies: core/, auth/, audit/, storage/, orchestrators/
Contains:
- routes/ - API endpoint definitions
- schemas.py - Request/response schemas (Pydantic)
- middleware.py - Authentication, rate limiting, CORS
- docs.py - OpenAPI/Swagger documentation
Rules:
- β
Can import from: core/, auth/, audit/, storage/, orchestrators/
- β Cannot import from: cli/, ui/, server.py (MCP)
- π― Key Design: Stateless, RESTful, versioned (/v1/, /v2/)
Layer 6: Orchestration#
orchestrators/ - Workflow Coordination#
Purpose: High-level workflows coordinating parsers, converters, generators.
Status: β
Partial (assessment.py, deployment.py as top-level); π Needs refactor
Dependencies: core/, parsers/, converters/, generators/, integrations/, storage/
Contains:
- migration.py - End-to-end migration workflows
- analysis.py - Codebase analysis orchestration
- validation.py - Multi-stage validation workflows
- deployment.py - Deployment orchestration (refactored from top-level)
- assessment.py - Assessment workflows (refactored from top-level)
Rules:
- β
Can import from: core/, parsers/, converters/, generators/, integrations/, storage/, auth/, audit/, benchmarking/
- β Cannot import from: api/, cli/, ui/, server.py
- π― Key Design: Coordinates lower layers, implements business workflows
Layer 7: User Interfaces#
cli/ - Command-Line Interface#
Purpose: Terminal-based user interface.
Status: β
Exists (cli.py, cli_v2_commands.py, cli_registry.py - needs consolidation)
Dependencies: orchestrators/, api/ (optional)
Contains:
- commands/ - CLI command implementations
- interactive.py - Interactive mode (prompts, wizards)
Rules:
- β
Can import from: orchestrators/, api/ (if using REST API), core/
- β Cannot import from: ui/, server.py, domain logic directly
- π― Key Design: Thin wrapper around orchestrators
ui/ - Web User Interface#
Purpose: Browser-based dashboard and visualizations.
Status: β
Exists (Streamlit); π Planned enhancements (Next.js, analytics, dark mode)
Dependencies: api/, orchestrators/
Contains:
- app.py - Main Streamlit application
- pages/ - Dashboard pages
- components/ - Reusable UI components
- π analytics.py - Usage analytics and insights (planned)
- π recommendations.py - AI-powered smart recommendations (planned)
- π themes.py - Dark mode and accessibility themes (planned)
Rules:
- β
Can import from: api/, orchestrators/ (for direct calls during prototyping), core/
- β Cannot import from: cli/, server.py, domain logic directly
- π― Key Design: API-first - all actions call REST API (when available)
server.py - MCP Server (Top-Level File)#
Purpose: Model Context Protocol server entry point.
Status: β
Exists
Dependencies: orchestrators/, core/
Contains:
- MCP tool registration using FastMCP
- Tool wrapper functions calling orchestrators
Rules:
- β
Can import from: orchestrators/, core/
- β Cannot import from: cli/, ui/, domain logic directly
- π― Key Design: Thin MCP wrapper around orchestrators
Dependency Matrix#
This matrix defines which containers CAN import from which other containers. Use this when implementing Phase 2 in SonarCloud.
Legend: - β = Allowed dependency - β = Forbidden dependency - π = Conditional (e.g., only during certain phases)
| From β / To β | core | storage | filesystem | ir | parsers | converters | generators | auth | audit | benchmarking | integrations | api | orchestrators | cli | ui | server.py |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| core | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| storage | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| filesystem | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| ir | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| parsers | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| converters | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| generators | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| auth | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| audit | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| benchmarking | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| integrations | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| api | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| orchestrators | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
| cli | β | β | β | β | β | β | β | β | β | β | β | π | β | β | β | β |
| ui | β | β | β | β | β | β | β | β | β | β | β | β | π | β | β | β |
| server.py | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β | β |
Matrix Validation Rules#
Foundation Layer (core): - β Can import: Only Python stdlib and third-party libraries - β Cannot import: Any souschef module
Data Layer (storage, filesystem, ir):
- β
Can import: core/ only
- β Cannot import: Any higher layer
Domain Layer (parsers, converters, generators):
- β
Can import: core/, ir/, filesystem/ (parsers, generators only), parsers/ (converters only), converters/ (generators only)
- β Cannot import: Services, integrations, orchestrators, UI layers
Service Layer (auth, audit, benchmarking):
- β
Can import: core/, storage/, sometimes each other (auditβauth)
- β Cannot import: Domain logic, orchestrators, UI layers
Integration & API Layer: - β Can import: Foundation, data, services, orchestrators (API only) - β Cannot import: Domain logic directly, UI layers
Orchestration Layer:
- β
Can import: All lower layers except API/UI interfaces
- β Cannot import: api/, cli/, ui/, server.py
UI Layer (cli, ui, server.py):
- β
Can import: orchestrators/, api/ (UI only), core/
- β Cannot import: Domain logic directly, other UI containers
Module Placement Rules#
Use this decision tree when creating new code:
NEW FEATURE/CODE
β
ββ Is it a utility/constant/base class?
β ββ YES β core/
β
ββ Does it store/retrieve data?
β ββ YES β storage/ or filesystem/
β
ββ Does it parse input files?
β ββ YES β parsers/ (e.g., parsers/puppet.py)
β
ββ Does it transform data without I/O?
β ββ YES β converters/ or generators/
β
ββ Is it authentication/authorization?
β ββ YES β auth/
β
ββ Is it audit logging/compliance?
β ββ YES β audit/
β
ββ Is it performance profiling?
β ββ YES β benchmarking/
β
ββ Is it an external system integration?
β ββ YES β integrations/ (e.g., integrations/gitlab.py)
β
ββ Is it a REST API endpoint?
β ββ YES β api/routes/
β
ββ Does it coordinate multiple lower layers?
β ββ YES β orchestrators/
β
ββ Is it a user interface?
ββ CLI? β cli/commands/
ββ Web? β ui/pages/ or ui/components/
ββ MCP? β server.py (top-level file)
Examples#
Puppet Support (Implemented):
1. β
parsers/puppet.py - Parse Puppet manifests β structured data (14 recognised resource types, 10 fully mapped to Ansible)
2. β
converters/puppet_to_ansible.py - Puppet β Ansible via ansible.builtin modules
3. β
ui/pages/puppet_migration.py - Streamlit UI page for manifest/module conversion
4. β
8 MCP tools in server.py β parse, convert, list types, AI-assisted conversion
5. β
CLI commands via souschef puppet subcommand group
6. π orchestrators/migration.py - Full Puppet workflow orchestration (planned)
7. π api/routes/puppet.py - REST endpoints for Puppet conversion (planned)
Adding RBAC:
1. auth/rbac.py - Role and permission management
2. auth/policies.py - Policy definitions
3. api/middleware.py - Update to enforce RBAC on endpoints
4. audit/logger.py - Log permission checks
5. ui/components/permissions.py - UI for role assignment
Adding Dark Mode:
1. ui/themes.py - Theme definitions and switcher
2. ui/components/*.py - Update components to use theme context
3. api/routes/user_preferences.py - Store user theme preference
SonarCloud Enforcement#
Phase 1: Container-Level (Current)#
Status: β Implemented in UI
Containers defined:
- souschef/core
- souschef/parsers
- souschef/converters
- souschef/filesystem
- souschef/ir
Next Steps:
1. Add remaining containers to Phase 1:
- souschef/storage
- souschef/generators
- souschef/auth (create skeleton)
- souschef/audit (create skeleton)
- souschef/benchmarking (migrate profiling.py)
- souschef/integrations (existing github/)
- souschef/api (create skeleton)
- souschef/orchestrators (create + migrate assessment.py, deployment.py)
- souschef/cli (consolidate existing files)
- souschef/ui
- Define relationships in SonarCloud UI based on Dependency Matrix above
Phase 2: File-Level (Future)#
Define individual modules within containers for granular enforcement
Example:
- souschef/parsers/recipe.py can depend on souschef/core/path_utils.py
- souschef/parsers/recipe.py cannot depend on souschef/converters/playbook.py
Growth Guidelines#
When Adding New Capabilities#
1. Start with Architecture - Is this a new container or fits in existing? - What dependencies does it need? - Check Dependency Matrix for violations
2. Create Container Skeleton (if new)
# souschef/newcontainer/__init__.py
"""
NewContainer: Brief description
Purpose: What this container does
Dependencies: Which containers it can import from
Rules: What it cannot do
"""
__version__ = "1.0.0"
3. Update Architecture Document - Add to Container Definitions - Update Dependency Matrix - Add to Module Placement Rules decision tree
4. Implement with Discipline
- Follow dependency rules strictly
- Write tests in tests/unit/test_newcontainer.py
- Update integration tests if needed
5. Update SonarCloud - Add container to architecture definition - Define allowed dependencies - Verify no violations detected
When Refactoring Existing Code#
Current Violations to Fix:
- Top-Level Files (assessment.py, deployment.py, ansible_upgrade.py, profiling.py)
- Issue: Not in containers, hard to govern
- Solution: Migrate to
orchestrators/or appropriate container -
Timeline: v2.1 refactor sprint
-
CLI Consolidation (cli.py, cli_v2_commands.py, cli_registry.py)
- Issue: Fragmented CLI code
- Solution: Consolidate into
cli/container -
Timeline: v2.1 refactor sprint
-
Profiling Migration (profiling.py β benchmarking/)
- Issue: Not in proper service container
- Solution: Move to
benchmarking/profiler.py - Timeline: v2.0 completion
Migration Checklist#
When moving code between containers:
- Verify new location follows Dependency Matrix
- Update all imports in dependent modules
- Move tests to mirror new structure
- Update API documentation if endpoints change
- Add deprecation notices for old imports (if public API)
- Update SonarCloud architecture definition
- Run full test suite
- Update CHANGELOG.md
Related Documentation#
- CONTRIBUTING.md - Development workflow and code standards
- sonar-project.properties - SonarCloud configuration
- README.md - Project overview and quickstart
- .github/copilot-instructions.md - AI coding assistant guidelines
Questions? Open a GitHub discussion or consult the maintainers before violating architectural boundaries!
Last Review: 2026-03-06 by @kpeacocke