# duct-framework/core architecture

> Architecture diagram of the GitHub repository duct-framework/core, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/duct-framework/core
- Repository: https://github.com/duct-framework/core

## Overview

##### Main Components

a) Core Framework Components:
- Configuration Reader
- Module System
- Profile System
- Environment Handler
- Resource Manager
- REPL Integration

b) External Dependencies:
- Integrant (micro-framework)
- Java I/O (for resource handling)

**User Application Layer**

- ▼
**Configuration Layer (EDN files)**

- ▼
**Duct Core Processing Layer**

- ▼
**Integrant Framework Layer**

##### Key Relationships to Highlight

a) Configuration Flow:
- How EDN configurations are read and processed
- Transformation pipeline: read-config → prep-config → exec-config

b) Module System:
- Module hierarchy with `:duct/module` as the parent
- How modules can have dependencies using `integrant.core/prep-key`
- Demonstrate module function application to configurations

c) Profile System:
- Relationship between the five built-in profiles:
- :duct.profile/base
- :duct.profile/dev
- :duct.profile/local
- :duct.profile/test
- :duct.profile/prod

##### Special Elements

a) Reader Tags (use distinct symbols):
- #duct/env
- #duct/include
- #duct/resource
- #duct/displace
- #duct/replace

- :duct/const
- :duct/module
- :duct/profile
- :duct.core/environment
- :duct.core/project-ns

##### Implementation Details

**src/duct/core/**
- core.clj (main functionality)
- env.clj (environment handling)
- merge.clj (configuration merging)
- repl.clj (REPL integration)
- resource.clj (resource management)

##### Testing Integration

How the test directory structure mirrors the source structure and how test profiles integrate with the system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Application"
        UA[User Application]
    end

    subgraph "Configuration Layer"
        Config["Configuration Files"]:::config
        click Config "https://github.com/duct-framework/core/blob/master/test/duct/config.edn"
        Reader["Reader Configuration"]:::config
        click Reader "https://github.com/duct-framework/core/blob/master/test/duct/reader.edn"
        Included["Included Configuration"]:::config
        click Included "https://github.com/duct-framework/core/blob/master/test/duct/included.edn"
        Nested["Nested Configuration"]:::config
        click Nested "https://github.com/duct-framework/core/blob/master/test/duct/nested.edn"
    end

    subgraph "Duct Core Framework"
        CoreImpl["Core Implementation"]:::core
        click CoreImpl "https://github.com/duct-framework/core/blob/master/src/duct/core.clj"
        EnvHandler["Environment Handler"]:::core
        click EnvHandler "https://github.com/duct-framework/core/blob/master/src/duct/core/env.clj"
        ConfigMerger["Configuration Merger"]:::core
        click ConfigMerger "https://github.com/duct-framework/core/blob/master/src/duct/core/merge.clj"
        ReplInt["REPL Integration"]:::core
        click ReplInt "https://github.com/duct-framework/core/blob/master/src/duct/core/repl.clj"
        ResManager["Resource Manager"]:::core
        click ResManager "https://github.com/duct-framework/core/blob/master/src/duct/core/resource.clj"
        Hierarchy["Framework Hierarchy"]:::core
        click Hierarchy "https://github.com/duct-framework/core/blob/master/src/duct_hierarchy.edn"
    end

    subgraph "Testing Layer"
        CoreTests["Core Tests"]:::test
        click CoreTests "https://github.com/duct-framework/core/blob/master/test/duct/core_test.clj"
        EnvTests["Environment Tests"]:::test
        click EnvTests "https://github.com/duct-framework/core/blob/master/test/duct/env_test.clj"
        ReplTests["REPL Tests"]:::test
        click ReplTests "https://github.com/duct-framework/core/blob/master/test/duct/repl_test.clj"
        ResTests["Resource Tests"]:::test
        click ResTests "https://github.com/duct-framework/core/blob/master/test/duct/resource_test.clj"
        Example["Example Implementation"]:::test
        click Example "https://github.com/duct-framework/core/blob/master/test/duct/example.clj"
    end

    subgraph "Profile System"
        Base["Base Profile"]:::profile
        Dev["Dev Profile"]:::profile
        Local["Local Profile"]:::profile
        Test["Test Profile"]:::profile
        Prod["Prod Profile"]:::profile
    end

    subgraph "Module System"
        ModuleCore["Module Core"]:::module
        ModuleDeps["Module Dependencies"]:::module
    end

    subgraph "External Dependencies"
        Integrant["Integrant Framework"]:::external
        JavaIO["Java I/O"]:::external
    end

    %% Relationships
    UA --> Config
    Config --> CoreImpl
    Reader --> CoreImpl
    Included --> CoreImpl
    Nested --> CoreImpl
    
    CoreImpl --> EnvHandler
    CoreImpl --> ConfigMerger
    CoreImpl --> ReplInt
    CoreImpl --> ResManager
    CoreImpl --> Hierarchy
    
    EnvHandler --> JavaIO
    ResManager --> JavaIO
    CoreImpl --> Integrant
    
    Base --> CoreImpl
    Dev --> Base
    Local --> Base
    Test --> Base
    Prod --> Base
    
    ModuleCore --> CoreImpl
    ModuleDeps --> ModuleCore
    
    CoreImpl --> CoreTests
    EnvHandler --> EnvTests
    ReplInt --> ReplTests
    ResManager --> ResTests
    CoreImpl --> Example

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef config fill:#2ecc71,stroke:#27ae60,color:white
    classDef module fill:#e67e22,stroke:#d35400,color:white
    classDef profile fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef test fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Configuration Files"]:::config
        L3["Module System"]:::module
        L4["Profile System"]:::profile
        L5["External Dependencies"]:::external
        L6["Testing Components"]:::test
    end
```
