# jmalarcon/miis architecture

> Architecture diagram of the GitHub repository jmalarcon/miis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jmalarcon/miis
- Repository: https://github.com/jmalarcon/miis

## Overview

##### Project type and purpose
- MIIS is a file-based CMS / dynamic static-site-generator hybrid running on IIS or Azure Web Apps.
- It intercepts HTTP requests, parses Markdown/HTML files with front-matter, applies Liquid templates (via MIISdotliquid), and serves rendered HTML on the fly—no database or pre-build step required.

##### High-level file structure analysis
- Root
- .gitmodules → two Git submodules: IISHelpers (IIS integration helpers) and MIISdotliquid (Liquid engine integration).
- IISHelpers, MIISdotliquid folders
- src/MIISHandler → core HTTP-module / handler, configuration (Web.config), filters, field resolvers, renderer, FMSources interfaces.
- src/Extensions → pluggable extensions:
– Filters (e.g., Concat, Reverse, IfNull, UrlFilters, Where)
– ParamSources (file enumeration, paginator, custom query/cookie param sourcing)
– Tags (e.g., YouTube embed tag)
- src/SampleExtensions → examples of how to build extensions (sample filter, sample param source).
- src/Tests → end-to-end tests, sample templates, sample Markdown content.
- Solution file MIIS.sln glues all projects together.

##### Key README insights
- .NET Framework 4.5+, IIS URL Rewrite required.
- No DB; caching at file/template level.
- Supports Liquid tags, template inheritance, includes, fragments, dynamic parameters.
- Custom per-folder configuration via Web.config location files.

##### Main components
a. Client & Browser
b. IIS / Azure Web App
- IIS URL Rewrite module
- IISHelpers integration (module registration, caching hooks)
c. MIIS HTTP Handler / Module (MIISHandler assembly)
- Request pipeline: routing → front-matter resolver → Markdown parser → Renderer
d. MIISdotliquid engine (submodule)
- Template parsing, variable resolution, tag/filter execution
e. Extensions layer (dynamically loaded assemblies)
- Filters, Tags, ParamSources projects
f. File Store (content repository)
- Markdown (.md/.mdh), HTML templates, Web.config per folder, assets
g. Cache subsystem
- Template cache, file cache, folder-tree cache
h. Response output to client

##### Relationships and data flows
- Handler → reads Web.config and front-matter → loads content file → passes raw Markdown/HTML to parser
- Parser → hands AST to MIISdotliquid → applies templates, includes, tags, filters (from Extensions)
- Renderer → final HTML → cache if enabled → HTTP Response → Browser

##### Architectural patterns and design principles
- Pipeline pattern in the HTTP request/response flow
- Plugin architecture for filters, tags, param sources (each extension is a separate assembly loaded by convention)
- Separation of concerns:
- Hosting concerns (IISHelpers)
- Core parsing/rendering (MIISHandler + MIISdotliquid)
- Extensions (Filters/Tags/ParamSources)
- Tests and samples kept in separate projects
- Configuration-by-convention with override via folder Web.config

##### Technologies, frameworks, and libraries
- .NET Framework 4.5+, ASP.NET HTTP Module/Handler
- Liquid templating engine (via MIISdotliquid, itself built on DotLiquid)
- Git submodules for dependency code sharing
- URL Rewrite extension for clean URLs
- C# projects (.csproj), NuGet packages (packages.config)

##### Detail level
- Assembly/project as its own node if clarity demands (e.g., IISHelpers vs. MIISdotliquid vs. MIISHandler).
- Integration points: “Loads Filters via reflection from ~/Extensions/Filters”, “Reads per-folder configuration from Web.config”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hosting Layer
    subgraph "Hosting Layer"
        direction TB
        IISURL["IIS URL Rewrite"] 
        IISHelpers["IIS Integration Helpers"] 
    end

    %% Core Engine
    subgraph "Core Engine"
        direction TB
        Handler["MIISHandler Module"]
        Renderer["Renderer"]
        MDResolver["Front-matter & Field Resolver"]
        MIISFileModel["File Model Classes"]
        PluginInterfaces["Plugin Source Interfaces"]
        FilterFactory["Filter Factory Interface"]
        BuiltInTag["Built-in Tag (InsertFile)"]
        MIISConfig["Web.config"]
        LiquidEngine["Liquid Engine (MIISdotliquid)"]
    end

    %% Extensions Layer
    subgraph "Extensions Layer"
        direction TB
        FiltersProj["Filters Project"]
        Concat["Concat Filter"]
        Reverse["Reverse Filter"]
        IfNull["IfNull Filter"]
        UrlFilters["Url Filters"]
        Where["Where Filter"]

        ParamProj["ParamSources Project"]
        FilesEnum["Files Enumerator"]
        Paginator["Paginator"]
        FilesFromFolder["FilesFromFolderParamSrc"]
        DataFromFile["DataFromFileParamSrc"]
        CategsFolder["CategsFolderParamSrc"]
        TagsFolder["TagsFolderParamSrc"]
        FolderTreeCacheDep["Folder-Tree Cache Dependency"]

        TagsProj["Tags Project"]
        YouTubeTag["YouTube Embed Tag"]
    end

    %% Sample Extensions
    subgraph "Sample Extensions"
        direction TB
        RandomSample["Random Param Sample"]
        TitleCaseSample["TitleCase Filter Sample"]
    end

    %% File & Config Store
    subgraph "File & Config Store"
        direction TB
        FileStore["Content File Store"]:::data
        WebConfigStore["Per-folder Web.config"]:::data
    end

    %% Cache Subsystem
    subgraph "Cache Subsystem"
        direction TB
        TemplateCache["Template Cache"]:::cache
        FileCache["File Cache"]:::cache
        FolderTreeCache["Folder-Tree Cache"]:::cache
    end

    %% Flow
    Browser["Client Browser"] 
    Browser -->|HTTP GET| IISURL
    IISURL -->|rewrite| IISHelpers
    IISHelpers -->|invoke| Handler

    WebConfigStore -.->|reads| Handler
    FileStore -->|load content| Handler
    Handler -->|parse front-matter| MDResolver
    MDResolver -->|produce AST| Renderer
    Renderer -->|render markdown| LiquidEngine

    LiquidEngine -->|apply filters/tags| FiltersProj
    FiltersProj --> Concat
    FiltersProj --> Reverse
    FiltersProj --> IfNull
    FiltersProj --> UrlFilters
    FiltersProj --> Where

    LiquidEngine -->|apply params| ParamProj
    ParamProj --> FilesEnum
    ParamProj --> Paginator
    ParamProj --> FilesFromFolder
    ParamProj --> DataFromFile
    ParamProj --> CategsFolder
    ParamProj --> FolderTreeCacheDep

    LiquidEngine -->|apply tags| TagsProj
    TagsProj --> YouTubeTag

    Renderer -->|output HTML| TemplateCache
    Renderer --> FileCache
    TemplateCache --> FolderTreeCache

    TemplateCache -->|HTTP Response| Browser

    %% Click events
    click IISHelpers "https://github.com/jmalarcon/miis/tree/master/IISHelpers/"
    click LiquidEngine "https://github.com/jmalarcon/miis/tree/master/MIISdotliquid/"
    click Handler "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/MIISHandler.csproj"
    click Renderer "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/Renderer.cs"
    click MDResolver "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/MDFieldsResolver.cs"
    click MIISFileModel "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/MIISFile.cs"
    click MIISFileModel "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/MarkdownFile.cs"
    click PluginInterfaces "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/FMSources/IFMSource.cs"
    click PluginInterfaces "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/FMSources/IQueryStringDependent.cs"
    click FilterFactory "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/Filters/IFilterFactory.cs"
    click BuiltInTag "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/Tags/InsertFile.cs"
    click MIISConfig "https://github.com/jmalarcon/miis/blob/master/src/MIISHandler/Web.config"

    click FiltersProj "https://github.com/jmalarcon/miis/blob/master/src/Extensions/Filters/MIISLiquidFilters/MIISLiquidFilters.csproj"
    click Concat "https://github.com/jmalarcon/miis/blob/master/src/Extensions/Filters/MIISLiquidFilters/ConcatFilter.cs"
    click Reverse "https://github.com/jmalarcon/miis/blob/master/src/Extensions/Filters/MIISLiquidFilters/ReverseFilter.cs"
    click IfNull "https://github.com/jmalarcon/miis/blob/master/src/Extensions/Filters/MIISLiquidFilters/IfNullFilter.cs"
    click UrlFilters "https://github.com/jmalarcon/miis/blob/master/src/Extensions/Filters/MIISLiquidFilters/UrlFilters.cs"
    click Where "https://github.com/jmalarcon/miis/blob/master/src/Extensions/Filters/MIISLiquidFilters/WhereFilter.cs"

    click ParamProj "https://github.com/jmalarcon/miis/blob/master/src/Extensions/ParamSources/FilesEnumeratorParam/MIISFilesEnumeratorFMS.csproj"
    click FilesEnum "https://github.com/jmalarcon/miis/blob/master/src/Extensions/ParamSources/FilesEnumeratorParam/FilesEnumerator.cs"
    click Paginator "https://github.com/jmalarcon/miis/blob/master/src/Extensions/ParamSources/FilesEnumeratorParam/Paginator.cs"
    click FilesFromFolder "https://github.com/jmalarcon/miis/blob/master/src/Extensions/ParamSources/FilesEnumeratorParam/FilesFromFolderParamSrc.cs"
    click DataFromFile "https://github.com/jmalarcon/miis/blob/master/src/Extensions/ParamSources/FilesEnumeratorParam/DataFromFileParamSrc.cs"
    click CategsFolder "https://github.com/jmalarcon/miis/blob/master/src/Extensions/ParamSources/FilesEnumeratorParam/CategsFolderParamSrc.cs"
    click TagsFolder "https://github.com/jmalarcon/miis/blob/master/src/Extensions/ParamSources/FilesEnumeratorParam/TagsFolderParamSrc.cs"
    click FolderTreeCacheDep "https://github.com/jmalarcon/miis/blob/master/src/Extensions/ParamSources/FilesEnumeratorParam/FolderTreeCacheDependency.cs"

    click TagsProj "https://github.com/jmalarcon/miis/blob/master/src/Extensions/Tags/MIISYouTubeTag/MIISYouTubeTag.csproj"
    click YouTubeTag "https://github.com/jmalarcon/miis/blob/master/src/Extensions/Tags/MIISYouTubeTag/YouTube.cs"

    click RandomSample "https://github.com/jmalarcon/miis/blob/master/src/SampleExtensions/MIISRandomParamSample/MIISRandomParamSample.csproj"
    click RandomSample "https://github.com/jmalarcon/miis/blob/master/src/SampleExtensions/MIISRandomParamSample/RandomParamSample.cs"
    click TitleCaseSample "https://github.com/jmalarcon/miis/blob/master/src/SampleExtensions/MIISToTitleCaseFilter/MIISTitleCaseSampleFilter.csproj"
    click TitleCaseSample "https://github.com/jmalarcon/miis/blob/master/src/SampleExtensions/MIISToTitleCaseFilter/TitleCaseFilter.cs"

    click FileStore "https://github.com/jmalarcon/miis/tree/master/src/Tests/_data/"
    click WebConfigStore "https://github.com/jmalarcon/miis/blob/master/src/Tests/Web.config"

    click FolderTreeCache "https://github.com/jmalarcon/miis/blob/master/src/Extensions/ParamSources/FilesEnumeratorParam/FolderTreeCacheDependency.cs"

    %% Styles
    classDef hosting fill:#dae8fc,stroke:#6c8ebf
    classDef core fill:#d5e8d4,stroke:#82b366
    classDef ext fill:#fff2cc,stroke:#d6b656
    classDef data fill:#fff2cc,stroke:#d6b656
    classDef cache fill:#fff2cc,stroke:#d6b656

    class IISURL,IISHelpers hosting
    class Handler,Renderer,MDResolver,MIISFileModel,PluginInterfaces,FilterFactory,BuiltInTag,MIISConfig,LiquidEngine core
    class FiltersProj,Concat,Reverse,IfNull,UrlFilters,Where,ParamProj,FilesEnum,Paginator,FilesFromFolder,DataFromFile,CategsFolder,FolderTreeCacheDep,TagsProj,YouTubeTag ext
    class FileStore,WebConfigStore data
    class TemplateCache,FileCache,FolderTreeCache cache
```
